예제 #1
0
    public override void Reset()
    {
        Action.SetSuccess();
        Action = null;

        base.Reset();
    }
예제 #2
0
 public override void OnDeactivate()
 {
     Owner.BlackBoard.ReactOnHits = true;
     if (Action != null)
     {
         Action.SetSuccess();
         Action = null;
     }
     Owner.BlackBoard.Speed = 0;
     base.OnDeactivate();
     // Time.timeScale = 1;
 }
예제 #3
0
    void HandleCoverMove()
    {
        AgentActionCoverMove action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverMove) as AgentActionCoverMove;

        action.Speed = Owner.BlackBoard.Desires.MoveSpeedModifier;

        if (Vector3.Dot(Owner.BlackBoard.Desires.MoveDirection, Owner.Right) > 0)
        {
            action.Direction = AgentActionCoverMove.E_Direction.Right;
        }
        else
        {
            action.Direction = AgentActionCoverMove.E_Direction.Left;
        }

        Owner.BlackBoard.ActionAdd(action);
    }
예제 #4
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;
     }
 }
예제 #5
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionCoverMove;

        if (Owner.BlackBoard.BaseSetup.UseMoveSpeedModifier)
        {
            MaxSpeed = Owner.BlackBoard.BaseSetup.MaxCoverSpeed * Action.Speed;
        }
        else
        {
            // don't care about input power
            MaxSpeed = Owner.BlackBoard.BaseSetup.MaxCoverSpeed;
        }

        Owner.BlackBoard.MotionType = GetMotionType();
        Owner.BlackBoard.MoveType   = GetMoveType();
    }
예제 #6
0
    public override void Activate()
    {
        base.Activate();

        Action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverMove) as AgentActionCoverMove;

        Action.Speed = Owner.BlackBoard.Desires.MoveSpeedModifier;

        if (Vector3.Dot(Owner.BlackBoard.Desires.MoveDirection, Owner.Right) > 0)
        {
            Action.Direction = AgentActionCoverMove.E_Direction.Right;
        }
        else
        {
            Action.Direction = AgentActionCoverMove.E_Direction.Left;
        }

        Owner.BlackBoard.ActionAdd(Action);
    }
예제 #7
0
    public override void Update()
    {
        AgentActionCoverMove.E_Direction direction;

        if (Vector3.Dot(Owner.BlackBoard.Desires.MoveDirection, Owner.Right) > 0)
        {
            direction = AgentActionCoverMove.E_Direction.Right;
        }
        else
        {
            direction = AgentActionCoverMove.E_Direction.Left;
        }

        if (Action.Speed != Owner.BlackBoard.Desires.MoveSpeedModifier || Action.Direction != direction)
        {
            Action           = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverMove) as AgentActionCoverMove;
            Action.Speed     = Owner.BlackBoard.Desires.MoveSpeedModifier;
            Action.Direction = direction;
            Owner.BlackBoard.ActionAdd(Action);
        }
    }
예제 #8
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;
                }
            }
        }
    }
예제 #9
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);
    }