Example #1
0
    private void KillEnemy(bool throughFeet)
    {
        GameState.score += 100;

        var player = ObjectLocator.GetPlayer();

        if (player != null)
        {
            var pos = new Vector2(player.transform.position.x, player.transform.position.y + 0.3f);
            // Uh...
            // Make a resource manager with a pool of scores
            // Also add more scoring stuff
            Instantiate(Resources.Load <GameObject>("Prefabs/Scores/Score100"), pos, player.transform.rotation);
        }

        // Type of death
        // TODO: Improve
        if (deathType == DeathType.ICE || deathType == DeathType.DIVIDE)
        {
            var iceCube = Resources.Load <GameObject>("Prefabs/Props/IceCube");
            var pos     = gameObject.transform.position;
            Instantiate(iceCube, new Vector3(pos.x - 0.02f, pos.y - 0.01f, pos.z), gameObject.transform.rotation);
            Instantiate(iceCube, new Vector3(pos.x - 0.01f, pos.y - 0.01f, pos.z), gameObject.transform.rotation);
            Instantiate(iceCube, new Vector3(pos.x, pos.y - 0.01f, pos.z), gameObject.transform.rotation);
            Instantiate(iceCube, new Vector3(pos.x + 0.01f, pos.y - 0.01f, pos.z), gameObject.transform.rotation);
            Instantiate(iceCube, new Vector3(pos.x + 0.02f, pos.y - 0.01f, pos.z), gameObject.transform.rotation);
            MarkAsDead();
        }
        else
        {
            var prefab = "Blood";
            // Pff I mean this is utter crap
            if (deathType == DeathType.EXPLOSION)
            {
                prefab = "Explosion";
                AudioManager.GetInstance().PlayEffect(Sfx.EXPLOSION, 1f);
            }
            if (deathType == DeathType.SLIME)
            {
                prefab = "Poison";
            }
            Instantiate(Resources.Load <GameObject>("Prefabs/" + prefab), gameObject.transform.position, gameObject.transform.rotation);
            MarkAsDead();
        }

        if (throughFeet)
        {
            AchievementManager.AddJumpKillCount();
        }

        gameObject.SetActive(false);
    }