public void Death() { AutoMover autoMover = GetComponent <AutoMover>(); HideMover hideMover = GetComponent <HideMover>(); Vector2 playerPos = Grapher.RoundedVector(PlayerMover.instance.transform.position); Vector2 position = Grapher.RoundedVector(transform.position); if (GetComponent <PlayerMover>()) { gameObject.SetActive(false); Sidebar.instance.GameOver(); // Debug.Log("Dead!"); // TODO: Game Over menu //TransitionFader.instance.Transition(0); } else if (autoMover && autoMover.spawnsWounded) { GameObject woundedEnemy = Instantiate(Globals.WEAK_ENEMY, position, Quaternion.identity, ObjectContainer.instance.wounded.transform); woundedEnemy.GetComponent <HideMover>().lastSawPlayer = playerPos; Inventory oldInventory = GetComponent <Inventory>(); Inventory newInventory = woundedEnemy.GetComponent <Inventory>(); if (oldInventory && newInventory) { newInventory.Add(oldInventory.inventory, oldInventory.wallet); } // Wounded enemies make noise GameObject tempNoise = Instantiate(Globals.NOISE, position, Quaternion.identity); tempNoise.GetComponent <Noise>().Initialize(true, Globals.KNIFE_VOLUME, Noise.Source.Knife); Destroy(gameObject); } else if (hideMover || (autoMover && !autoMover.spawnsWounded)) { GameObject corpse = Instantiate(Globals.CORPSE, position, Quaternion.identity); corpse.transform.parent = ObjectContainer.instance.corpses.transform; Inventory unitInventory = GetComponent <Inventory>(); Inventory corpseInventory = corpse.GetComponent <Inventory>(); if (unitInventory && corpseInventory) { corpseInventory.Add(unitInventory.inventory, unitInventory.wallet); } Destroy(gameObject); } }
// Pauses the player and all enemies (does not modify timeScale) public void ActionPause(bool paused) { actionPaused = paused; // Necessary for message dialogue pauseDimmer.targetAlpha = paused ? 0.5f : 0; RefreshAllActionButtons(); PlayerMover.instance.enabled = !paused; List <GameObject> enemyList = ObjectContainer.GetEnemiesAndWounded(); foreach (GameObject unit in enemyList) { AutoMover autoMover = unit.GetComponent <AutoMover>(); if (autoMover != null) { autoMover.enabled = !paused; } HideMover hideMover = unit.GetComponent <HideMover>(); if (hideMover != null) { hideMover.enabled = !paused; } Airship airship = unit.GetComponent <Airship>(); if (airship != null) { airship.enabled = !paused; } } List <GameObject> projectiles = ObjectContainer.GetAllProjectiles(); foreach (GameObject projectile in projectiles) { Projectile proj = projectile.GetComponent <Projectile>(); if (proj != null) { proj.enabled = !paused; } } }