Пример #1
0
        private void DrawSelection()
        {
            GUI.skin = ResourceManager.SelectBoxSkin;
            Rect selectBox = WorkManager.CalculateSelectionBox(Agent.Body.GetSelectionBounds(), (Agent as RTSAgent).GetPlayerArea());

            // Draw the selection box around the currently selected object, within the bounds of the playing area
            GUI.BeginGroup((Agent as RTSAgent).GetPlayerArea());
            DrawSelectionBox(selectBox);
            GUI.EndGroup();
        }
Пример #2
0
        private void DrawBuildProgress()
        {
            GUI.skin = ResourceManager.SelectBoxSkin;
            Rect selectBox = WorkManager.CalculateSelectionBox(Agent.Body.GetSelectionBounds(), (Agent as RTSAgent).GetPlayerArea());

            //Draw the selection box around the currently selected object, within the bounds of the main draw area
            GUI.BeginGroup((Agent as RTSAgent).GetPlayerArea());
            CalculateCurrentHealth(0.5f, 0.99f);
            DrawHealthBar(selectBox, "Building ...");
            GUI.EndGroup();
        }
Пример #3
0
        protected override void HandleLoadedProperty(JsonTextReader reader, string propertyName, object readValue)
        {
            base.HandleLoadedProperty(reader, propertyName, readValue);
            switch (propertyName)
            {
            case "Harvesting":
                IsHarvesting = (bool)readValue;
                break;

            case "HarvestMoving":
                IsHarvestMoving = (bool)readValue;
                break;

            case "Emptying":
                IsEmptying = (bool)readValue;
                break;

            case "CurrentLoad":
                currentLoadAmount = (long)readValue;
                break;

            case "CurrentDeposit":
                currentDepositAmount = (long)readValue;
                break;

            case "HarvestType":
                HarvestType = WorkManager.GetResourceType((string)readValue);
                break;

            case "ResourceDepositId":
                loadedDepositId = (int)(System.Int64)readValue;
                break;

            case "Focused":
                IsFocused = (bool)readValue;
                break;

            case "InRange":
                inRange = (bool)readValue;
                break;

            case "HarvestCount":
                harvestCount = (long)readValue;
                break;

            case "FastRangeToTarget":
                fastRangeToTarget = (long)readValue;
                break;

            default:
                break;
            }
        }
        private void DrawBuildProgress()
        {
            GUI.skin = GameResourceManager.SelectBoxSkin;
            Bounds selectionBounds = WorkManager.CalculateBounds(Agent.gameObject, Agent.Body._position.ToVector3());
            Rect   selectBox       = WorkManager.CalculateSelectionBox(selectionBounds, Agent.GetPlayerArea());

            //Draw the selection box around the currently selected object, within the bounds of the main draw area
            GUI.BeginGroup(Agent.GetPlayerArea());
            CalculateCurrentHealth(0.5f, 0.99f);
            DrawHealthBar(selectBox, "Constructing...");
            GUI.EndGroup();
        }
        private void DrawSelection()
        {
            GUI.skin = GameResourceManager.SelectBoxSkin;

            Bounds selectionBounds = WorkManager.CalculateBounds(Agent.gameObject, Agent.Body._position.ToVector3());
            Rect   selectBox       = WorkManager.CalculateSelectionBox(selectionBounds, Agent.GetPlayerArea());

            // Draw the selection box around the currently selected object, within the bounds of the playing area
            GUI.BeginGroup(Agent.GetPlayerArea());
            DrawSelectionBox(selectBox);
            GUI.EndGroup();
        }
