Exemplo n.º 1
0
 private void HookScriptTriggers(Script script)
 {
     foreach (ScriptTrigger scriptTrigger in script.Triggers)
     {
         ScriptTrigger        triggerCopy          = scriptTrigger;
         EntityTypeDescriptor entityTypeDescriptor = EntityTypes.Types[scriptTrigger.Object.Type];
         EventDescriptor      eventDescriptor      = entityTypeDescriptor.Events[scriptTrigger.Event];
         if (entityTypeDescriptor.Static)
         {
             Action action = (Action)(() => this.ProcessTrigger(triggerCopy, script));
             object obj    = eventDescriptor.AddHandler((object)this.services[scriptTrigger.Object.Type], new object[1]
             {
                 (object)action
             });
         }
         else
         {
             Action <int> action = (Action <int>)(id => this.ProcessTrigger(triggerCopy, script, new int?(id)));
             object       obj    = eventDescriptor.AddHandler((object)this.services[scriptTrigger.Object.Type], new object[1]
             {
                 (object)action
             });
         }
     }
 }
Exemplo n.º 2
0
 public ScriptTrigger Clone()
 {
   ScriptTrigger scriptTrigger = new ScriptTrigger();
   scriptTrigger.Event = this.Event;
   scriptTrigger.Object = this.Object.Clone();
   return scriptTrigger;
 }
Exemplo n.º 3
0
        public ScriptTrigger Clone()
        {
            ScriptTrigger scriptTrigger = new ScriptTrigger();

            scriptTrigger.Event  = this.Event;
            scriptTrigger.Object = this.Object.Clone();
            return(scriptTrigger);
        }
Exemplo n.º 4
0
        private static void ProcessEndTrigger(ScriptTrigger trigger, ActiveScript script, int?id)
        {
            int?nullable   = id;
            int?identifier = trigger.Object.Identifier;

            if ((nullable.GetValueOrDefault() != identifier.GetValueOrDefault() ? 0 : (nullable.HasValue == identifier.HasValue ? 1 : 0)) == 0)
            {
                return;
            }
            script.Dispose();
        }
        // 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);
        }
Exemplo n.º 6
0
    // METHODES START
    private void InitializationDesBots()
    {
        Bots             = ScriptFactory.GetGameObjectsBot();
        BotsProperties   = new ScriptPnjProperties[Bots.Length];
        BotsDialogues    = new ScriptParler[Bots.Length];
        BotsTriggers     = new ScriptTrigger[Bots.Length];
        BotsDeplacements = new ScriptDeplacementAutomatique[Bots.Length];

        foreach (GameObject bot in Bots)
        {
            Debug.Log("Chargement des bots...");

            BotsProperties[i]          = ScriptFactory.GetScriptAttachedOnGO <ScriptPnjProperties>(bot);
            BotsDeplacements[i]        = ScriptFactory.GetScriptAttachedOnGO <ScriptDeplacementAutomatique>(bot);
            BotsTriggers[i]            = ScriptFactory.GetScriptTriggerInChildOf(bot);
            BotsDialogues[i]           = ScriptFactory.GetScriptParler(bot);
            BotsDialogues[i].IsTalking = false;
            i++;
        }
    }
    /// <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;
    }
