Esempio n. 1
0
 public override void Activate()
 {
     base.Activate();
     Action          = AgentActionFactory.Create(AgentActionFactory.E_Type.E_Move) as AgentActionMove;
     Action.MoveType = AgentActionMove.E_MoveType.E_MT_Forward;
     Owner.BlackBoard.AddAction(Action);
 }
Esempio n. 2
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionMove;

        PlayMoveAnim(true);

        if (Owner.BlackBoard.AimAnimationsEnabled)
        {
            AnimNameUp   = Owner.AnimSet.GetAimAnim(E_AimDirection.Up, E_CoverPose.None, E_CoverDirection.Unknown);
            AnimNameDown = Owner.AnimSet.GetAimAnim(E_AimDirection.Down, E_CoverPose.None, E_CoverDirection.Unknown);

            Animation[AnimNameUp].wrapMode   = WrapMode.ClampForever;
            Animation[AnimNameDown].wrapMode = WrapMode.ClampForever;

            Animation[AnimNameUp].blendMode = AnimationBlendMode.Additive;
            Animation[AnimNameUp].layer     = 1;

            Animation[AnimNameDown].blendMode = AnimationBlendMode.Additive;
            Animation[AnimNameDown].layer     = 1;

            UpdateBlendValues();

            Animation[AnimNameUp].time   = 0.0333f;
            Animation[AnimNameDown].time = 0.0333f;

            Animation[AnimNameUp].weight   = BlendUp;
            Animation[AnimNameDown].weight = BlendDown;

            Animation.Blend(AnimNameUp, BlendUp, 0);
            Animation.Blend(AnimNameDown, BlendDown, 0);
        }
    }
Esempio n. 3
0
    public override void OnDeactivate()
    {
        //THROW_RUN, THROW_RUN_2
        if (Owner.BlackBoard.KeepMotion == false)         //beny: due to 'UseItem while Move' feature
        {
            Owner.BlackBoard.MotionType = E_MotionType.None;
            Owner.BlackBoard.MoveDir    = Vector3.zero;
            Owner.BlackBoard.Speed      = 0;
        }

        Action.SetSuccess();
        Action = null;

        if (Owner.BlackBoard.AimAnimationsEnabled)
        {
            Animation[AnimNameUp].weight   = 0;
            Animation[AnimNameDown].weight = 0;

            Animation.Stop(AnimNameUp);
            Animation.Stop(AnimNameDown);
        }

        TimeToFinishWeaponAction = 0;

        base.OnDeactivate();
        // Time.timeScale = 1;
    }
Esempio n. 4
0
    public override void Activate()
    {
        base.Activate();

        ActionMove = AgentActionFactory.Create(AgentActionFactory.E_Type.Move) as AgentActionMove;
        Owner.BlackBoard.ActionAdd(ActionMove);
    }
Esempio n. 5
0
    public override void Activate()
    {
        base.Activate();

        Action          = AgentActionFactory.Create(AgentActionFactory.E_Type.E_MOVE) as AgentActionMove;
        Action.MoveType = AgentActionMove.E_MoveType.E_MT_FORWARD;
        Owner.BlackBoard.ActionAdd(Action);
    }
Esempio n. 6
0
 protected override void Initialize(AgentAction _action)
 {
     base.Initialize(_action);
     Action        = _action as AgentActionMove;
     StartRotation = Owner.Transform.rotation;
     FinalRotation.SetLookRotation(Owner.BlackBoard.DesiredDirection);
     RotationProgress = 0;
 }
Esempio n. 7
0
 public override void OnDeactivate()
 {
     if (null != Action)
     {
         Action.SetSuccess();
         Action = null;
     }
     Owner.BlackBoard.Speed = 0;
     base.OnDeactivate();
 }
Esempio n. 8
0
    public override void Deactivate()
    {
        base.Deactivate();

        Owner.WorldState.SetWSProperty(E_PropKey.AtTargetPos, true);
        AgentActionIdle a = AgentActionFactory.Create(AgentActionFactory.E_Type.Idle) as AgentActionIdle;

        Owner.BlackBoard.ActionAdd(a);

        ActionMove = null;
    }
Esempio n. 9
0
 public override void OnDeactivate()
 {
     Debug.Log("AgentActionMove Is OnDeactivate");
     Owner.BlackBoard.MotionType = E_MotionType.None;
     if (null != Action)
     {
         Action.SetSuccess();
         Action = null;
     }
     Owner.BlackBoard.Speed = 0;
     base.OnDeactivate();
 }
