public void UpdateShipDestroyed(Event ev) { ShipDestroyedEvent des = (ShipDestroyedEvent)ev; if (des.Ship.Owner == user) { gridAI.SetCellState(lastHit, CellState.Sunk); } else { gridUser.SetCellState(lastHit, CellState.Sunk); } }
private void HandleShipDestroyed(Event ev) { ShipDestroyedEvent evCasted = (ShipDestroyedEvent)ev; Ship evShip = evCasted.Ship; foreach (Ship ship in evShip.Owner.Ships) { if (!ship.IsSunk()) { return; } } evShip.Owner.Lose(); }
private void OnDestroyed(ShipDestroyedEvent e) { if (e.DestroyedBy == Team.Player && e.Ship is EnemyShip enemy) { Points += enemy.MaxHealth; // we just use the max health of the enemy as his "value" if (enemy.ShipId == EnemyController.BossId) { if (waveCount == 0 && !hasTrophyAchieved) { // we have killed our first boss and we don't already have the achievement Game.Jolt.Trophies.SetAchieved(Game.User, Game.Settings.FirstBossTrophy); message = "Unlocked trophy!"; } waveCount++; // wave finished } } else if (e.Ship is PlayerShip) { gameover = true; // we died, so we can upload our new score. Game.Jolt.Scores.Add(Game.User, Points, $"{Points}P", tableId: Game.Settings.Scoreboard); } }
private void OnCollisionEnter(Collision collision) { string tag = collision.gameObject.tag; // Add damage if (tag == "Sun" || tag == "Planet") { currentHP = 0; } else { currentHP -= (rigidbody.velocity.magnitude / maxSpeed); } // check HP if (currentHP <= 0) { // Add explosion GameObject exp = Instantiate(explosion); exp.transform.position = transform.position; // Destroy ship GameObject.Destroy(gameObject); currentHP = 0; ShipDestroyedEvent.Invoke(); } else { // Add little explosion GameObject exp = Instantiate(littleExplosion, transform); exp.transform.position = transform.position; } // Update text info textHP.text = currentHP.ToString(); }
private void ASCIIShipDestroyed(Event ev) { ShipDestroyedEvent shipEvent = (ShipDestroyedEvent)ev; ASCIIWriteShip(shipEvent.Ship.Owner.ID, shipEvent.Ship, shipEvent.Ship.Length.ToString().ToCharArray()[0], ConsoleColor.White, ConsoleColor.Red); }