Exemplo n.º 9
0
    // METHODES
    public void DeplacementAutomatique(int frames, ScriptTrigger trigger)
    {
        // Donner un nouveau random
        int random = Random.Range(60, 500);

        // S'arrêter
        if (((frames % random) - 100) == 0)
        {
            CanWalk = false;
        }

        // Rotationner puis marcher
        if (frames % random == 0 || trigger.TouchAWall)
        {
            Rotationner(gameObject, Random.Range(-180, 180));
            trigger.TouchAWall = false;
            CanWalk            = true;
        }

        if (CanWalk)
        {
            Avancer(gameObject, WalkSpeed);
        }
    }
        //------------------------------------------------------------------------------
        /// <summary>
        /// Fire this trigger.
        /// </summary>
        public override bool Fire()
        {
            //Log.Debug("fire:"+id);
            //call function(s) if Fire allowed
            if(base.Fire())
            {
                //TODO: send trigger event to UI or register delegate from UI?
                //// Log.Debug("----> Dialog:"+id+" fired event:"+trigger+","+emotion);

                // //create Dialog model and send event
                UIDialog d =  new UIDialog(id,
                                           dialogtype,
                                           screenId,
                                           characterImage,
                                           characterName,
                                           characterVisible,
                                           texts,
                                           position,
                                           npcPosition);
                UIManager.Instance.AddDialog(d);
                GameManager.Instance.Event("DIALOG", fullId, "show");

                //only if not multichoice,
                //when we need to wait for the selected item
                if(dialogtype != DialogType.MULTICHOICE)
                {
                    if(triggerDelay == 0)
                    {
                        //wait for user action
                        triggerDelayObject = null;
                        //GameManager.Instance.Event(GameEvent.DIALOG, trigger, "fire");
                    }
                    else
                    {
                        triggerDelayObject = DelayedCommand(triggerDelay, "trigger");
                    }

                    if(deleteEventDelay > 0)
                    {
                        //TODO might need to add triggerDelay as well?
                        deleteDelayObject = DelayedCommand(deleteEventDelay, "delete");
                    }

                }

                return true;
            }

            return false;
        }
        //------------------------------------------------------------------------------
        /// <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;
        }
        /// <summary>
        /// Create DialogTrigger from dictionary
        /// which was parsed by json
        /// </summary>
        public DialogTrigger(Dictionary<string,object> dialog)
        {
            // Log.Info("ctor DialogTrigger");
            Clear();

            ///--- defaults
            this.priority = 1;  //set in json?
            this.repeat = 1;
            this.fireCondition = CheckFire;
            this.deleteCondition = CheckDelete;
            this.fireFlag = false;
            this.delFlag = false;

            ///--- must have
            this.id = dialog["id"].ToString();
            this.type = TriggerType.DIALOG;
            this.screenId = dialog["screen"].ToString();
            // runtime performance use StringBuilder
            StringBuilder sb = new StringBuilder();
            sb.Append(this.screenId);
            sb.Append(".");
            sb.Append(this.id);
            this.fullId = sb.ToString();

            //set default fire condition to the same as the id
            this.fireEventId = this.fullId;
            this.deleteEventId = "";
            this.fireEventDelay = 0;
            this.deleteEventDelay = 0;
            this.triggerDelay = 0;
            this.triggerDelayObject = null;
            this.deleteDelayObject = null;
            this.triggered = false;

            //GameManager.Instance.AddEventHandler(EventHandler);

            Parse(dialog);
        }
Exemplo n.º 13
0
 private void Trigger_ExecuteCompleted(ScriptTrigger trigger)
 {
     triggerExecuteQueue.Remove(trigger);
     trigger.CurrentFrozen = trigger.frozenTime;
     triggerForzenQueue.Add(trigger);
 }
