Exemple #1
0
    public void AddOrder(AgentOrder order)
    {
        Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type);
        switch (order.Type)
        {
        case AgentOrder.E_OrderType.E_STOPMOVE:
            Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
            DesiredPosition = Owner.Position;
            break;

        case AgentOrder.E_OrderType.E_GOTO:
            Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
            DesiredPosition   = order.Position;
            DesiredDirection  = order.Direction;
            MoveSpeedModifier = order.MoveSpeedModifier;
            break;

        case AgentOrder.E_OrderType.E_ATTACK:
            if (order.Target == null || (order.Target.Position - Owner.Position).magnitude <= (WeaponRange + 0.2f))
            {
                Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, true);
            }
            else
            {
                Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, false);
            }

            DesiredAttackType  = order.AttackType;
            DesiredTarget      = order.Target;
            DesiredDirection   = order.Direction;
            DesiredAttackPhase = order.AnimAttackData;
            break;

        default:
            break;
        }
        AgentOrderFactory.Return(order);
    }
Exemple #2
0
    public void OrderAdd(AgentOrder order)
    {
        //  Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);

        if (IsOrderAddPossible(order.Type))
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type);

            switch (order.Type)
            {
            case AgentOrder.E_OrderType.E_STOPMOVE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                DesiredPosition = Owner.Position;
                break;

            case AgentOrder.E_OrderType.E_GOTO:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                DesiredPosition   = order.Position;
                DesiredDirection  = order.Direction;
                MoveSpeedModifier = order.MoveSpeedModifier;
                break;

            case AgentOrder.E_OrderType.E_DODGE:
                DesiredDirection = order.Direction;
                //  Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);
                break;

            case AgentOrder.E_OrderType.E_USE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_USE_WORLD_OBJECT, true);

                if ((order.Position - Owner.Position).sqrMagnitude <= 1)
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                }
                DesiredPosition   = order.Position;
                InteractionObject = order.InteractionObject;
                Interaction       = order.Interaction;
                break;

            case AgentOrder.E_OrderType.E_ATTACK:
                if (order.Target == null || (order.Target.Position - Owner.Position).magnitude <= (WeaponRange + 0.2f))
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, false);
                }

                DesiredAttackType  = order.AttackType;
                DesiredTarget      = order.Target;
                DesiredDirection   = order.Direction;
                DesiredAttackPhase = order.AnimAttackData;
                break;
            }

            // Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);
        }
        else if (order.Type == AgentOrder.E_OrderType.E_ATTACK)
        {
            // Debug.Log(Time.timeSinceLevelLoad +  " " +order.Type + " is nto allowed because " + currentOrder);
        }
        AgentOrderFactory.Return(order);
    }