Example #1
0
        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);
            }
        }
Example #2
0
        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();
        }
Example #3
0
 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);
     }
 }
Example #4
0
    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();
    }
Example #5
0
        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);
        }