Exemplo n.º 1
0
    public void CreateOrderUse()
    {
        if (Agent.BlackBoard.IsOrderAddPossible(AgentOrder.E_OrderType.E_USE) == false)
        {
            return;
        }

        InteractionGameObject onObject = MissionZone.Instance.CurrentGameZone.GetNearestInteractionObject(Agent.Position, 2);

        if (onObject == null)
        {
            return;
        }

        if (onObject is InteractionLever)
        {
            InteractionLever lever = onObject as InteractionLever;
            if (lever.State != InteractionLever.E_State.E_OFF && lever.State != InteractionLever.E_State.E_OFF)
            {
                return;
            }

            AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_USE);
            order.InteractionObject = onObject;
            order.Position          = order.InteractionObject.GetEntryTransform().position;
            order.Interaction       = E_InteractionType.On;
            Agent.BlackBoard.AddOrder(order);

            return;
        }

        ComboProgress.Clear();
        ClearBufferedOrder();
        //GuiManager.Instance.ShowComboProgress(ComboProgress);
    }
Exemplo n.º 2
0
    public void Reset()
    {
        m_ActiveActions.Clear();

        Stop           = false;
        MotionType     = E_MotionType.None;
        WeaponState    = E_WeaponState.NotInHands;
        WeaponToSelect = E_WeaponType.None;

        Speed = 0;

        Health = RealMaxHealth;

        Rage      = RageMin;
        Dodge     = DodgeMin;
        Fear      = FearMin;
        IdleTimer = 0;

        MoveDir = Vector3.zero;

        DesiredPosition  = Vector3.zero;
        DesiredDirection = Vector3.zero;

        InteractionObject = null;
        Interaction       = E_InteractionType.None;

        DesiredAnimation = "";

        DesiredTarget     = null;
        DesiredAttackType = E_AttackType.None;

        DontUpdate = false;
    }
Exemplo n.º 3
0
    public void EnableAllActiveInteraction(bool enable)
    {
        for (int i = InteractionObjects.Length - 1; i >= 0; i--)
        {
            InteractionGameObject o = InteractionObjects[i];
            if (o.IsActive == false)
            {
                continue;
            }

            o.Enable(enable);
        }
    }
Exemplo n.º 4
0
    public override bool IsInteractionObjectInRange(Vector3 center, float maxLen)
    {
        float nearestLen = maxLen * maxLen;

        for (int i = InteractionObjects.Length - 1; i >= 0; i--)
        {
            InteractionGameObject o = InteractionObjects[i];
            if (o.IsActive == false || o.IsEnabled == false || (o is InteractionLever) == false)
            {
                continue;
            }

            if ((o.Position - center).sqrMagnitude < nearestLen)
            {
                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 获取最近操作杆
    /// </summary>
    /// <param name="center"></param>
    /// <param name="maxLen"></param>
    /// <returns></returns>
    public override InteractionGameObject GetNearestInteractionObject(Vector3 center, float maxLen)
    {
        float len;
        float nearestLen           = maxLen * maxLen;
        InteractionGameObject best = null;

        for (int i = 0; i < InteractionObjects.Length; i++)
        {
            InteractionGameObject igo = InteractionObjects [i];
            if (igo.IsActive == false || igo.IsEnabled == false || (igo is InteractionLever) == false)
            {
                continue;
            }

            len = (igo.Position - center).sqrMagnitude;
            if (len < nearestLen)
            {
                nearestLen = len;
                best       = igo;
            }
        }
        return(best);
    }
Exemplo n.º 6
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;
                //Debug.Log("DesiredPosition="+ DesiredPosition);
                //float van = Mathf.Atan2(2, 5);
                CameraDirection.y = 0;
                Quaternion q = Quaternion.FromToRotation(Vector3.forward, CameraDirection);
                DesiredDirection = q * order.Direction;
                Debug.Log("DesiredDirection=" + DesiredDirection);
                MoveSpeedModifier = order.MoveSpeedModifier;
                break;

            case AgentOrder.E_OrderType.E_DODGE:
                Quaternion qq = Quaternion.FromToRotation(Vector3.forward, CameraDirection);
                DesiredDirection = qq * 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;
                Quaternion qqq = Quaternion.FromToRotation(Vector3.forward, CameraDirection);
                DesiredDirection   = qqq * order.Direction;
                DesiredAttackPhase = order.AnimAttackData;
                break;
            }

            //  Debug.Log(Time.timeSinceLevelLoad + " new 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);
    }
Exemplo n.º 7
0
    public void AddOrder(AgentOrder order)
    {
        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;
                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;
            }
        }
        else if (order.Type == AgentOrder.E_OrderType.E_ATTACK)
        {
        }

        AgentOrderFactory.Return(order);
    }