예제 #1
0
 public void Refresh(RTSRenderer renderer)
 {
     if (refreshFOW)
     {
         refreshFOW = false;
         RenderMap(renderer);
     }
     tbScanner.DoTasks(1f);
     RenderEntities();
 }
예제 #2
0
        // Logic Stage
        private void ApplyLogic(GameState s, float dt)
        {
            RTSTeam team = null;

            // Apply Dev Commands
            int c = commands.Count;

            for (int i = 0; i < c; i++)
            {
                var comm = commands.Dequeue();
                switch (comm.Type)
                {
                case DevCommandType.Spawn:
                    ApplyLogic(s, dt, comm as DevCommandSpawn);
                    break;

                case DevCommandType.StopMotion:
                    ApplyLogic(s, dt, comm as DevCommandStopMotion);
                    break;

                case DevCommandType.KillUnits:
                    ApplyLogic(s, dt, comm as DevCommandKillUnits);
                    break;

                case DevCommandType.KillBuildings:
                    ApplyLogic(s, dt, comm as DevCommandKillBuildings);
                    break;

                case DevCommandType.FOW:
                    ApplyLogic(s, dt, comm as DevCommandFOW);
                    break;

                case DevCommandType.Save:
                    ApplyLogic(s, dt, comm as DevCommandSave);
                    break;

                case DevCommandType.Capital:
                    ApplyLogic(s, dt, comm as DevCommandCapital);
                    break;
                }
            }

            // Find Decisions For Currently Budgeted Tasks
            tbSquadDecisions.DoTasks(dt);
            tbEntityDecisions.DoTasks(dt);

            // Apply Decisions For Squads
            for (int ti = 0; ti < s.activeTeams.Length; ti++)
            {
                team = s.activeTeams[ti].Team;
                for (int i = 0; i < team.Squads.Count; i++)
                {
                    if (team.Squads[i].ActionController != null)
                    {
                        team.Squads[i].ActionController.ApplyAction(s, dt);
                    }
                }
            }
            // Apply Decisions For Units And Buildings
            for (int ti = 0; ti < s.activeTeams.Length; ti++)
            {
                team = s.activeTeams[ti].Team;
                for (int i = 0; i < team.Units.Count; i++)
                {
                    if (team.Units[i].ActionController != null)
                    {
                        team.Units[i].ActionController.ApplyAction(s, dt);
                    }
                }
                for (int i = 0; i < team.Buildings.Count; i++)
                {
                    if (team.Buildings[i].ActionController != null)
                    {
                        team.Buildings[i].ActionController.ApplyAction(s, dt);
                    }
                }
            }

            // Calculate FOW
            tbFOWCalculations.DoTasks(dt);

            // Calculate Memorizations
            if (s.CurrentFrame % GameState.BUILDING_MEMORIZATION_LATENCY == 0)
            {
                s.tbMemBuildings.ResortBins();
            }
            s.tbMemBuildings.DoTasks(dt);
        }