示例#1
0
 public virtual void DoOrders(ControlledDivision Host)
 {
     if (OngoingOrder.Canceled)
     {
         OngoingOrder.End(Host);
         TryStartNextOrder(Host);
     }
     else if (GameManager.Instance.IsPaused)
     {
         OngoingOrder.Pause(Host);
     }
     else if (OngoingOrder.GetType() != typeof(EmptyOrder))
     {
         //if we are finished stop
         if (OngoingOrder.TestIfFinished(Host))
         {
             OngoingOrder.End(Host);
             OngoingOrder = new EmptyOrder();
             Host.OnChange();
         }
         else
         {
             ContinueOrder(Host);
         }
     }
     //grab a new order
     else if (TryStartNextOrder(Host))
     {
     }
 }
示例#2
0
 /// <summary>
 /// starts a new order
 /// </summary>
 /// <param name="Host"></param>
 /// <param name="order"></param>
 protected virtual void StartOrder(ControlledDivision Host, Order order)
 {
     OngoingOrder = order;
     OngoingOrder.Start(Host);
     //DOES not use continueOrder to proceed the order, this is because sub classes of multi use the continue order to start new orders and can cause infinite recursion
     OngoingOrder.Proceed(Host);
     Host.OnChange();
     name = $"{_baseName} {OngoingOrder.name}";
 }
示例#3
0
    public virtual void DoBackgroundOrders(ControlledDivision Host)
    {
        if (GameManager.Instance.IsPaused)
        {
            BackgroundOrderList.ForEach(x => x.Pause(Host));
        }
        else
        {
            for (int i = 0; i < BackgroundOrderList.Count; i++)
            {
                var order = BackgroundOrderList[i];

                if (order.Canceled)
                {
                    order.End(Host);
                    BackgroundOrderList.RemoveAt(i);
                    i--;
                    Host.OnChange();
                }

                if (!order.HasStarted)
                {
                    order.Start(Host);
                    Host.OnChange();
                }

                order.Proceed(Host);

                if (order.TestIfFinished(Host))
                {
                    order.End(Host);
                    BackgroundOrderList.RemoveAt(i);
                    i--;
                    Host.OnChange();
                }
            }
        }
    }
示例#4
0
    public virtual Division CreateChild(List <Soldier> soldiersForChild, DivisionController newController)
    {
        newController.transform.position = this.Controller.transform.position;
        newController.transform.rotation = this.Controller.transform.rotation;

        ControlledDivision newDivision = new ControlledDivision(TeamId, newController)
        {
            Soldiers = new ObservableCollection <Soldier>(soldiersForChild)
        };

        AddSubordinate(new RememberedDivision(newDivision));
        newDivision.Commander = DivisionId;
        OnChange();
        newDivision.OnChange();
        newController.AttachedDivision = newDivision;
        return(newDivision);
    }
示例#5
0
    public virtual void ReceiveOrder(ControlledDivision Host, Order order)
    {
        if (order.IsBackgroundOrder)
        {
            //make sure theres no duplicates of this type of order
            foreach (Order backgroundOrder in BackgroundOrderList)
            {
                if (order.GetType() == backgroundOrder.GetType())
                {
                    return;
                }
            }
            var orderType = order.GetType();
            BackgroundOrderList.Add(order);
        }
        else
        {
            OrderQueue.Add(order);
        }

        Host.OnChange();
    }