Пример #1
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("AgentActionIdle......");
         AgentActionIdle a = AgentActionFactory.Create(AgentActionFactory.E_Type.E_IDLE) as AgentActionIdle;
         Owner.BlackBoard.AddAction(a);
     }
 }
Пример #2
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);
    }
Пример #3
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);
    }
Пример #4
0
    protected override void Update()
    {
        if (Owner.IsAlive == false)
        {
            return;
        }

        // camera je null v pripade spectator kamer - panaci pak slidovali po scene (bez rotace)
        // pokud nekdo vi proc tady byl tento test, nebo v pripade problemu vratit zpatky
        //if (Camera.main == null)
        //    return;

        base.Update();

        //Debug.Log(StrictCharacter.isStandingStill + " " + StrictCharacter.velocity.x + StrictCharacter.velocity.y + StrictCharacter.velocity.z);
        if (IsRolling || Owner.BlackBoard.BusyAction || Owner.IsEnteringToCover || IsLeavingCover)
        {
            Vector3 moveDirection = StrictCharacter.Velocity;
            Owner.BlackBoard.Desires.MoveDirection     = moveDirection.normalized;
            Owner.BlackBoard.Desires.MoveSpeedModifier = 1;

            float newSpeed = moveDirection.magnitude;
//			if (newSpeed > Owner.BlackBoard.BaseSetup.MaxSprintSpeed)
//				newSpeed = Owner.BlackBoard.BaseSetup.MaxSprintSpeed;
            if (newSpeed > Owner.BlackBoard.RealMaxSprintSpeed)
            {
                newSpeed = Owner.BlackBoard.RealMaxSprintSpeed;
            }

            Owner.BlackBoard.Speed = Mathf.Lerp(LastSpeed, newSpeed, 5);
            LastSpeed = Owner.BlackBoard.Speed;
        }
        else if (!StrictCharacter.isStandingStill)
        {
            Vector3 moveDirection = StrictCharacter.Velocity;

            if (Owner.IsInCover)
            {
                float dotRight   = Vector3.Dot(Owner.BlackBoard.Cover.Right, moveDirection);
                float dotForward = Vector3.Dot(Owner.BlackBoard.Cover.Forward, moveDirection);
                bool  canMove    = false;

                if (dotForward > 0.75f || dotForward < -0.75f)
                {
                    // disabled - HandleCoverMove() takes care just about left and right directions - why this was here then?
                    // in case of any problems just enable it again
                    //canMove = true;
                }
                else
                {
                    if (dotRight > 0.75f)
                    {
                        Vector3 edgePos = Owner.BlackBoard.Cover.RightEdge;
                        edgePos.y = Owner.Position.y;

                        if ((Owner.Position - edgePos).magnitude > 0.01f)
                        {
                            canMove = true;
                        }
                    }
                    else if (dotRight < -0.75f)
                    {
                        Vector3 edgePos = Owner.BlackBoard.Cover.LeftEdge;
                        edgePos.y = Owner.Position.y;

                        if ((Owner.Position - edgePos).magnitude > 0.01f)
                        {
                            canMove = true;
                        }
                    }
                }

                if (canMove)
                {
                    HandleCoverMove();
                }
            }
            else if (Owner.BlackBoard.MotionType == E_MotionType.None)
            {
                Owner.BlackBoard.ActionAdd(AgentActionFactory.Create(AgentActionFactory.E_Type.Move) as AgentActionMove);
            }
            else
            {
                //Debug.Log ("ComponentPlayerMP.Update() 4");
            }

            Owner.BlackBoard.Desires.MoveDirection     = moveDirection.normalized;
            Owner.BlackBoard.Desires.MoveSpeedModifier = 1;

            float newSpeed = moveDirection.magnitude;
//			if(newSpeed > Owner.BlackBoard.BaseSetup.MaxSprintSpeed)
//				newSpeed = Owner.BlackBoard.BaseSetup.MaxSprintSpeed;
            if (newSpeed > Owner.BlackBoard.RealMaxSprintSpeed)
            {
                newSpeed = Owner.BlackBoard.RealMaxSprintSpeed;
            }

            Owner.BlackBoard.Speed = Mathf.Lerp(LastSpeed, newSpeed, 5);
            LastSpeed = Owner.BlackBoard.Speed;
            Owner.WorldState.SetWSProperty(E_PropKey.AtTargetPos, false);
        }
        else
        {
            Owner.BlackBoard.Desires.MoveDirection     = Vector3.zero;
            Owner.BlackBoard.Desires.MoveSpeedModifier = 0;
            Owner.BlackBoard.Speed = 0;
            LastSpeed = 0;

            if (Owner.BlackBoard.MotionType != E_MotionType.None /*&& !IsLeavingCover*/ && !Owner.BlackBoard.CoverFire)
            //mira and mara and beny consensus, that it could be deleted
            {
                AgentActionIdle idle = AgentActionFactory.Create(AgentActionFactory.E_Type.Idle) as AgentActionIdle;
                Owner.BlackBoard.ActionAdd(idle);
                Owner.WorldState.SetWSProperty(E_PropKey.AtTargetPos, true);
            }
        }

        Owner.BlackBoard.Desires.Rotation = StrictCharacter.Rotation;

        ClipRotation();

        // Debug.Log(Controls.View.YawAdd + " " + Controls.View.PitchAdd);

        HandleFire();
    }
Пример #5
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);
    }
Пример #6
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);
    }