private void OnMouseDown() { if (playerAttacking.pAction > 0 || (spriteColor.material.color != Color.yellow)) // If player has dbl healed or attacked already or enemy outside of range { return; } playerAttacking.Attack(this.gameObject); }
void Update() { if (isGrounded) { extrajumps = maxJumps; } if (knockbackCounter == 0 && freezeCounter == 0) { if (onEnemyHead && (Input.GetKey(KeyCode.W) || Input.GetButton(A))) { rb.velocity = Vector2.up * footStoolForce; Debug.Log("Footstool"); } else if ((Input.GetKeyDown(KeyCode.W) || Input.GetButtonDown(A)) && extrajumps > 0 && !isGrounded) { rb.velocity = Vector2.up * jumpForce; extrajumps--; } else if ((Input.GetKeyDown(KeyCode.W) || Input.GetButtonDown(A)) && isGrounded) { rb.velocity = Vector2.up * jumpForce; } if ((Input.GetKeyDown(KeyCode.J) || Input.GetButtonDown(B))) { actions.Attack(); } if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown(RB)) { myGun.Fire(); } } else { if (knockbackCounter > 0) { knockbackCounter -= Time.deltaTime; if (knockbackCounter < 0) { knockbackCounter = 0; rb.velocity = Vector2.zero; } } if (freezeCounter > 0) { freezeCounter -= Time.deltaTime; if (freezeCounter < 0) { freezeCounter = 0; } } } if (Input.GetButtonDown(startButton)) { gameMam.PausePressed(); } }
public void FinishTurn(int player, string action) { if (!gameEnded) { switch (player) { case 1: player1.EndTurn(); turnPlayer1 = false; actionPlayer1 = action; break; case 2: player2.EndTurn(); turnPlayer2 = false; actionPlayer2 = action; break; } } if (!turnPlayer1 && !turnPlayer2) { if (actionPlayer1 == "Charge") { player1Actions.Charge(); } if (actionPlayer2 == "Charge") { player2Actions.Charge(); } if (actionPlayer1 == "Block") { player1Actions.Block(); } if (actionPlayer2 == "Block") { player2Actions.Block(); } if (actionPlayer1 == "Attack") { player1Actions.Attack(); } if (actionPlayer2 == "Attack") { player2Actions.Attack(); } actionPlayer1 = ""; actionPlayer2 = ""; player1Actions.CheckIfUnblock(); player1.StartTurn(); turnPlayer1 = true; player2Actions.CheckIfUnblock(); player2.StartTurn(); turnPlayer2 = true; } }