Beispiel #1
0
        public void SetConstructQueue()
        {
            while (ConstructQueue.Count > 0)
            {
                QStructure qStructure = ConstructQueue.Dequeue();
                if (qStructure.IsNotNull())
                {
                    RTSAgent  newRTSAgent  = Agent.Controller.CreateAgent(qStructure.StructureName, qStructure.BuildPoint, qStructure.RotationPoint) as RTSAgent;
                    Structure newStructure = newRTSAgent.GetAbility <Structure>();

                    if (newStructure.StructureType == StructureType.Wall)
                    {
                        newRTSAgent.transform.localScale = qStructure.LocalScale.ToVector3();
                        newStructure.IsOverlay           = true;
                    }

                    newRTSAgent.Body.HalfWidth  = qStructure.HalfWidth;
                    newRTSAgent.Body.HalfLength = qStructure.HalfLength;

                    newStructure.BuildSizeLow  = (newRTSAgent.Body.HalfWidth.CeilToInt() * 2);
                    newStructure.BuildSizeHigh = (newRTSAgent.Body.HalfLength.CeilToInt() * 2);

                    if (GridBuilder.Place(newRTSAgent.GetAbility <Structure>(), newRTSAgent.Body._position))
                    {
                        Agent.GetCommander().CachedResourceManager.RemoveResources(newRTSAgent);

                        newRTSAgent.SetPlayingArea(Agent.GetPlayerArea());
                        newRTSAgent.SetCommander(Agent.GetCommander());

                        newRTSAgent.gameObject.name  = newRTSAgent.objectName;
                        newRTSAgent.transform.parent = newStructure.StructureType == StructureType.Wall ? WallPositioningHelper.OrganizerWalls.transform
                            : ConstructionHandler.OrganizerStructures.transform;

                        newStructure.AwaitConstruction();
                        // Set to transparent material until constructor is in range to start
                        ConstructionHandler.SetTransparentMaterial(newStructure.gameObject, GameResourceManager.AllowedMaterial, true);

                        if (CurrentProject.IsNull())
                        {
                            CurrentProject = newRTSAgent;
                            StartConstructMove();
                        }
                    }
                    else
                    {
                        Debug.Log("Couldn't place building!");
                        newRTSAgent.Die();
                    }
                }
            }
        }
Beispiel #2
0
 public QueueStructure(QStructure newStructure)
 {
     Value = newStructure;
 }