コード例 #1
0
        // 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);
        }
	    /// <summary>
	    /// Helper for processing blinking of an image.
	    /// It will toggle the visible flag based on the preset values
	    /// </summary>
	    public void BlinkToggle(UIImage image)
	    {
	    	//Log.Info("BlinkToggle:"+image.Name);

	    	//TODO use reference here!!

	    	//TODO show/hide, but could use sprites states as well
			//image.Visible = !image.Visible;
			if(image.Sprite == 0)
				image.Sprite = 1;
			else if(image.Sprite == 1)
				image.Sprite = 0;

	    	if(--image.blinkNumber > 0)
	    	{

		    	TimerCondition relTimeCondBlink = 
					new TimerCondition(TimerType.Relative, image.blinkSpeed, gpm.DialogGame.TimeSource);
				timeTrigger = 
					new ScriptTrigger<UIImage>(1, 1, relTimeCondBlink.Check, null, BlinkToggle, image);

				gpm.DialogGame.AddTrigger(timeTrigger);
			}
			
			if(image.blinkNumber == 0)
			{
				image.Sprite = 0;
				//image.Visible = true;
			}
	    }
コード例 #3
0
        //------------------------------------------------------------------------------
        /// <summary>
        /// helper to create trigger for wait and trigger
        /// </summary>
        public ScriptTrigger<string> DelayedCommand(double time, string param)
        {
            time /= 1000.0;
            // Log.Debug("Delayed "+fullId+" Command: " + param + " delay:"+time);

            // Relative means here, that the time is ADDED to the current gameTime
            TimerCondition relTimeCond = new TimerCondition(TimerType.Relative,
                                  time, GameManager.Instance.DialogGame.TimeSource);
            ScriptTrigger<string> timeTrigger =
                    new ScriptTrigger<string>(1, 1, relTimeCond.Check, null, TimeExpired, param);
            GameManager.Instance.DialogGame.AddTrigger(timeTrigger);

            return timeTrigger;
        }
コード例 #4
0
        public void ProcessTimelineEvent(string eventId, string param)
        {
            if (eventId != "SIM") return;

            //WebPlayerDebugManager.addOutput(eventId + " " + param, 2);

            switch (param)
            {
            case "Pause":	   	if (Speed != 0) oldSpeed = Speed;
                                Speed = 0;
                                timeLine.PauseSlider();
                                break;
            case "Unpause":	   	Speed = oldSpeed;
                                timeLine.UnpauseSlider();
                                simMenu.SetActive (true);
                                scoreBoard.SetActive (true);
                                break;
            case "Activate":   	timeLine.isActive = true;
                                timeLine.VisibleWhenInScreen = true;
                                timeLine.gameObject.SetActive(true);
                                break;
            case "Start":	   	{
                                    ACondition relTimeCondSIM =
                                        new TimerCondition(TimerType.Relative,
                                                           timeStep, TimeSource);  //true after 1sec

                                    triggerSIMTime =
                                        new ScriptTrigger<int>(1, -1,
                                                               relTimeCondSIM.Check,
                                                               null, UpdateSIMTime, 1);

                                    AddTrigger(triggerSIMTime);

                                    //WebPlayerDebugManager.addOutput ("Trigger added!", 1);
                                    Speed = 1;
                                    timeLine.StartSlider();
                                }
                                break;
            case "Restart":	   	{
                                    WebPlayerDebugManager.addOutput("restarting timeline SIM", 2);
                                    value = 0;

                                    ACondition relTimeCondSIM =
                                        new TimerCondition(TimerType.Relative,
                                                           timeStep, TimeSource);  //true after 1sec

                                    triggerSIMTime =
                                        new ScriptTrigger<int>(1, -1,
                                                               relTimeCondSIM.Check,
                                                               null, UpdateSIMTime, 1);

                                    AddTrigger(triggerSIMTime);

                                    //WebPlayerDebugManager.addOutput ("Trigger added!", 1);

                                    oldSpeed = 1;
                                    date = startDate;

                                    Speed = 0;
                                    timeLine.PauseSlider();

                                    actTime = (float) TimeSource.Time;
                                    lastTime = actTime;

                                }
                                break;
            case "Deactivate": 	timeLine.isActive = false;
                                timeLine.VisibleWhenInScreen = false;
                                timeLine.gameObject.SetActive(false);
                                break;
            case "Stop":	   	if (timeLine.isActive)
                                    timeLine.StopSlider();
                                RemoveTrigger(triggerSIMTime);
                                break;
            case "Speed_1":	   	Speed = 1;
                                break;
            case "Speed_2":	   	Speed = 2;
                                break;
            case "Speed_4":	   	Speed = 4;
                                    break;
            }
        }