playMaker

Author Topic: IsApplicationGenuine.cs  (Read 6732 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
IsApplicationGenuine.cs
« on: August 23, 2011, 04:03:32 AM »
hi,

 Following the request from http://hutonggames.com/playmakerforum/index.php?topic=545.0

Here is a simple action that can store isApplicationGenuineAvailable and isApplicationGenuine in bools as well as dispatching events.
 
Could someone check it work for android. I have a hard time figuring out why there is no specific android utils, I currently use iPhoneUtils. Maybe I miss the obvious, else...

The code can be found below and also attached to this post. Any mistake, please comment :)

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
//
// Author: Jean fabre 
// http://www.fabrejean.net
//
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("mobile")]
[Tooltip("Check if application is genuine and dispatch events. Can also store flags in variables")]
public class IsApplicationGenuine : FsmStateAction
{

[UIHint(UIHint.Variable)]
public FsmBool isApplicationGenuineAvailable;
[UIHint(UIHint.Variable)]
public FsmBool isApplicationGenuine;

public FsmEvent isGenuine;
public FsmEvent isNotGenuine;
public FsmEvent notVerified;

public override void Reset()
{
isApplicationGenuineAvailable = null;
isApplicationGenuine = null;
isGenuine = null;
isNotGenuine = null;
notVerified = null;


}

public override void OnEnter()
{
DoIsApplicationGenuineTest();
}

void DoIsApplicationGenuineTest()
{

isApplicationGenuineAvailable.Value = iPhoneUtils.isApplicationGenuineAvailable;
isApplicationGenuine.Value = iPhoneUtils.isApplicationGenuine;

if (iPhoneUtils.isApplicationGenuineAvailable ){

if (iPhoneUtils.isApplicationGenuine){
Fsm.Event(isGenuine);
}else{
Fsm.Event(isNotGenuine);
}

}else{
Fsm.Event(notVerified);
}
}

}
}



Bye,

 Jean

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: IsApplicationGenuine.cs
« Reply #1 on: August 23, 2011, 08:15:00 AM »
Well most support for the android is for IOS.
So they still use iphone syntax.
But almost everything for IOS do work on android.
Its just bad that they still use iphone syntax instead of a mobile syntax.

About this.
Im not sure you understand it..

This syntax should be checked first  isApplicationGenuineAvailable.
If that is true then it should check isApplicationGenuine.

If you only check isApplicationGenuine then you can get an error if its not used.So i think you should split this up to 2 actions.
So if you check  isApplicationGenuineAvailable first and its true you can use the second action to check that to.
If  isApplicationGenuineAvailable is not true then it should not do anything.

So isApplicationGenuineAvailable = true then send it to an event.
If isApplicationGenuine true then continue with the game, if not then send it to an new event.
In that new event you can show the user a new screen or send the user to the market and close the program.





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IsApplicationGenuine.cs
« Reply #2 on: August 23, 2011, 02:21:16 PM »
Hi,

 Isn't it what it's doing? or do you mean that I should not store into bool first thing?


Quote
This syntax should be checked first  isApplicationGenuineAvailable.
If that is true then it should check isApplicationGenuine.

It's doing this. the first if statement check for isApplicationGenuineAvailable, if true procesed with isApplicationGenuine

 Or I am still missing the point  ???


Quote
If you only check isApplicationGenuine then you can get an error if its not used.

Is it a bug? cause the documentation seems to say that isApplicationGenuine simply returns false wether it's actually available or not.

I have put the sample from the custom action where I do the check bellow:

Code: [Select]
if (iPhoneUtils.isApplicationGenuineAvailable ){

if (iPhoneUtils.isApplicationGenuine){
Fsm.Event(isGenuine);
}else{
Fsm.Event(isNotGenuine);
}

}else{
Fsm.Event(notVerified);
}

so first, I check if genuine test is available and then I perform the test.

I don't think you do need two actions for this since with this custom action, you can route all possible way out of it I think.


Also, How do you actually manage to verify this action actually? Do you have some steps to be able to touch the code so that it triggers false for isApplicationGenuineAvailable and isApplicationGenuine?

 

 Bye,

 Jean


Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: IsApplicationGenuine.cs
« Reply #3 on: August 23, 2011, 03:32:09 PM »
Hi,

 Isn't it what it's doing? or do you mean that I should not store into bool first thing?


Quote
This syntax should be checked first  isApplicationGenuineAvailable.
If that is true then it should check isApplicationGenuine.

It's doing this. the first if statement check for isApplicationGenuineAvailable, if true procesed with isApplicationGenuine

 Or I am still missing the point  ???


Quote
If you only check isApplicationGenuine then you can get an error if its not used.

Is it a bug? cause the documentation seems to say that isApplicationGenuine simply returns false wether it's actually available or not.

I have put the sample from the custom action where I do the check bellow:

Code: [Select]
if (iPhoneUtils.isApplicationGenuineAvailable ){

if (iPhoneUtils.isApplicationGenuine){
Fsm.Event(isGenuine);
}else{
Fsm.Event(isNotGenuine);
}

}else{
Fsm.Event(notVerified);
}

so first, I check if genuine test is available and then I perform the test.

I don't think you do need two actions for this since with this custom action, you can route all possible way out of it I think.


Also, How do you actually manage to verify this action actually? Do you have some steps to be able to touch the code so that it triggers false for isApplicationGenuineAvailable and isApplicationGenuine?

 

 Bye,

 Jean



Maybe i did not read it to good, but there was not much info in the playmaker either.
if it first check isApplicationGenuineAvailable is true then check isApplicationGenuine if that true or false before it do any event then it work with one action.
isApplicationGenuine do return false if its not genuine, but also if isApplicationGenuineAvailable is false.
Thats why you need to check isApplicationGenuineAvailable first and if that false you dont need to check isApplicationGenuine for you know that will always be false.
So if isApplicationGenuineAvailable is fase the only even it shuld do is that is not validated.
Maybe you did that already. but it was not so clear when i was in playmaker and i needed to be sure it works like it should.

So
isApplicationGenuineAvailable = true
 then
   if isApplicationGenuine = true
     then event(run your game)
  Else event( run a info page)
  end
else
 event(not validated)
end


But it might like you do that already. I just need to be sure.. :-)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IsApplicationGenuine.cs
« Reply #4 on: August 24, 2011, 01:09:40 AM »
Hi,

 Yes, it is like that  ;)

 Bye,

 Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: IsApplicationGenuine.cs
« Reply #5 on: June 26, 2012, 06:08:48 AM »
Anyone get this working with Android LVL ?

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: IsApplicationGenuine.cs
« Reply #6 on: January 20, 2016, 04:50:28 PM »
Anyone want to add this action to ecosystem?
Cheers
Seb