Esempio n. 10
0
    protected override void Initialize(AgentAction action)
    {
        // Debug.Log("move");
        base.Initialize(action);
        AgentActionMove moveAction = Owner.BlackBoard.curAction as AgentActionMove;

        Owner.BlackBoard.desiredDirection = moveAction.moveDir;
        finalRotation.SetLookRotation(Owner.BlackBoard.desiredDirection);
        startRotation = Owner.Transform.rotation;
        Owner.BlackBoard.motionType = GetMoveMotionType();
        rotationProgress            = 0;
    }
Esempio n. 11
0
    override public void OnDeactivate()
    {
        if (Action != null)
        {
            Action.SetSuccess();
            Action = null;
        }

        Owner.BlackBoard.Speed = 0;

        base.OnDeactivate();

        // Time.timeScale = 1;
    }
Esempio n. 12
0
 public override void Update()
 {
     if (WorldEffects.GetWSProperty(E_PropKey.E_AT_TARGET_POS).GetBool() == true)
     {
         Action          = AgentActionFactory.Create(AgentActionFactory.E_Type.E_Move) as AgentActionMove;
         Action.MoveType = AgentActionMove.E_MoveType.E_MT_Forward;
         Owner.BlackBoard.AddAction(Action);
     }
     else
     {
         AgentActionIdle a = AgentActionFactory.Create(AgentActionFactory.E_Type.E_Idle) as AgentActionIdle;
         Owner.BlackBoard.AddAction(a);
     }
 }
Esempio n. 13
0
 public override void Update()
 {
     if (WorldEffects.GetWSProperty(E_PropKey.E_AT_TARGET_POS).GetBool() == true)
     {
         Action          = AgentActionFactory.Create(AgentActionFactory.E_Type.E_MOVE) as AgentActionMove;
         Action.MoveType = AgentActionMove.E_MoveType.E_MT_FORWARD;
         Owner.BlackBoard.AddAction(Action);
     }
     else
     {
         //  Debug.Log("CreateOrderStop");
         AgentActionIdle a = AgentActionFactory.Create(AgentActionFactory.E_Type.E_IDLE) as AgentActionIdle;
         Owner.BlackBoard.AddAction(a);
     }
 }
Esempio n. 14
0
    public override void Reset()
    {
        if (Owner.BlackBoard.AimAnimationsEnabled)
        {
            Animation[AnimNameUp].weight   = 0;
            Animation[AnimNameDown].weight = 0;

            Animation.Stop(AnimNameUp);
            Animation.Stop(AnimNameDown);
        }
        Action.SetSuccess();
        Action = null;

        TimeToFinishWeaponAction = 0;

        base.Reset();
    }
Esempio n. 15
0
    /// <summary>
    /// 使用E_Type创建AgentAction命令.
    /// </summary>
    /// <param name="_type">_type.</param>
    static public AgentAction Create(E_Type _type)
    {
        int         index = (int)_type;
        AgentAction a;

        if (_UnusedActions[index].Count > 0)
        {
            a = _UnusedActions[index].Dequeue();
        }
        else
        {
            switch (_type)
            {
            case E_Type.E_Idle:
                a = new AgentActionIdle();
                break;

            case E_Type.E_Move:
                a = new AgentActionMove();
                break;

            case E_Type.E_Weapon_Show:
                a = new AgentActionWeaponShow();
                break;

            case E_Type.E_Attack:
                a = new AgentActionAttack();
                break;

            case E_Type.E_Play_Anim:
                a = new AgentActionPlayAnim();
                break;

            default:
                Debug.LogError("No AgentAction Create!!! Type: " + _type.ToString());
                return(null);
            }
        }
        a.Reset();
        a.SetActive();
#if DEBUG
        _ActiveActions.Add(a);
#endif
        return(a);
    }
Esempio n. 16
0
 public void HandleAction(AgentAction a)
 {
     if (a is AgentActionMove)
     {
         ActionMove = a as AgentActionMove;
     }
     else if (a is AgentActionCoverMove)
     {
         ActionMoveCover = a as AgentActionCoverMove;
     }
     else if (a is AgentActionSprint)
     {
         ActionMoveSprint = a as AgentActionSprint;
     }
     else if (a is AgentActionUseItem)         //THROW_RUN
     {
         ActionUseItem = a as AgentActionUseItem;
     }
 }