Exemplo n.º 14
0
 private void TryInitialize()
 {
     if (this.isHooked)
     {
         this.Gomez.EnteredDoor -= new Action(this.CheckWinCondition);
         this.isHooked           = false;
     }
     if (this.LevelManager.Name != "CRYPT")
     {
         this.TraversedVolumes.Clear();
     }
     else
     {
         if (this.LevelManager.LastLevelName == "CRYPT")
         {
             this.TraversedVolumes.Add(this.PlayerManager.DoorVolume.Value);
             if (this.TraversedVolumes.Count > 4)
             {
                 this.TraversedVolumes.RemoveAt(0);
             }
             for (int index = 0; index < this.TraversedVolumes.Count; ++index)
             {
                 if (CryptHost.VolumeSequence[this.TraversedVolumes.Count - 1 - index] != this.TraversedVolumes[this.TraversedVolumes.Count - 1 - index])
                 {
                     this.TraversedVolumes.Clear();
                     break;
                 }
             }
         }
         else
         {
             this.TraversedVolumes.Clear();
         }
         ICollection <int> keys     = this.LevelManager.Scripts.Keys;
         int[]             numArray = new int[4]
         {
             0,
             1,
             2,
             3
         };
         foreach (int key in Enumerable.ToArray <int>(Enumerable.Except <int>((IEnumerable <int>)keys, (IEnumerable <int>)numArray)))
         {
             this.LevelManager.Scripts.Remove(key);
         }
         foreach (Volume volume in (IEnumerable <Volume>) this.LevelManager.Volumes.Values)
         {
             if (volume.Id > 1 && (volume.Id != 14 || this.TraversedVolumes.Count != 3))
             {
                 int key = IdentifierPool.FirstAvailable <Script>(this.LevelManager.Scripts);
                 int num = RandomHelper.InList <int>(Enumerable.Except <int>((IEnumerable <int>) this.LevelManager.Volumes.Keys, (IEnumerable <int>) new int[3]
                 {
                     0,
                     1,
                     volume.Id
                 }));
                 Script script1 = new Script();
                 script1.Id = key;
                 List <ScriptTrigger> triggers       = script1.Triggers;
                 ScriptTrigger        scriptTrigger1 = new ScriptTrigger();
                 scriptTrigger1.Event  = "Enter";
                 scriptTrigger1.Object = new Entity()
                 {
                     Type       = "Volume",
                     Identifier = new int?(volume.Id)
                 };
                 ScriptTrigger scriptTrigger2 = scriptTrigger1;
                 triggers.Add(scriptTrigger2);
                 List <ScriptAction> actions       = script1.Actions;
                 ScriptAction        scriptAction1 = new ScriptAction();
                 scriptAction1.Operation = "ChangeLevelToVolume";
                 scriptAction1.Arguments = new string[4]
                 {
                     "CRYPT",
                     num.ToString(),
                     "True",
                     "False"
                 };
                 scriptAction1.Object = new Entity()
                 {
                     Type = "Level"
                 };
                 ScriptAction scriptAction2 = scriptAction1;
                 actions.Add(scriptAction2);
                 Script script2 = script1;
                 foreach (ScriptAction scriptAction3 in script2.Actions)
                 {
                     scriptAction3.Process();
                 }
                 this.LevelManager.Scripts.Add(key, script2);
             }
         }
         this.LevelManager.Scripts[2].Disabled = this.TraversedVolumes.Count != 3;
     }
 }
Exemplo n.º 15
0
 public ActiveScript(Script script, ScriptTrigger initiatingTrigger)
 {
     ServiceHelper.InjectServices((object)this);
     this.Script            = script;
     this.InitiatingTrigger = initiatingTrigger;
 }
Exemplo n.º 16
0
        public void ReloadObjMap(string[] pMapObjFile)
        {
            MapObjects.Clear();
            LightPoints.Clear();

            foreach (var obj in pMapObjFile)
            {
                if (obj.Length < 2)
                {
                    continue;
                }

                string[] LineArgs       = obj.Split(';');
                int      TileX          = Convert.ToInt32(LineArgs[0]) * Global.TileSize;
                int      TileY          = Convert.ToInt32(LineArgs[1]) * Global.TileSize;
                string[] TileProperties = LineArgs[2].Split(',');

                MapTile ThisTile = new MapTile(TileX, TileY, TileProperties, MapObjects.Count);

                if (ThisTile.ObjectTileIDType != -1)
                {
                    if (ThisTile.ObjectTileIDType == 1)
                    {
                        CurrentPlayer = new Player(TileX, TileY, this);
                    }
                    if (ThisTile.ObjectTileIDType == 2)
                    {
                        //ScriptTrigger Stta = new ScriptTrigger(ThisTile.TileArgs, TileX, TileY, MapView);
                        string ParsedScriptName       = "";
                        string ParsedEventName        = "";
                        string ParsedID               = "";
                        bool   ParsedColideable       = false;
                        bool   ActivateViaActionKey   = false;
                        string ParsedColideableSprite = "";

                        for (int i = 0; i < TileProperties.Length; i++)
                        {
                            string[] Parameter = TileProperties[i].Split(':');

                            switch (Parameter[0])
                            {
                            case "script_name":
                                ParsedScriptName = Parameter[1];
                                break;

                            case "event_name":
                                ParsedEventName = Parameter[1];
                                break;

                            case "script_id":
                                ParsedID = Parameter[1];
                                break;

                            case "script_colideable":
                                ParsedColideable = true;
                                break;

                            case "colideable_sprite":
                                ParsedColideableSprite = Parameter[1];
                                break;

                            case "action_key":
                                ActivateViaActionKey = true;
                                break;
                            }
                        }

                        ScriptTrigger Stta = new ScriptTrigger(ParsedScriptName, ParsedEventName, ParsedColideable, ParsedColideableSprite, ParsedID, ActivateViaActionKey, TileX, TileY, MapView);


                        MapObjects.Add(Stta);
                    }
                    if (ThisTile.ObjectTileIDType == 4)
                    {
                        LightPoint LightPointToAdd   = new LightPoint(this, TileX, TileY, 10, "default");
                        int        ParsedLightRadius = 100;
                        string     ParsedLightShape  = "default";

                        for (int i = 0; i < TileProperties.Length; i++)
                        {
                            string[] Parameter = TileProperties[i].Split(':');

                            switch (Parameter[0])
                            {
                            case "light_radius":
                                ParsedLightRadius = Convert.ToInt32(Parameter[1]);
                                break;

                            case "light_shape":
                                ParsedLightShape = Parameter[1];
                                break;
                            }
                        }
                        LightPointToAdd.Radius = ParsedLightRadius;
                        LightPointToAdd.SetLightShape(ParsedLightShape);

                        LightPoints.Add(LightPointToAdd);
                    }
                }
            }
        }
