// Beendet den Kampf. Der Spieler hat in diesem Fall gewonnen. private void endCombat() { jumpAndRunUIText.text = "HP " + player.getHP() + "/" + player.getFullHP(); player.changeXP(enemyBase.getxpReward()); Debug.Log("current XP: " + player.getXP()); Debug.Log("XP for level: " + player.getXPForLevel(player.getLevel())); xpText.text = "XP " + player.getXP() + "/" + player.getXPForLevel(player.getLevel()); Destroy(touchedEnemy); playerCamera.SetActive(true); battleCamera.SetActive(false); setInCombat(false); Debug.Log("Player won fight!"); Destroy(enemyCombat.gameObject); }
// Update is called once per frame void Update() { movementUpdate(); if (Input.GetKeyDown(KeyCode.Z)) { FindObjectOfType <PlayerValues>().changeXP(100); combatManager.xpText.text = "XP " + player.getXP() + "/" + player.getXPForLevel(player.getLevel()); } if (Input.GetKeyDown(KeyCode.U)) { FindObjectOfType <PlayerValues>().saveStats(); SceneManager.LoadScene("Level2"); } if (player.getHP() <= 0 && !combatManager.inCombat) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } invincibility = Mathf.Max(0, invincibility - 1); if (!combatManager.inCombat) { combatTimeout = Mathf.Max(0, combatTimeout - 1); } attackTime = Mathf.Max(0, attackTime - 1); if (attackTime == 15) { Instantiate(playerHitbox, transform); } if (Input.GetButtonDown("Attack") && !activeTextBox) { anim.SetTrigger("Attack"); attackTime = 20; if (!grounded) { checkFlip(Input.GetAxis("Horizontal")); } } if (!combatManager.getInCombat()) { //Spieler wird bewegt collisionBox.movement(); //Prüft ob der Spieler auf dem Boden ist grounded = collisionBox.isGrounded(); if (grounded) { //Stacheln if (invincibility == 0) { Spikes floorDamage = collisionBox.getGround().GetComponent <Spikes>(); if (floorDamage != null) { spikeDamage(); } } //Spieler ist auf dem boden if (isStomping) { //Spieler landet von einer Stampfattacke GameObject ground = collisionBox.getGround(); if (ground != null) { Destructable des = ground.GetComponent <Destructable>(); if (des != null && des.stomp) { des.dealDamage(1); collisionBox.setVSpeed(0.4f); } } } else { if (collisionBox.velocity.x != 0) { GameObject wall = collisionBox.getWall(collisionBox.velocity.x > 0 ? Vector3.right : Vector3.left); if (wall != null) { Pushable push = wall.GetComponent <Pushable>(); if (push != null) { wall.GetComponent <CollisionBox>().wallCollisionH(collisionBox.velocity.x > 0 ? push.pushSpeed : -push.pushSpeed); } } } } canDoubleJump = true; isStomping = false; if (Input.GetAxis("Horizontal") != 0 && !activeTextBox) { anim.SetTrigger("Walking"); } else { anim.SetTrigger("Standing"); } } else { anim.SetTrigger("Jumping"); } if (invincibility == 0) { GameObject spikeWall = collisionBox.getWall(collisionBox.velocity.x < 0 ? Vector3.left : Vector3.right); if (spikeWall != null) { Spikes spike = spikeWall.GetComponent <Spikes>(); if (spike != null) { spikeDamage(); } } } if (Input.GetButtonDown("Jump") && !activeTextBox) { if (grounded) { //Sprung von dem Boden anim.ResetTrigger("Standing"); anim.ResetTrigger("Walking"); anim.ResetTrigger("Stomp"); anim.SetTrigger("Jumping"); collisionBox.setVSpeed(jumpForce); grounded = false; } else if (canDoubleJump && abilityDoubleJump) { //Doppelsprung canDoubleJump = false; //Stampfattacke wird abgrbrochen isStomping = false; anim.SetTrigger("DoubleJump"); collisionBox.setVSpeed(doubleJumpForce); } } if (abilityStomp && Input.GetButtonDown("Stomp") && !grounded) { //Stampfattacke anim.ResetTrigger("Jumping"); anim.SetTrigger("Stomp"); isStomping = true; } //Prüft auf Gegnerberührung checkEnemies(); } hpText.text = "HP " + player.getHP() + "/" + player.getFullHP(); }
public void loadStats(PlayerValues player) { player.currentXP = exp; player.hpFlaskAmount = potions; player.setLevel(level); FindObjectOfType <CharSheetController>().updateStats(); FindObjectOfType <CombatManager>().xpText.text = "XP " + player.getXP() + "/" + player.getXPForLevel(player.getLevel()); }