コード例 #1
0
 internal static void LateVisualize()
 {
     DefaultMessageRaiser.LateVisualize();
     AgentController.LateVisualize();
     PhysicsManager.LateVisualize();
     BehaviourHelperManager.LateVisualize();
 }
コード例 #2
0
        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);
        }
コード例 #4
0
 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();
            }
        }
コード例 #7
0
 internal static void Visualize()
 {
     if (!GameStarted)
     {
         return;
     }
     DefaultMessageRaiser.EarlyVisualize();
     PlayerManager.Visualize();
     BehaviourHelperManager.Visualize();
     AgentController.Visualize();
     ProjectileManager.Visualize();
     EffectManager.Visualize();
     CommandManager.Visualize();
     PhysicsManager.Visualize();
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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++;
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 //Called on the first frame of the game
 private static void GameStart()
 {
     BehaviourHelperManager.GameStart();
     GameStarted = true;
 }