void WinLevel() { EndText.text = "Level Won"; SetNextLevelButton(); Button.onClick.AddListener(NextLevelAction); gameObject.SetActive(true); WinSound.StopBackground(); WinSound.Play(); }
protected override bool Activate(Tile tile, Unit caster) { if (all_allies || all_enemies) { if (attackAudio != null) { attackAudio.Play(); } if (all_allies) { foreach (Unit unit in TurnManager.instance.friendlies) { unit.HP -= dmgValue; } } if (all_enemies) { foreach (Unit unit in TurnManager.instance.enemies) { unit.HP -= dmgValue; } } return(true); } if (castRange == 0) { if (attackAudio != null) { attackAudio.Play(); } caster.HP -= dmgValue; return(true); } else if (caster.tile.DistanceTo(tile) <= castRange && tile.unit != null) { if (attackAudio != null) { attackAudio.Play(); } tile.unit.HP -= dmgValue; return(true); } return(false); }
private void OnCollisionEnter2D(Collision2D other) { if (other.collider.gameObject.name == "MapBottom") { gameObject.SetActive(false); Events.PlayerDeath(); } else if (other.collider.gameObject.name == "WinLocation") { Events.PlayerWin(); } else if (other.collider.gameObject.name == "NextLevel") { Events.PlayerFinishLevel(); } else if (other.collider.gameObject.name.Contains("WeaponUpgrade")) { Events.WeaponUpgradePickup(other.gameObject.GetComponent <WeaponUpgrade>().weaponUpgradeData, other.gameObject.name); pickupWeapon.Play(); Destroy(other.gameObject); } else if (other.collider.gameObject.name.Contains("SavePoint")) { saveGameAudio.Play(); Events.SaveGame(other.gameObject.name); other.gameObject.GetComponent <BoxCollider2D>().enabled = false; } else if (other.gameObject.CompareTag("Platform")) { playerMovement.transform.parent = other.gameObject.transform; } }
public void Pressed() { Events.SelectSkill(SkillsData); Events.RemoveMoney(SkillsData.Cost); SkillUsed.Play(); Debug.Log("Pressed"); }
private void onClick() { //Debug.Log("Gathered" + res.Income); CoinDropAudio.Play(); Events.AddMoney(res.Income); Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "MeleeEnemy" && !_inv) { Debug.Log("meleeenemy"); Vector2 dir = collision.transform.position; dir = -dir.normalized; _rigidBody.AddForce(dir * 2, ForceMode2D.Impulse); _knockback = 0.2f; _spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 0.5f); Oof.Play(); Health -= collision.gameObject.GetComponentInParent <Damage>().EnemyMeleeDamage; _inv = true; } }
IEnumerator LerpMove(List <Tile> path, float duration) { isAnimating = true; Vector3 origin; Vector3 target = path[0].transform.position; for (int i = 1; i < path.Count; i++) { float startTime = Time.time; float currentTime = startTime; float endTime = startTime + duration; origin = target; target = path[i].transform.position; path[i].Color = Color.yellow; path[i - 1].Color = Color.black; while (currentTime < endTime) { yield return(null); currentTime = Time.time; transform.position = Vector3.Lerp(origin, target, (currentTime - startTime) / duration); if (walkAudio != null) { walkAudio.Play(); } } } isAnimating = false; }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { pickupKey.Play(); Events.DoorOpened(transform.parent.gameObject.name); Destroy(this.transform.parent.gameObject); } }
void LoseLevel() { EndText.text = "Level Lost"; SetBackToMenuButton(); Button.onClick.AddListener(GotoMenuAction); gameObject.SetActive(true); WinSound.StopBackground(); LoseSound.Play(); }
public void Damage(float dam) { Monster?.Play(); if (!_isDragon) { dam /= 2; } Lives -= dam; }
public void takeDamage(int damageAmount) { health = Mathf.Clamp(health - damageAmount, 0, maxHealth); HUD.Instance.SetHealth(health); takeDamageSound.Play(); Debug.Log("Player hp = " + health); if (health <= 0) { Events.PlayerDeath(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { walkAudio.Play(); } if (Input.GetKeyDown(KeyCode.Alpha2)) { deathAudio.Play(); } if (Input.GetKeyDown(KeyCode.Alpha3)) { explodeAudio.Play(); } //walkAudio.Play();//lol }
void Shoot() { _nextShot = Time.time + currentWeaponData.shootingSpeed; _sound.Play(); for (int i = 0; i < currentWeaponData.bulletAmount; i++) { //Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); float bulletRotNorm = Random.Range(-currentWeaponData.bullerSpread / 180, currentWeaponData.bullerSpread / 180); Quaternion bulletRot = Quaternion.FromToRotation(new Vector3(1, bulletRotNorm, 0), firePoint.right); GameObject bullet = Instantiate(bulletPrefab, firePoint.position, bulletRot); bullet.GetComponent <Bullet>().speed = currentWeaponData.bulletSpeed; bullet.GetComponent <Bullet>().bulletColor = currentWeaponData.bulletColor; bullet.GetComponent <Bullet>().damage = currentWeaponData.damage; } }
public void DrawCard() { //Data if (deck.Count == 0) { Reshuffle(); } hand.Add(Pop()); if (drawAudio != null) { drawAudio.Play(); } //UI if (turnManager.activeUnit == owner && owner is PlayerController) { UpdateHandUI(); } }
private void Shoot() { Health closest = null; float minVal = float.MaxValue; EnemiesInRange.ForEach((enemy) => { float val = (transform.position - enemy.transform.position).sqrMagnitude; if (val < minVal) { closest = enemy; minVal = val; } }); Bullet b = Instantiate(BulletPrefab, transform.position, Quaternion.identity, null); b.Target = closest; b.Damage = bulletDamage; b.Speed = bulletSpeed; ArrowShot.Play(); }
void Update() { if (AoE.activeSelf) { _timerAoE -= Time.deltaTime; if (_timerAoE < 0) { GameObject.Destroy(this.gameObject); } } _timerBomb -= Time.deltaTime; if (_timerBomb < 0) { AoE.SetActive(true); explosion.Play(); CameraShaker.Instance.ShakeOnce(1f, 0.9f, 0.3f, 0.3f); BoomSound?.Play(); this.GetComponent <SpriteRenderer>().sprite = null; } }
void OnPlayerDeath() { dieSound.Play(); gameObject.SetActive(false); }
public void Damage(float dam) { Monster?.Play(); Lives -= dam; }
public void Pressed() { Events.SelectStructure(StructureData); ItemSelected.Play(); }
void PlayButtonSound() { ButtonClickSound.Play(); }
public void Move(float move, bool crouch, bool jump) { // If crouching, check to see if the character can stand up if (!crouch) { // If the character has a ceiling preventing them from standing up, keep them crouching if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround)) { crouch = true; } } //only control the player if grounded or airControl is turned on if (m_Grounded || m_AirControl) { // If crouching if (crouch) { if (!m_wasCrouching) { m_wasCrouching = true; OnCrouchEvent.Invoke(true); } // Reduce the speed by the crouchSpeed multiplier move *= m_CrouchSpeed; // Disable one of the colliders when crouching if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = false; } } else { // Enable the collider when not crouching if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = true; } if (m_wasCrouching) { m_wasCrouching = false; OnCrouchEvent.Invoke(false); } } // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y); // And then smoothing it out and applying it to the character m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); // If the input is moving the player right and the player is facing left... if (move > 0 && !m_FacingRight) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && m_FacingRight) { // ... flip the player. Flip(); } } // If the player should jump... if (m_Grounded && jump) { jumpSound.Play(); // Add a vertical force to the player. m_Grounded = false; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); } }