Beispiel #1
0
        /// <summary>
        /// Adds a unit that doesn't need to be built as it's already ready!!
        /// </summary>
        ///<param name="a_Isunit">True if it's a unit, false if it's a building</param>
        /// <remarks>Another way around this is to add the unit to visible function and set the build timer to required timer
        /// and then it gets finished instantly</remarks>
        public void AddReadyThing(Thing a_thing, List <Vector3> a_newDestination)
        {
            //if possible to add!!
            //if (CanAddUnit(a_thing))  REASON FOR REMOVAL: If you want to add something ready, then it hsould be added no matter supply, like sacrifices e.t.c.!
            //{
            if (a_newDestination != null)
            {
                foreach (Vector3 destination in a_newDestination)
                {
                    //set destination(s)
                    a_thing.AddDestination(destination);
                }
            }

            //checks type to know which list to add it to
            if (a_thing.m_isUnit)
            {
                m_units.Add(a_thing);
            }
            else
            {
                m_buildings.Add(a_thing);
            }

            AddUnitPower(a_thing.m_type);
            AddSupply(a_thing.m_supplyValue);
            //}
        }
Beispiel #2
0
        private void DoPathfinding(Vector3 a_start, Vector3 a_destination, Thing thing, bool resetPaths)
        {
            switch (m_pathFinder.FindPath(a_start, a_destination))
            {
            //a path was found
            case 1:
                if (resetPaths)
                {
                    //clear destinations
                    //NOTE: the check is here because if no path is found, the former path shouldn't be cleared
                    thing.m_destination.Clear();
                }

                //add all destinations from the pathfinder
                for (int i = 0; i < m_pathFinder.m_pathList.Count; i++)
                {
                    thing.AddDestination(m_pathFinder.m_pathList[i]);
                }
                break;

            //no path was found
            case 2:
                break;
            }
        }
Beispiel #3
0
        public void AddSacrifice(Thing a_sacrifice)
        {
            if (!m_aspiringSacrifices.Contains(a_sacrifice) && a_sacrifice.m_type == ThingType.C_Cube)
            {
                //Pushes in the waypoint into the builder without blocked tiles problems
                a_sacrifice.AddDestination(m_builder.m_currentposition);

                //Sets the state to building so it can check the state, if for example a unit wants to move elsewhere it's automatically removed from the aspiring list!
                a_sacrifice.m_thingState = ThingState.Building;

                m_aspiringSacrifices.Add(a_sacrifice);
            }
        }