Пример #1
0
    private void Update()
    {
        UpdateMovement();
        UpdateAim();
        UpdateCurrentWeapon();

        if (GetButton("Fire"))
        {
            Shoot();
        }

        if (GetButtonDown("Reload"))
        {
            Reload();
        }

        if (GetButtonDown("Interact"))
        {
            Interact();
        }

        if (GetButtonDown("Ability"))
        {
            playerClass.Ability();
        }

        if (GetButtonDown("Special"))
        {
            playerClass.Special();
        }

        if (tempHealth >= 1)
        {
            Heal(Mathf.FloorToInt(tempHealth));
            tempHealth = 0;
        }
    }
Пример #2
0
 // Using Update here instead of FixedUpdate because it makes for more responsive lane switching
 void Update()
 {
     AnimatorController.instance.UpdateSpeed(body.velocity.x);
     // To limit player movement rightward
     posXLimit = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, 0)).x - 0.5f;
     if (GameManager.gameState != GameManager.GameState.Paused)
     {
         MoveLeftRight();
         SwitchLanes();
         // Work-around for a bug where the mage fireballs were pushing the player around
         if (!switchingLanes)
         {
             transform.position = new Vector2(transform.position.x, LaneManager.instance.laneLocations[lane]);
         }
     }
     if ((Input.GetKeyDown(KeyCode.J) ||
          Input.GetKeyDown(KeyCode.K) ||
          Input.GetKeyDown(KeyCode.L) ||
          Input.GetKeyDown(KeyCode.Space)) &&
         GameManager.gameState != GameManager.GameState.Paused)
     {
         currentClass.Ability();
     }
 }