internal static void LateVisualize()
 {
     DefaultMessageRaiser.LateVisualize();
     AgentController.LateVisualize();
     PhysicsManager.LateVisualize();
     BehaviourHelperManager.LateVisualize();
 }
        public void Execute(Command com)
        {
            if (com.ContainsData <Selection>())
            {
                previousSelection = com.GetData <Selection>();
            }

            BehaviourHelperManager.Execute(com);
            Selection selection = GetSelection(com);
            Influence influence = GetInfluencedAgent(com);

            // check if command is an influence from AI
            if (influence.IsNotNull())
            {
                ushort influencedAgentID = influence.InfluencedAgentLocalID;
                if (LocalAgentActive[influencedAgentID])
                {
                    var agent = LocalAgents[influencedAgentID];
                    agent.Execute(com);
                }
            }
            // otherwise it's an input command
            else if (selection != null && selection.selectedAgentLocalIDs.Count > 0)
            {
                for (int i = 0; i < selection.selectedAgentLocalIDs.Count; i++)
                {
                    ushort selectedAgentID = selection.selectedAgentLocalIDs[i];
                    if (LocalAgentActive[selectedAgentID])
                    {
                        var agent = LocalAgents[selectedAgentID];
                        agent.Execute(com);
                    }
                }
            }
        }
示例#3
0
        public void Execute(Command com)
        {
            if (com.ContainsData <Selection>())
            {
                previousSelection = com.GetData <Selection>();
            }

            BehaviourHelperManager.Execute(com);
            Selection selection = GetSelection(com);

            for (int i = 0; i < selection.selectedAgentLocalIDs.Count; i++)
            {
                ushort selectedAgentID = selection.selectedAgentLocalIDs[i];
                if (LocalAgentActive[selectedAgentID])
                {
                    var agent = LocalAgents[selectedAgentID];
                    ////Prevent executing twice on commander
                    //if (Commander.IsNull() || agent != Commander.Agent) {
                    agent.Execute(com);
                    //}
                }
            }
            //if (Commander.IsNotNull())
            //Commander.Agent.Execute (com);
        }
 private static void LateSimulate()
 {
     BehaviourHelperManager.LateSimulate();
     AgentController.LateSimulate();
     PhysicsManager.LateSimulate();
     DefaultMessageRaiser.LateSimulate();
 }
示例#5
0
        internal static void Deactivate()
        {
            DefaultMessageRaiser.EarlyDeactivate();

            if (GameStarted == false)
            {
                return;
            }

            Selector.Clear();
            AgentController.Deactivate();
            BehaviourHelperManager.Deactivate();
            ProjectileManager.Deactivate();
            EffectManager.Deactivate();
            ClientManager.Deactivate();

            ClientManager.Quit();
            PhysicsManager.Deactivate();
            GameStarted = false;
            LSServer.Deactivate();
            DefaultMessageRaiser.LateDeactivate();
            CoroutineManager.Deactivate();

            DefaultMessageRaiser.Reset();
        }
示例#6
0
        internal static void Initialize(ILockstepEventsHandler[] helpers, NetworkHelper networkHelper)
        {
            PlayRate = FixedMath.One;
            //PauseCount = 0;

            if (!Loaded)
            {
                Setup();
                Loaded = true;
            }

            DefaultMessageRaiser.EarlyInitialize();

            LSDatabaseManager.Initialize();
            LSUtility.Initialize(1);
            InfluenceCount = 0;
            Time.timeScale = 1f;

            Stalled = true;

            FrameCount          = 0;
            InfluenceFrameCount = 0;
            MainNetworkHelper   = networkHelper;

            AgentController.Initialize();

            ClientManager.Initialize(MainNetworkHelper);

            BehaviourHelperManager.Initialize(helpers);

            GridManager.Initialize();

            CoroutineManager.Initialize();
            FrameManager.Initialize();

            CommandManager.Initialize();


            PhysicsManager.Initialize();
            PlayerManager.Initialize();

            //   GridBuilder.Initialize();

            //Initialized in UserInputHelper
            //	SelectionManager.Initialize ();
            InfluenceManager.Initialize();
            ProjectileManager.Initialize();

            DefaultMessageRaiser.LateInitialize();
            BehaviourHelperManager.LateInitialize();
            if (onInitialize != null)
            {
                onInitialize();
            }
        }
 internal static void Visualize()
 {
     if (!GameStarted)
     {
         return;
     }
     DefaultMessageRaiser.EarlyVisualize();
     PlayerManager.Visualize();
     BehaviourHelperManager.Visualize();
     AgentController.Visualize();
     ProjectileManager.Visualize();
     EffectManager.Visualize();
     CommandManager.Visualize();
     PhysicsManager.Visualize();
 }
        internal static void Execute(Command com)
        {
            if (!GameStarted)
            {
                Debug.LogError("BOOM");
                return;
            }
            if (com.ControllerID != byte.MaxValue)
            {
                AgentController cont = AgentController.InstanceManagers [com.ControllerID];
                cont.Execute(com);
            }
            else
            {
                BehaviourHelperManager.Execute(com);
            }

            DefaultMessageRaiser.Execute(com);
        }
        internal static void Simulate()
        {
            MainNetworkHelper.Simulate();
            DefaultMessageRaiser.EarlySimulate();
            if (InfluenceCount == 0)
            {
                InfluenceSimulate();
                InfluenceCount = InfluenceResolution - 1;
                if (FrameManager.CanAdvanceFrame == false)
                {
                    Stalled = true;
                    return;
                }
                Stalled = false;

                FrameManager.Simulate();
                InfluenceFrameCount++;
            }
            else
            {
                InfluenceCount--;
            }
            if (Stalled || IsPaused)
            {
                return;
            }

            if (FrameCount == 0)
            {
                GameStart();
            }
            BehaviourHelperManager.Simulate();
            AgentController.Simulate();
            PhysicsManager.Simulate();
            CoroutineManager.Simulate();
            InfluenceManager.Simulate();
            ProjectileManager.Simulate();

            LateSimulate();
            FrameCount++;
        }
        public void CreateCommander()
        {
            if (Commander != null)
            {
                Debug.LogError("A commander called '" + Commander.gameObject.name + "' already exists for '" + this.ToString() + "'.");
            }
            if (!UnityEngine.Object.FindObjectOfType <RTSGameManager>())
            {
                Debug.LogError("A game manager has not been initialized!");
            }

            //load from ls db
            GameObject commanderObject = GameObject.Instantiate(GameResourceManager.GetCommanderObject(), UnityEngine.Object.FindObjectOfType <RTSGameManager>().GetComponentInChildren <AgentCommanders>().transform);

            commanderObject.name = this.ControllerName;

            AgentCommander commanderClone = commanderObject.GetComponent <AgentCommander>();

            //change to user's selected username
            commanderClone.username = this.ControllerName;
            commanderClone.SetController(this);

            if (PlayerManager.ContainsController(this))
            {
                commanderClone.human = true;
            }

            //come up with better way to set selected commander to the current commander
            if (this == PlayerManager.MainController)
            {
                PlayerManager.SelectPlayer(commanderClone.username, 0, this.ControllerID, this.PlayerIndex);
            }

            _commander = commanderClone;
            BehaviourHelperManager.InitializeOnDemand(_commander);
        }
 //Called on the first frame of the game
 private static void GameStart()
 {
     BehaviourHelperManager.GameStart();
     GameStarted = true;
 }