예제 #1
0
파일: Simulator.cs 프로젝트: ludidilu/orca
        public double doStepFinal()
        {
            double result = 0;

            for (int i = 0; i < agentList.Count; i++)
            {
                Agent agent = agentList[i];

                if (agent.type == (int)AgentType.GroundUnit || agent.type == AgentType.GroundJumpUnit || agent.type == AgentType.AirUnit || agent.type == AgentType.SkillUnit)
                {
                    agent.computeNeighbors();

                    agent.computeNewVelocity();
                }
            }

            List <int> delList = null;

            for (int i = 0; i < agentList.Count; i++)
            {
                Agent agent = agentList[i];

                if (agent.type == (int)AgentType.GroundUnit || agent.type == AgentType.GroundJumpUnit || agent.type == AgentType.AirUnit || agent.type == AgentType.SkillUnit)
                {
                    agent.update();

                    agent.checkPosInMapBound();

                    agent.FixPosAndVelocity();

                    result += agent.position_.x + agent.position_.y + agent.velocity_.x + agent.velocity_.y;
                }
                else if (agent.type == AgentType.SkillPush)
                {
                    if (delList == null)
                    {
                        delList = new List <int>();
                    }

                    delList.Add(agent.uid);
                }
            }

            if (delList != null)
            {
                for (int i = 0; i < delList.Count; i++)
                {
                    delAgent(delList[i]);
                }
            }

            return(result);
        }
예제 #2
0
파일: Simulator.cs 프로젝트: ludidilu/orca
        /**
         * <summary>Performs a simulation step and updates the two-dimensional
         * position and two-dimensional velocity of each agent.</summary>
         *
         * <returns>The global time after the simulation step.</returns>
         */
        public void doStep()
        {
            for (int i = 0; i < agentList.Count; i++)
            {
                Agent agent = agentList[i];

                if (agent.type == (int)AgentType.GroundUnit || agent.type == AgentType.GroundJumpUnit || agent.type == AgentType.AirUnit || agent.type == AgentType.SkillUnit)
                {
                    agent.computeNeighbors();

                    agent.computeNewVelocity();
                }
            }

            for (int i = 0; i < agentList.Count; i++)
            {
                Agent agent = agentList[i];

                if (agent.type == (int)AgentType.GroundUnit || agent.type == AgentType.GroundJumpUnit || agent.type == AgentType.AirUnit || agent.type == AgentType.SkillUnit)
                {
                    agent.update();
                }
            }
        }