Пример #6
0
        private RTSAgent ClosestResourceStore(string resourceStoreName)
        {
            //change list to fastarray
            List <RTSAgent> playerBuildings = new List <RTSAgent>();

            // use RTS influencer?
            foreach (RTSAgent child in Agent.Controller.Commander.GetComponentInChildren <RTSAgents>().GetComponentsInChildren <RTSAgent>())
            {
                if (child.objectName == resourceStoreName)
                {
                    playerBuildings.Add(child);
                }
            }
            RTSAgent nearestObject = WorkManager.FindNearestWorldObjectInListToPosition(playerBuildings, transform.position) as RTSAgent;

            return(nearestObject);
        }
Пример #7
0
        protected override void HandleLoadedProperty(JsonTextReader reader, string propertyName, object readValue)
        {
            base.HandleLoadedProperty(reader, propertyName, readValue);
            switch (propertyName)
            {
            case "SpawnPoint":
                spawnPoint = LoadManager.LoadVector(reader);
                break;

            case "RallyPoint":
                rallyPoint = LoadManager.LoadVector(reader);
                break;

            case "FlagState":
                _flagState = WorkManager.GetFlagState((string)readValue);
                break;

            default: break;
            }
        }
Пример #8
0
        /*
         * A child class should only determine other conditions under which a decision should
         * not be made. This could be 'harvesting' for a harvester, for example. Alternatively,
         * an object that never has to make decisions could just return false.
         */

        protected void GetNearbyObject()
        {
            Vector3 currentPosition = transform.position;

            nearbyObjects = WorkManager.FindNearbyObjects(currentPosition, cachedAttack.Range);
        }
Пример #9
0
 public override void DecideWhatToDo()
 {
     base.DecideWhatToDo();
     if (Agent.Tag == AgentTag.Harvester && cachedHarvest.IsFocused)
     {
         //convert to fast list...
         List <RTSAgent> resources = new List <RTSAgent>();
         foreach (RTSAgent nearbyObject in nearbyObjects)
         {
             ResourceDeposit resource = nearbyObject.GetAbility <ResourceDeposit>();
             if (resource && !resource.IsEmpty())
             {
                 resources.Add(nearbyObject);
             }
         }
         RTSAgent nearestObject = WorkManager.FindNearestWorldObjectInListToPosition(resources, transform.position);
         if (nearestObject)
         {
             ResourceDeposit closestResource = nearestObject.GetAbility <ResourceDeposit>();
             // only harvest resources the worker is assigned to
             if (closestResource && closestResource.ResourceType == cachedHarvest.HarvestType)
             {
                 // send harvest command
                 Command harvestCom = new Command(AbilityDataItem.FindInterfacer("Harvest").ListenInputID);
                 harvestCom.Add <DefaultData>(new DefaultData(DataType.UShort, nearestObject.GlobalID));
                 UserInputHelper.SendCommand(harvestCom);
             }
         }
     }
     if (Agent.Tag == AgentTag.Builder && cachedBuild.IsFocused)
     {
         //convert to fast array
         List <RTSAgent> buildings = new List <RTSAgent>();
         foreach (RTSAgent nearbyObject in nearbyObjects)
         {
             if (nearbyObject.GetCommander() != Agent.Controller.Commander)
             {
                 continue;
             }
             RTSAgent nearbyBuilding = nearbyObject.GetComponent <RTSAgent>();
             if (nearbyBuilding && nearbyBuilding.GetAbility <Structure>().UnderConstruction())
             {
                 buildings.Add(nearbyObject);
             }
         }
         RTSAgent nearestObject = WorkManager.FindNearestWorldObjectInListToPosition(buildings, transform.position);
         if (nearestObject)
         {
             RTSAgent closestBuilding = nearestObject.GetComponent <RTSAgent>();
             if (closestBuilding)
             {
                 // send build command
                 Command buildCom = new Command(AbilityDataItem.FindInterfacer("Construct").ListenInputID);
                 buildCom.Add <DefaultData>(new DefaultData(DataType.UShort, closestBuilding.GlobalID));
                 UserInputHelper.SendCommand(buildCom);
             }
         }
         else
         {
             cachedBuild.SetCurrentProject(null);
         }
     }
 }