示例#1
0
        protected override void Prepare()
        {
            base.Prepare();
            base.StartAction(this.m_PunchBack);
            Direction direction;

            if (FistFightController.Get().IsActive())
            {
                direction = (FistFightController.Get().IsLeftPunch() ? Direction.Right : Direction.Left);
            }
            else if (WeaponMeleeController.Get().IsActive())
            {
                if (WeaponMeleeController.Get().IsRightAttack())
                {
                    direction = Direction.Left;
                }
                else if (WeaponMeleeController.Get().IsLeftAttack())
                {
                    direction = Direction.Right;
                }
                else
                {
                    direction = ((UnityEngine.Random.Range(0f, 1f) < 0.5f) ? Direction.Right : Direction.Left);
                }
            }
            else
            {
                direction = ((UnityEngine.Random.Range(0f, 1f) < 0.5f) ? Direction.Right : Direction.Left);
            }
            this.m_PunchBack.SetDirection(direction);
        }
        protected override void Prepare()
        {
            base.Prepare();
            Vector3 normalized2D = (Player.Get().transform.position - this.m_HumanAI.transform.position).GetNormalized2D();
            float   num          = Vector3.Angle(this.m_HumanAI.transform.forward.GetNormalized2D(), normalized2D);
            float   num2         = 40f;
            float   num3         = 0.3f;

            HitReaction.Type type = HitReaction.Type.Middle;
            if (num <= num2 && num3 <= UnityEngine.Random.Range(0f, 1f))
            {
                type = HitReaction.Type.StepBack;
            }
            else if (FistFightController.Get().IsActive())
            {
                type = ((!FistFightController.Get().IsLeftPunch()) ? HitReaction.Type.Right : HitReaction.Type.Left);
            }
            else if (WeaponMeleeController.Get().IsActive())
            {
                if (WeaponMeleeController.Get().IsRightAttack())
                {
                    type = HitReaction.Type.Right;
                }
                else if (WeaponMeleeController.Get().IsLeftAttack())
                {
                    type = HitReaction.Type.Left;
                }
                else
                {
                    type = HitReaction.Type.Middle;
                }
            }
            else if (num <= num2 && WeaponSpearController.Get().IsActive())
            {
                type = HitReaction.Type.StepBack;
            }
            if (type == this.m_AI.m_HumanFightModule.m_LastHitReactionType && this.m_AI.m_GoalsModule.m_PrevGoal != null && this.m_AI.m_GoalsModule.m_PrevGoal.m_Type == AIGoalType.HumanHitReaction)
            {
                switch (type)
                {
                case HitReaction.Type.Right:
                case HitReaction.Type.Left:
                    type = HitReaction.Type.Middle;
                    break;

                case HitReaction.Type.Middle:
                    type = HitReaction.Type.StepBack;
                    break;

                case HitReaction.Type.StepBack:
                    type = HitReaction.Type.Middle;
                    break;
                }
            }
            this.m_HitReaction.SetType(type);
            this.m_AI.m_HumanFightModule.m_LastHitReactionType = type;
            this.m_HitReaction.Initialize(this.m_AI, this);
            base.AddToPlan(this.m_HitReaction);
        }
示例#3
0
    private void UpdateState()
    {
        if (PlayerConditionModule.Get().IsStaminaLevel(WeaponMeleeController.Get().m_BlockAttackStaminaLevel))
        {
            this.m_Animator.SetBool(this.m_LowStaminaHash, true);
            this.SetState(BowController.State.LowStamina);
            this.m_Player.StopAim();
        }
        switch (this.m_State)
        {
        case BowController.State.Idle:
            if (!Inventory3DManager.Get().gameObject.activeSelf)
            {
                this.UpdateArrowFromInventory();
                if (this.m_Arrow == null)
                {
                    this.SetState(BowController.State.NoArrowIdle);
                }
            }
            break;

        case BowController.State.AimLoop:
            if (TriggerController.Get().IsGrabInProgress())
            {
                this.SetState(BowController.State.Idle);
                this.m_Player.StopAim();
            }
            else
            {
                float num = PlayerConditionModule.Get().GetStaminaDecrease(StaminaDecreaseReason.Bow) * Skill.Get <ArcherySkill>().GetStaminaConsumptionMul();
                this.m_Player.DecreaseStamina(num * Time.deltaTime);
                if (PlayerConditionModule.Get().GetStamina() == 0f)
                {
                    this.SetState(BowController.State.Idle);
                    this.m_Player.StopAim();
                }
            }
            break;

        case BowController.State.NoArrowIdle:
            this.UpdateArrowFromInventory();
            if (this.m_Arrow != null)
            {
                this.SetState(BowController.State.Idle);
            }
            break;

        case BowController.State.LowStamina:
            if (!PlayerConditionModule.Get().IsStaminaLevel(WeaponMeleeController.Get().m_BlockAttackStaminaLevel))
            {
                this.SetState((!(this.m_Arrow != null)) ? BowController.State.NoArrowIdle : BowController.State.Idle);
                this.m_Animator.SetBool(this.m_LowStaminaHash, false);
            }
            break;
        }
        this.m_Animator.SetInteger(this.m_IBowState, (int)this.m_State);
    }
示例#4
0
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo state_info, int layer_index)
 {
     if (state_info.normalizedTime > 0.9f)
     {
         WeaponMeleeController component = animator.transform.parent.GetComponent <WeaponMeleeController>();
         if (component)
         {
             component.PlayerMeleeUpAttackEnd();
         }
     }
 }
示例#5
0
 public override void OnReplicationPrepare()
 {
     if (WeaponMeleeController.Get().m_AnimationStopped)
     {
         if (this.m_AnimationStopped != WeaponMeleeController.Get().m_AnimationStopped)
         {
             this.m_AnimationStopped = WeaponMeleeController.Get().m_AnimationStopped;
             if (this.m_AnimationStopped)
             {
                 this.m_AnimationStopFrame = WeaponMeleeController.Get().m_AnimationStopFrame;
                 this.m_StateHash          = WeaponMeleeController.Get().m_AnimationStopStateHash;
                 return;
             }
         }
     }
     else
     {
         this.m_AnimationStopped   = false;
         this.m_AnimationStopFrame = -1f;
     }
 }
 public PlayerController GetLocalActiveControllerAnimClipReplacer()
 {
     if (BowController.Get().enabled)
     {
         return(BowController.Get());
     }
     if (HeavyObjectController.Get().enabled)
     {
         return(HeavyObjectController.Get());
     }
     if (ItemController.Get().enabled)
     {
         return(ItemController.Get());
     }
     if (WeaponMeleeController.Get().enabled)
     {
         return(WeaponMeleeController.Get());
     }
     if (WeaponSpearController.Get().enabled)
     {
         return(WeaponSpearController.Get());
     }
     return(null);
 }
示例#7
0
 private bool CanSwing()
 {
     return(this.m_Item.GetInfoID() != ItemID.Fire && (this.m_State == ItemController.State.None && !WeaponMeleeController.Get().IsActive()) && !Inventory3DManager.Get().isActiveAndEnabled);
 }