コード例 #1
0
ファイル: Attack.cs プロジェクト: forestrf/LockstepRTSEngine
        protected override void OnExecute(Command com)
        {
            Vector2d    pos;
            DefaultData target;

            if (com.TryGetData <Vector2d>(out pos) && CanMove)
            {
                StartAttackMove(pos);
            }
            else if (com.TryGetData <DefaultData>(out target) && target.Is(DataType.UShort))
            {
                isFocused      = true;
                IsAttackMoving = false;
                LSAgent tempTarget;
                ushort  targetValue = (ushort)target.Value;
                if (AgentController.TryGetAgentInstance(targetValue, out tempTarget))
                {
                    Engage(tempTarget);
                }
                else
                {
                    Debug.Log("nope");
                }
            }
        }
コード例 #2
0
ファイル: Harvest.cs プロジェクト: forestrf/LockstepRTSEngine
        protected override void OnExecute(Command com)
        {
            DefaultData target;

            if (com.TryGetData <DefaultData>(out target) && target.Is(DataType.UShort))
            {
                IsFocused       = true;
                IsHarvestMoving = false;
                LSAgent tempTarget;
                ushort  targetValue = (ushort)target.Value;
                if (AgentController.TryGetAgentInstance(targetValue, out tempTarget))
                {
                    if (tempTarget)
                    {
                        if (tempTarget.MyAgentType == AgentType.Resource && !tempTarget.GetAbility <ResourceDeposit>().IsEmpty())
                        {
                            StartHarvest(tempTarget as RTSAgent);
                        }
                        else if (tempTarget.MyAgentType == AgentType.Building && (tempTarget as RTSAgent).objectName == ResourceStoreName && currentLoadAmount > 0)
                        {
                            StartDeposit(tempTarget as RTSAgent);
                        }
                    }
                    else
                    {
                        StopHarvesting();
                    }
                }
                else
                {
                    Debug.Log("nope");
                }
            }
        }
コード例 #3
0
        protected override void OnExecute(Command com)
        {
            //first check if queue command
            QueueStructure qStructure;

            if (com.TryGetData(out qStructure))
            {
                ConstructQueue.Enqueue(qStructure.Value);
            }
            else
            {
                DefaultData target;
                if (com.TryGetData(out target))
                {
                    IsFocused     = true;
                    IsBuildMoving = false;
                    Agent.Tag     = AgentTag.Builder;

                    // construction hasn't started yet, only a bool given
                    if (target.Is(DataType.Bool) && ConstructQueue.Count > 0)
                    {
                        if ((bool)target.Value)
                        {
                            SetConstructQueue();
                        }
                        else
                        {
                            ConstructQueue.Clear();
                        }
                    }
                    // otherwise this is another agent coming to help
                    // should have been sent local id of target
                    else if (target.Is(DataType.UShort))
                    {
                        RTSAgent tempTarget;
                        ushort   targetValue = (ushort)target.Value;
                        if (AgentController.TryGetAgentInstance(targetValue, out tempTarget))
                        {
                            RTSAgent building = tempTarget;
                            if (building && building.GetAbility <Structure>().NeedsConstruction)
                            {
                                CurrentProject = building;
                                StartConstructMove();
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        protected override void OnExecute(Command com)
        {
            DefaultData target;

            if (com.TryGetData <DefaultData>(out target) && target.Is(DataType.UShort))
            {
                IsFocused     = true;
                IsBuildMoving = false;
                LSAgent tempTarget;
                ushort  targetValue = (ushort)target.Value;
                if (AgentController.TryGetAgentInstance(targetValue, out tempTarget))
                {
                    RTSAgent building = (RTSAgent)tempTarget;
                    if (building && building.GetAbility <Structure>().UnderConstruction())
                    {
                        SetBuilding(building);
                    }
                }
                else
                {
                    Debug.Log("nope");
                }
            }
        }