示例#1
0
 public CombatInput(Vector3 MovementDir, bool isJumping, bool isSprinting, ECombatInputType combatType)
 {
     this.MovementDir = MovementDir;
     this.isJumping   = isJumping;
     this.isSprinting = isSprinting;
     this.combatType  = combatType;
 }
示例#2
0
 public void StartedNewAttack(ECombatInputType attack)
 {
     //Set attack type
     fightHandler.CurrentAttack = attack;
     //Set attacking state
     if (attack != ECombatInputType.NONE)
     {
         fightHandler.IsAttacking = true;
     }
     else
     {
         fightHandler.IsAttacking = false;
         return;
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        //start delay before starting regen
        if (startRegeningStamina)
        {
            timerRestDelay += Time.deltaTime;
        }

        //can start regen
        if (timerRestDelay >= staminaRestDelay)
        {
            startRegeningStamina = false;
            if (currStamina < torsoPart.maxStamina)
            {
                timer += Time.deltaTime;
                if (timer >= torsoPart.staminaRegen)
                {
                    timer = 0;
                    CurrStamina++;
                }
            }
        }

        //Handle Block animation state.
        if (Input.GetKeyDown(KeyCode.Q))
        {
            armPart.Block();
        }
        else if (Input.GetKeyUp(KeyCode.Q))
        {
            armPart.UnBlock();
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            CanAttack = !CanAttack;
            bool ui = inventory.SwitchUI();
            myCamera.UseMouseLook = !ui;
        }

        ECombatInputType someInputWasPressed = noInput;

        if (CanAttack)
        {
            if (Input.GetMouseButtonDown(0))
            {
                someInputWasPressed = ECombatInputType.WEAK_ATTACK;
            }

            if (Input.GetMouseButtonDown(1))
            {
                if (someInputWasPressed == ECombatInputType.WEAK_ATTACK)
                {
                    someInputWasPressed = ECombatInputType.BOTH_ATTACKS;
                }
                else
                {
                    someInputWasPressed = ECombatInputType.STRONG_ATTACK;
                }
            }

            if (someInputWasPressed != ECombatInputType.NONE)
            {
                CombatInput input = new CombatInput(speed, isJumping, isSprinting, someInputWasPressed);
                armPart.AttackInput(input);
            }
        }

        if (isSprinting)
        {
            timerStaminaRate += Time.deltaTime;
            if (timerStaminaRate >= legPart.RunningStaminaRate)
            {
                CurrStamina     -= legPart.RunningStaminaCost;
                timerStaminaRate = 0;
            }
        }
    }