Esempio n. 1
0
        public override void Awake()
        {
            base.Awake();
            this.PlayerEnteredRange.Action = delegate()
            {
                Phone phone = PlayerDataFactory.Instance.Get <Phone>();

                if (!string.IsNullOrEmpty(this.Initial))
                {
                    DialogueForest      forest = WorldFactory.Instance.Get <World>().DialogueForest;
                    DialogueForest.Node n      = forest.GetByName(this.Initial);
                    if (n == null)
                    {
                        Log.d(string.Format("Could not find dialogue node {0}", this.Initial));
                    }
                    else
                    {
                        if (n.type == DialogueForest.Node.Type.Choice)
                        {
                            throw new Exception("Cannot start dialogue tree with a choice");
                        }
                        phone.Execute(n);
                    }

                    if (phone.Schedules.Length > 0)                     // We sent a message. That means this signal tower cannot execute again.
                    {
                        this.Initial.Value = null;
                    }

                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_SIGNAL_TOWER_ACTIVATE, this.Entity);
                }

                PlayerFactory.Instance.Get <Player>().SignalTower.Value = this.Entity;
            };

            this.PlayerExitedRange.Action = delegate()
            {
                Phone phone = PlayerDataFactory.Instance.Get <Phone>();

                if (!string.IsNullOrEmpty(this.Initial))                 // The player did not interact.
                {
                    phone.ActiveAnswers.Clear();
                }

                if (PlayerFactory.Instance != null)
                {
                    PlayerFactory.Instance.Get <Player>().SignalTower.Value = null;
                }
            };

            if (!this.main.EditorEnabled)
            {
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_SIGNAL_TOWER_LOOP, this.Entity);
            }

            SignalTower.All.Add(this);
        }
Esempio n. 2
0
        public static void Run(Entity script)
        {
            Property <string> lastNode = property <string>(script, "LastNode");
            Property <string> nextNode = property <string>(script, "NextNode");

            Phone phone = PlayerDataFactory.Instance.Get <Phone>();

            script.Add(new CommandBinding(phone.OnVisit(lastNode), new Command
            {
                Action = delegate()
                {
                    DialogueForest forest = WorldFactory.Instance.Get <World>().DialogueForest;
                    DialogueForest.Node n = forest.GetByName(nextNode);
                    phone.Execute(n);
                }
            }));
        }