Esempio n. 17
0
    static public AgentAction Create(E_Type _type)
    {
        int         index = (int)_type;
        AgentAction a     = null;

        if (_UnusedActions[index].Count > 0)
        {
            //Dequeue 表示移除
            a = _UnusedActions[index].Dequeue();
        }
        else
        {
            switch (_type)
            {
            case E_Type.E_Idle:
                a = new AgentActionIdle();
                break;

            case E_Type.E_Move:
                a = new AgentActionMove();
                break;

            //case E_Type.E_Attack:
            //    break;
            //case E_Type.E_Weapon_Show:
            //    break;
            //case E_Type.E_Play_Anim:
            //    break;
            //case E_Type.E_Count:
            //    break;
            default:
                Debug.Log("没有AgentAction被创建" + _type.ToString());
                break;
            }
        }

        a.Reset();
        a.SetActive();
#if DEBUG
        _ActiveActions.Add(a);
#endif
        return(a);
    }
Esempio n. 18
0
    public AgentAction GetInputAction()
    {
        Vector3 moveDir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); // phenix 添加

        if (moveDir != Vector3.zero)
        {
            AgentActionMove moveAction = AgentActionFactory.Get(AgentActionType.MOVE, _owner) as AgentActionMove;
            moveAction.moveDir = moveDir;
            AddOrder(moveAction);
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            AgentActionRoll rollAction = AgentActionFactory.Get(AgentActionType.ROLL, _owner) as AgentActionRoll;
            rollAction.direction = transform.forward;
            rollAction.toTarget  = null;
            AddOrder(rollAction);
        }
        if (Input.GetKeyUp(KeyCode.J))
        {
            AgentActionAttackMelee attackMeleeAction = AgentActionFactory.Get(AgentActionType.ATTACK_MELEE, _owner) as AgentActionAttackMelee;
            attackMeleeAction.attackType = OrderAttackType.X;
            AddOrder(attackMeleeAction);
        }
        if (Input.GetKeyUp(KeyCode.K))
        {
            AgentActionAttackMelee attackMeleeAction = AgentActionFactory.Get(AgentActionType.ATTACK_MELEE, _owner) as AgentActionAttackMelee;
            attackMeleeAction.attackType = OrderAttackType.O;
            AddOrder(attackMeleeAction);
        }

        if (_inputOrders.Count > 0)
        {
            return(_inputOrders.Dequeue());
        }
        return(null);
    }
Esempio n. 19
0
    public static AgentAction Create(E_Type type)
    {
        int index = (int)type;

        AgentAction a;

        if (m_UnusedActions[index].Count > 0)
        {
            a = m_UnusedActions[index].Dequeue();
        }
        else
        {
            switch (type)
            {
            case E_Type.Idle:
                a = new AgentActionIdle();
                break;

            case E_Type.Move:
                a = new AgentActionMove();
                break;

            case E_Type.Sprint:
                a = new AgentActionSprint();
                break;

            case E_Type.Goto:
                a = new AgentActionGoTo();
                break;

            case E_Type.Attack:
                a = new AgentActionAttack();
                break;

            case E_Type.Melee:
                a = new AgentActionMelee();
                break;

            case E_Type.Injury:
                a = new AgentActionInjury();
                break;

            case E_Type.Roll:
                a = new AgentActionRoll();
                break;

            case E_Type.WeaponChange:
                a = new AgentActionWeaponChange();
                break;

            case E_Type.Rotate:
                a = new AgentActionRotate();
                break;

            case E_Type.Use:
                a = new AgentActionUse();
                break;

            case E_Type.PlayAnim:
                a = new AgentActionPlayAnim();
                break;

            case E_Type.PlayIdleAnim:
                a = new AgentActionPlayIdleAnim();
                break;

            case E_Type.Death:
                a = new AgentActionDeath();
                break;

            case E_Type.Knockdown:
                a = new AgentActionKnockdown();
                break;

            case E_Type.Teleport:
                a = new AgentActionTeleport();
                break;

            case E_Type.CoverEnter:
                a = new AgentActionCoverEnter();
                break;

            case E_Type.CoverMove:
                a = new AgentActionCoverMove();
                break;

            case E_Type.CoverFire:
                a = new AgentActionCoverFire();
                break;

            case E_Type.CoverFireCancel:
                a = new AgentActionCoverFireCancel();
                break;

            case E_Type.CoverLeave:
                a = new AgentActionCoverLeave();
                break;

            case E_Type.Reload:
                a = new AgentActionReload();
                break;

            case E_Type.UseItem:
                a = new AgentActionUseItem();
                break;

            case E_Type.ConstructGadget:
                a = new AgentActionConstructGadget();
                break;

            case E_Type.TeamCommand:
                a = new AgentActionTeamCommand();
                break;

            default:
                Debug.LogError("no AgentAction to create");
                return(null);
            }
        }
        a.Reset();
        a.SetActive();

        // DEBUG !!!!!!
        //	m_ActionsInAction.Add(a);
        return(a);
    }
