예제 #1
0
파일: World.cs 프로젝트: Gurbx/LudumDare_46
    /// 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);
    }