コード例 #1
0
    public override void Reset()
    {
        Action.SetSuccess();
        Action = null;

        base.Reset();
    }
コード例 #2
0
    protected override AgentAction MakeAgentAction()
    {
        AgentActionGoTo agentAction = AgentActionFactory.Get(AgentActionType.GOTO_POS, Owner) as AgentActionGoTo;

        agentAction.moveType      = MoveType.FORWARD;
        agentAction.motionType    = MotionType.SPRINT;
        agentAction.finalPosition = GetBestAttackStart(Owner.BlackBoard.desiredTarget);
        return(agentAction);
    }
コード例 #3
0
 private void ActionGoTo(Vector3 finalPos)
 {
     FinalPos             = finalPos;
     Action               = AgentActionFactory.Create(AgentActionFactory.E_Type.E_GOTO) as AgentActionGoTo;
     Action.MoveType      = AgentActionGoTo.E_MoveType.E_MT_FORWARD;
     Action.Motion        = E_MotionType.Run;
     Action.FinalPosition = FinalPos;
     Owner.BlackBoard.AddAction(Action);
     UnityEngine.Debug.Log(this.ToString() + "Send new goto action to pos " + FinalPos.ToString());
 }
コード例 #4
0
    public override void OnDeactivate()
    {
        Owner.BlackBoard.MotionType = E_MotionType.None;
        Owner.BlackBoard.MoveDir    = Vector3.zero;
        Owner.BlackBoard.Speed      = 0;

        Action.SetSuccess();
        Action = null;

        base.OnDeactivate();

        // Time.timeScale = 1;
    }
コード例 #5
0
ファイル: AnimStateGoTo.cs プロジェクト: chenyunpet/MyScript
    override public void OnDeactivate()
    {
        AnimEngine[AnimName].speed = 1;

        Action.SetSuccess();
        Action = null;

        Owner.BlackBoard.Speed = 0;

        base.OnDeactivate();

        // Time.timeScale = 1;
    }
コード例 #6
0
ファイル: GOAPActionGoTo.cs プロジェクト: huokele/shadow-gun
    public override void Activate()
    {
        base.Activate();

        Action               = AgentActionFactory.Create(AgentActionFactory.E_Type.Goto) as AgentActionGoTo;
        Action.MoveType      = E_MoveType.Forward;
        Action.Motion        = E_MotionType.Run;
        Action.FinalPosition = Position;

        Action.UseNavMeshAgentRotation = true;

        Owner.BlackBoard.ActionAdd(Action);
    }
コード例 #7
0
    private void ActionGoTo(Agent target)
    {
        FinalPos = GetBestAttackStart(target);

        Action               = AgentActionFactory.Create(AgentActionFactory.E_Type.E_GOTO) as AgentActionGoTo;
        Action.MoveType      = AgentActionGoTo.E_MoveType.E_MT_FORWARD;
        Action.Motion        = E_MotionType.Sprint;
        Action.FinalPosition = FinalPos;
        Owner.BlackBoard.AddAction(Action);


        if (Effect && (FinalPos - Owner.Position).magnitude > 0.5f)
        {
            CombatEffectsManager.Instance.StartCoroutine(CombatEffectsManager.Instance.PlayAndStop(Effect, 0.1f));
        }
    }
コード例 #8
0
ファイル: AnimStateGoTo.cs プロジェクト: chenyunpet/MyScript
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionGoTo;

        Vector3 dir;

        if (Owner.BlackBoard.LookType == E_LookType.TrackTarget && Owner.BlackBoard.DesiredTarget != null)
        {
            dir   = Owner.BlackBoard.DesiredTarget.Position - Owner.Transform.position;
            dir.y = 0;
            dir.Normalize();
        }
        else
        {
            dir   = Action.FinalPosition - Owner.Transform.position;
            dir.y = 0;
            dir.Normalize();
        }

        StartRotation = Owner.Transform.rotation;

        if (dir != Vector3.zero)
        {
            FinalRotation.SetLookRotation(dir);
        }

        Owner.BlackBoard.MotionType = GetMotionType();

        if (Action.Motion == E_MotionType.Sprint)
        {
            MaxSpeed = Owner.BlackBoard.MaxSprintSpeed;
        }
        else if (Action.Motion == E_MotionType.Run)
        {
            MaxSpeed = Owner.BlackBoard.MaxRunSpeed;
        }
        else
        {
            MaxSpeed = Owner.BlackBoard.MaxWalkSpeed;
        }

        RotationProgress = 0;
    }
コード例 #9
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionGoTo;

        Vector3 dir;

        dir   = Action.FinalPosition - Owner.Transform.position;
        dir.y = 0;
        dir.Normalize();

        StartRotation = Owner.Transform.rotation;

        if (dir != Vector3.zero)
        {
            if (Action.MoveType == E_MoveType.Forward)
            {
                FinalRotation.SetLookRotation(dir);
            }
            else if (Action.MoveType == E_MoveType.Backward)
            {
                FinalRotation.SetLookRotation(-dir);
            }
        }

        Owner.BlackBoard.MotionType = GetMotionType();
        Owner.BlackBoard.MoveType   = Action.MoveType;

        if (Action.Motion == E_MotionType.Run)
        {
            MaxSpeed = Owner.BlackBoard.RealMaxRunSpeed;             //Owner.BlackBoard.BaseSetup.MaxRunSpeed;
        }
        else
        {
            MaxSpeed = Owner.BlackBoard.RealMaxWalkSpeed;             //Owner.BlackBoard.BaseSetup.MaxWalkSpeed;
        }
        RotationProgress = 0;
    }
コード例 #10
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);
        _agentActionGoTo = Owner.BlackBoard.curAction as AgentActionGoTo;

        Vector3 dir = _agentActionGoTo.finalPosition - Owner.Transform.position;

        dir.y = 0;
        dir.Normalize();
        if (dir != Vector3.zero)
        {
            FinalRotation.SetLookRotation(dir);
        }

        StartRotation = Owner.Transform.rotation;

        Owner.BlackBoard.motionType = GetMotionType();

        if (_agentActionGoTo.motionType == MotionType.SPRINT)
        {
            _maxSpeed = Owner.BlackBoard.maxSprintSpeed;
        }
        else if (_agentActionGoTo.motionType == MotionType.RUN)
        {
            _maxSpeed = Owner.BlackBoard.maxRunSpeed;
        }
        else
        {
            _maxSpeed = Owner.BlackBoard.maxWalkSpeed;
        }

        RotationProgress = 0;

        if (Owner.isPlayer == false)
        {
            //Owner.BlackBoard.Vigor -= 20;
        }
    }
コード例 #11
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);
    }
コード例 #12
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);
    }