Esempio n. 20
0
    protected virtual void HandleMovement()
    {
        if (ActionMove != null)
        {
            if (ActionMove.IsActive())
            {
//				Debug.Log ("ComponentBody.HandleMovement() MOVE, BlackBoard.MoveDir=" + Owner.BlackBoard.MoveDir);

                //Profiler.BeginSample ("ComponentBody.Update() : HandleMovement - Move");

                if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
                {
                    ActionMove.SetFailed();
                }

                //Profiler.EndSample();
            }

            if (ActionMove.IsActive() == false)
            {
                ActionMove = null;
            }
        }
        else if (ActionMoveCover != null)
        {
            if (ActionMoveCover.IsActive())
            {
                if (CoverMove() == false)
                {
                    ActionMoveCover.SetFailed();
                }

                CheckEdges();
            }

            if (ActionMoveCover.IsActive() == false)
            {
                ActionMoveCover = null;
            }
        }
        else if (ActionMoveSprint != null)
        {
            if (ActionMoveSprint.IsActive())
            {
                if (Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime) == false)
                {
                    ActionMoveSprint.SetFailed();
                }
            }

            if (ActionMoveSprint.IsActive() == false)
            {
                ActionMoveSprint = null;
            }
        }
        else if (ActionUseItem != null)         //THROW_RUN support move while throwing grenades
        {
            if (!Owner.IsInCover && (Owner.BlackBoard.MotionType == E_MotionType.Walk || Owner.BlackBoard.MotionType == E_MotionType.Run))
            {
//				Debug.Log ("ComponentBody.HandleMovement() USE ITEM, BlackBoard.MoveDir=" + Owner.BlackBoard.MoveDir);

                if (ActionUseItem.IsActive())
                {
                    Move(Owner.BlackBoard.MoveDir * Owner.BlackBoard.Speed * Time.deltaTime);
                }

                if (ActionUseItem.IsActive() == false)
                {
                    ActionUseItem = null;
                }
            }
        }
    }
Esempio n. 21
0
    /// <summary>
    /// 使用E_Type创建AgentAction命令.
    /// </summary>
    /// <param name="_type">_type.</param>
    static public AgentAction Create(E_Type _type)
    {
        int         index = (int)_type;
        AgentAction a;

        if (_UnusedActions[index].Count > 0)
        {
            a = _UnusedActions[index].Dequeue();
        }
        else
        {
            switch (_type)
            {
            case E_Type.E_IDLE:
                a = new AgentActionIdle();
                break;

            case E_Type.E_MOVE:
                a = new AgentActionMove();
                break;

            case E_Type.E_WEAPON_SHOW:
                a = new AgentActionWeaponShow();
                break;

            case E_Type.E_ATTACK:
                a = new AgentActionAttack();
                break;

            case E_Type.E_PLAY_ANIM:
                a = new AgentActionPlayAnim();
                break;

            case E_Type.E_GOTO:
                a = new AgentActionGoTo();
                break;
            //case E_Type.E_COMBAT_MOVE:
            //    a = new AgentActioCombatMove();
            //    break;
            //case E_Type.E_ATTACK_ROLL:
            //    a = new AgentActionAttackRoll();
            //    break;
            //case E_Type.E_ATTACK_WHIRL:
            //    a = new AgentActionAttackWhirl();
            //    break;
            //case E_Type.E_INJURY:
            //    a = new AgentActionInjury();
            //    break;
            //case E_Type.E_DAMAGE_BLOCKED:
            //    a = new AgentActionDamageBlocked();
            //    break;
            //case E_Type.E_BLOCK:
            //    a = new AgentActionBlock();
            //    break;
            //case E_Type.E_ROLL:
            //    a = new AgentActionRoll();
            //    break;
            //case E_Type.E_INCOMMING_ATTACK:
            //    a = new AgentActionIncommingAttack();
            //    break;

            //case E_Type.Rotate:
            //    a = new AgentActionRotate();
            //    break;
            //case E_Type.E_USE_LEVER:
            //    a = new AgentActionUseLever();
            //    break;


            //case E_Type.E_PLAY_IDLE_ANIM:
            //    a = new AgentActionPlayIdleAnim();
            //    break;
            //case E_Type.E_DEATH:
            //    a = new AgentActionDeath();
            //    break;
            //case E_Type.E_KNOCKDOWN:
            //    a = new AgentActionKnockdown();
            //    break;
            //case E_Type.Teleport:
            //    a = new AgentActionTeleport();
            //    break;
            default:
                Debug.LogError("No AgentAction Create!!! Type: " + _type.ToString());
                return(null);
            }
        }
        a.Reset();
        a.SetActive();
#if DEBUG
        _ActiveActions.Add(a);
#endif
        return(a);
    }