Exemplo n.º 17
0
 private void ProcessTrigger(ScriptTrigger trigger, Script script)
 {
     this.ProcessTrigger(trigger, script, new int?());
 }
        public void ProcessTimelineEvent(string eventId, string param)
        {
            if (eventId != "CP") return;

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

            switch (param)
            {
            case "Pause":	Speed = 0;
                timeLine.PauseSlider();
                break;
            case "Unpause":	Speed = 1;
                timeLine.UnpauseSlider();
                break;
            case "Activate":   	timeLine.isActive = true;
                timeLine.VisibleWhenInScreen = true;
                timeLine.gameObject.SetActive(true);
                timeLine.Show(true);
                break;
            case "Start":

                relTimeCondCP =
                    new TimerCondition(TimerType.Relative,
                                       timeStep, TimeSource);  //true after timestep

                triggerCPTime =
                    new ScriptTrigger<int>(1, -1,
                                           relTimeCondCP.Check,
                                           null, UpdateCPTime, 1);
                AddTrigger(triggerCPTime);

                lastTime = (float) TimeSource.Time;
                timeLine.StartSlider();
                break;
            case "Deactivate": 	timeLine.isActive = false;
                timeLine.VisibleWhenInScreen = false;
                timeLine.gameObject.SetActive(false);
                timeLine.Show(false);
                break;
            case "Stop":	   	RemoveTrigger(triggerCPTime);
                timeLine.StopSlider();
                break;
            }
        }
        /// <summary>
        /// Helper for timer.
        /// This function will be called when a timer is expired.
        /// </summary>
        public void TimeExpired(string param)
        {
            // Log.Debug("TimeExpired: "+fullId+":"+param+ " delFlag:"+delFlag);

            if(param == "trigger")
            {
                Trigger();
                triggerDelayObject = null;
            }
            else if(param == "fire" && !delFlag)
            {
                fireFlag = true;
            }
            else if(param == "delete")
            {
                delFlag = true;
                deleteDelayObject = null;
            }
        }
