Пример #1
0
    /// Returns true if target is killed
    public bool DamageObjectAtPoint(Vector2Int point, int damage)
    {
        if (enemyHandler.DamageEnemyAtPoint(point, damage) || unitHandler.DamageUnitAtPoint(point, damage) || hutHandler.DamageHutAtPoint(point, damage))
        {
            if (worldMap[point.x, point.y] == WorldObject.Hut) //If hut is destroyed reduce world health
            {
                if (GameData.instance.gameIsOver)
                {
                    return(true);
                }
                GameData.instance.health -= 1;
                healthUI.SetHP(GameData.instance.health);
                if (GameData.instance.health <= 0)
                {
                    GameOver();
                }
            }
            if (GetAllObjectPoints(WorldObject.Friend).Count <= 0)
            {
                if (GameData.instance.gameIsOver)
                {
                    return(true);
                }
                GameOver();
            }

            worldMap[point.x, point.y] = WorldObject.Empty;
            ScreenShakeHandler.AddScreenShake(5, 5, 0.5f);
            return(true);
        }
        return(false);
    }
Пример #2
0
    private void DeathEffect()
    {
        ScreenShakeHandler.AddScreenShake(3, 3, 0.2f);
        trail.transform.parent = transform.parent;
        trail.Stop();
        Destroy(trail, 4f);
        var effect = Instantiate(deathExplosionPrefab, transform);

        effect.transform.parent = transform.parent;
        Destroy(effect, 6f);
    }