Example #1
0
        public readonly UnitType unitTypeBuild; // Nullable

        #endregion Fields

        #region Constructors

        public Order(OrderType orderType, Position targetPosition=null, Unit targetUnit=null, UnitType unitTypeBuild=null)
        {
            this.orderType = orderType;
            this.targetPosition = targetPosition;
            this.targetUnit = targetUnit;
            this.unitTypeBuild = unitTypeBuild;
        }
Example #2
0
        public Unit AddUnit(UnitType unitType, Position position, Player owner)
        {
            if (!map.Inside(position)) return null;

            var newUnit = new Unit(GetNextId(), this, unitType, position, owner);
            units.Add(newUnit);
            unitQuadtrees[owner].AddUnit(newUnit);
            CacheSetUnitAt(newUnit);
            return newUnit;
        }
Example #3
0
        public Unit(int id, Engine engine, UnitType unitType, Position position, Player owner)
        {
            this.id = id;
            this.engine = engine;
            this.type = unitType;
            this.position = position;
            this.previousPosition = position;
            this.nextMove = -1;
            this.owner = owner;

            health = type.maxHealth;
            status = Status.Idle;
            orders = new List<Order>();
            modifiers = new List<UnitModifier>();

            animationStartTick = 0;
            direction = 0;

            currentPath = null;
            currentTargetPosition = null;
        }
Example #4
0
 public void OrderProduce(Unit factory, UnitType unitType, Position targetPosition = null)
 {
     factory.orders.Add(Order.CreateProduceOrder(unitType, targetPosition));
     ScheduleUpdate(1, factory);
 }
Example #5
0
 public static Order CreateProduceOrder(UnitType unitType, Position targetPosition)
 {
     Debug.Assert(unitType != null);
     return new Order(OrderType.Produce, targetPosition: targetPosition, unitTypeBuild: unitType);
 }