/// <summary> /// Creates Game1. /// </summary> public GMGame CreateGame1() { //create games and add triggers GMGame game = new GMGame("game1"); //create conditions ACondition cond1 = new TestCondition("Test-Cond-1", true); //ACondition cond2 = new TestCondition("Test-Cond-2", true); ACondition falseCond = new FalseCondition(); ACondition trueCond = new TrueCondition(); ACondition relTimeCond = new TimerCondition(TimerType.Relative, 1, game.TimeSource); //true after 1sec //create triggers ScriptTrigger<int> trigger1 = new ScriptTrigger<int>( 2, 500, trueCond.Check, null, TestScriptFunctionInt, 111); ScriptTrigger<int> trigger2 = new ScriptTrigger<int>(); trigger2.Value = 222; trigger2.Function = TestScriptFunctionInt; trigger2.Priority = 3; trigger2.Repeat = 3; trigger2.FireCondition = cond1.Check; //this will only be fired, when both fireCondition is true at the same time ScriptTrigger<string> trigger3 = new ScriptTrigger<string>(); trigger3.Value = "game2"; trigger3.Function = TestScriptFunctionString; trigger3.Priority = 1; trigger3.Repeat = 1; //only fire once trigger3.FireCondition += trueCond.Check; //always true, but you can check sg extra here trigger3.FireCondition += relTimeCond.Check; //should fire only when time reached trigger3.DeleteCondition = falseCond.Check; //don't remove until repeating game.AddTrigger(trigger1); game.AddTrigger(trigger2); Debug.Log ("Added trigger 3"); game.AddTrigger(trigger3); return game; }
/// <summary> /// Creates Game2. /// </summary> public GMGame CreateGame2() { //create conditions ACondition falseCond = new FalseCondition(); ACondition trueCond = new TrueCondition(); ScriptCondition<bool> scriptCond = new ScriptCondition<bool>(TestScriptConditionEvaulateBool, true); //create triggers ScriptTrigger<int> trigger1 = new ScriptTrigger<int>(2, 2, trueCond.Check, trueCond.Check, TestScriptFunctionInt, 1); ScriptTrigger<float> trigger2 = new ScriptTrigger<float>(5, 10, trueCond.Check, falseCond.Check, TestScriptFunctionFloat, 2.2f); ScriptTrigger<string> trigger3 = new ScriptTrigger<string>(1, 3, null, null, TestScriptFunctionString, "no conditions"); DialogTrigger trigger4 = new DialogTrigger(1, 3, scriptCond.Check, null, "myDialog"); //create games and add triggers GMGame game = new GMGame("game2"); game.AddTrigger(trigger1); game.AddTrigger(trigger2); game.AddTrigger(trigger3); game.AddTrigger(trigger4); return game; }
// Use this for initialization void Awake() { Debug.Log("<color=cyan>START GAME</color>"); if (startText == null) Debug.LogError("No <color=cyan>startText</color> assigned to:<color=cyan>"+gameObject.name+"</color>"); if (screen1 == null) Debug.LogError("No <color=cyan>screen1</color> assigned to:<color=cyan>"+gameObject.name+"</color>"); if (screen2 == null) Debug.LogError("No <color=cyan>screen2</color> assigned to:<color=cyan>"+gameObject.name+"</color>"); UIManager ui = UIManager.Instance; UIManager.ScreenChanged = notifyScreenChanged; ui.AddScreen(screen1); ui.AddScreen(screen2); ui.ActivateScreen(screen1.name); startText.SetActive(false); //localisation i18nManager = I18nManager.Instance; i18nManager.SetLanguage(lang); //add an empty main game GMGame game = new GMGame("TestGame"); gm = GameManager.Instance; ACondition falseCond = new FalseCondition(); ACondition trueCond = new TrueCondition(); ACondition relTimeCond = new TimerCondition(TimerType.Absolute, 8, game.TimeSource); //true after 1sec //this will only be fired, when both fireCondition is true at the same time ScriptTrigger<string> trigger3 = new ScriptTrigger<string>(); trigger3.Value = "TestGame"; trigger3.Function = TestScriptFunctionString; trigger3.Priority = 1; trigger3.Repeat = 1; //only fire once trigger3.FireCondition += trueCond.Check; //always true, but you can check sg extra here trigger3.FireCondition += relTimeCond.Check; //should fire only when time reached trigger3.DeleteCondition = falseCond.Check; //don't remove until repeating gm.Add (game); game.AddTrigger(trigger3); Debug.Log (" ----> AddTrigger 3"); gm.Start(game.Name); }