Example #1
0
        private void ApplyInput(GameState s, float dt, SetTargetEvent e)
        {
            RTSTeam        team     = s.teams[e.Team];
            List <IEntity> selected = team.Input.selected;

            if (selected != null && selected.Count > 0)
            {
                RTSSquad squad = null;
                foreach (var unit in selected)
                {
                    RTSUnit u = unit as RTSUnit;
                    if (u != null)
                    {
                        if (squad == null)
                        {
                            squad = u.Team.AddSquad();
                        }
                        if (u.ActionController != null)
                        {
                            u.ActionController.Reset();
                        }
                        squad.Add(u);
                        DevConsole.AddCommand("gc 1");
                    }
                }
                if (squad == null)
                {
                    DevConsole.AddCommand("gc return"); return;
                }
                // Assign The Target To Every Unit In The Squad
                for (int u = 0; u < squad.Units.Count; u++)
                {
                    RTSUnit unit = squad.Units[u];
                    unit.Target = e.Target;
                    DevConsole.AddCommand("gc target");
                }
                AddTask(s, squad);
                SendSquadQuery(s, squad, e);
            }
        }
 private void SelectNewTarget()
 {
     _target = _targetLocator.GetNearestTarget(_transform);
     SetTargetEvent.Invoke(_target);
 }