Exemplo n.º 20
0
        private void ProcessTrigger(ScriptTrigger trigger, Script script, int?id)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            ScriptingHost.\u003C\u003Ec__DisplayClass11 cDisplayClass11 = new ScriptingHost.\u003C\u003Ec__DisplayClass11();
            // ISSUE: reference to a compiler-generated field
            cDisplayClass11.trigger = trigger;
            // ISSUE: reference to a compiler-generated field
            cDisplayClass11.script = script;
            // ISSUE: reference to a compiler-generated field
            cDisplayClass11.\u003C\u003E4__this = this;
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            if (this.GameState.Loading && cDisplayClass11.trigger.Object.Type != "Level" && cDisplayClass11.trigger.Event != "Start" || cDisplayClass11.script.Disabled)
            {
                return;
            }
            int?nullable = id;
            // ISSUE: reference to a compiler-generated field
            int?identifier = cDisplayClass11.trigger.Object.Identifier;

            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated method
            if ((nullable.GetValueOrDefault() != identifier.GetValueOrDefault() ? 1 : (nullable.HasValue != identifier.HasValue ? 1 : 0)) != 0 || cDisplayClass11.script.Conditions != null && Enumerable.Any <ScriptCondition>((IEnumerable <ScriptCondition>)cDisplayClass11.script.Conditions, (Func <ScriptCondition, bool>)(c => !c.Check(this.services[c.Object.Type]))) || cDisplayClass11.script.OneTime && Enumerable.Any <ActiveScript>((IEnumerable <ActiveScript>) this.activeScripts, new Func <ActiveScript, bool>(cDisplayClass11.\u003CProcessTrigger\u003Eb__a)))
            {
                return;
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            cDisplayClass11.activeScript = new ActiveScript(cDisplayClass11.script, cDisplayClass11.trigger);
            // ISSUE: reference to a compiler-generated field
            this.activeScripts.Add(cDisplayClass11.activeScript);
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            if (cDisplayClass11.script.IsWinCondition && !this.GameState.SaveData.ThisLevel.FilledConditions.ScriptIds.Contains(cDisplayClass11.script.Id))
            {
                // ISSUE: reference to a compiler-generated field
                this.GameState.SaveData.ThisLevel.FilledConditions.ScriptIds.Add(cDisplayClass11.script.Id);
                this.GameState.SaveData.ThisLevel.FilledConditions.ScriptIds.Sort();
            }
            // ISSUE: reference to a compiler-generated field
            foreach (ScriptAction scriptAction in cDisplayClass11.script.Actions)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                ScriptingHost.\u003C\u003Ec__DisplayClass13 cDisplayClass13 = new ScriptingHost.\u003C\u003Ec__DisplayClass13();
                // ISSUE: reference to a compiler-generated field
                cDisplayClass13.CS\u0024\u003C\u003E8__locals12 = cDisplayClass11;
                // ISSUE: reference to a compiler-generated field
                cDisplayClass13.runnableAction = new RunnableAction()
                {
                    Action = scriptAction
                };
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated method
                cDisplayClass13.runnableAction.Invocation = new Func <object>(cDisplayClass13.\u003CProcessTrigger\u003Eb__b);
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                cDisplayClass11.activeScript.EnqueueAction(cDisplayClass13.runnableAction);
            }
            // ISSUE: reference to a compiler-generated field
            if (!cDisplayClass11.script.IgnoreEndTriggers)
            {
                // ISSUE: reference to a compiler-generated field
                foreach (ScriptTrigger scriptTrigger in cDisplayClass11.script.Triggers)
                {
                    EntityTypeDescriptor  entityTypeDescriptor  = EntityTypes.Types[scriptTrigger.Object.Type];
                    DynamicMethodDelegate dynamicMethodDelegate = entityTypeDescriptor.Events[scriptTrigger.Event].AddEndTriggerHandler;
                    if (dynamicMethodDelegate != null)
                    {
                        if (entityTypeDescriptor.Static)
                        {
                            // ISSUE: reference to a compiler-generated method
                            Action action = new Action(cDisplayClass11.\u003CProcessTrigger\u003Eb__c);
                            // ISSUE: reference to a compiler-generated field
                            object obj = dynamicMethodDelegate((object)this.services[cDisplayClass11.trigger.Object.Type], new object[1]
                            {
                                (object)action
                            });
                        }
                        else
                        {
                            // ISSUE: reference to a compiler-generated method
                            Action <int> action = new Action <int>(cDisplayClass11.\u003CProcessTrigger\u003Eb__d);
                            // ISSUE: reference to a compiler-generated field
                            object obj = dynamicMethodDelegate((object)this.services[cDisplayClass11.trigger.Object.Type], new object[1]
                            {
                                (object)action
                            });
                        }
                    }
                }
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated method
            cDisplayClass11.activeScript.Disposed += new Action(cDisplayClass11.\u003CProcessTrigger\u003Eb__e);
        }
Exemplo n.º 21
0
 private static void ProcessEndTrigger(ScriptTrigger trigger, ActiveScript script)
 {
     ScriptingHost.ProcessEndTrigger(trigger, script, new int?());
 }
	    /// <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;
			}
	    }
        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;
            }
        }