Exemplo n.º 1
0
    protected override void OnDeath()
    {
        base.OnDeath();
        if (pounceTimer != null)
        {
            TimeControl.RemoveTimer(pounceTimer.id);
        }
        //todo - turn into corpse
        int foodToDrop = foodDroppedRange.second == 0 ? 0 : Random.Range(foodDroppedRange.first, foodDroppedRange.second + 1);

        if (GameEngine.instance.player.HasTrait(Trait.Type.HUNTER))
        {
            foodToDrop *= 2;
        }
        while (foodToDrop > 0)
        {
            var food = Instantiate(foodOnDeath, transform.position, Quaternion.identity);
            food.GetComponent <Collider2D>().enabled = false;
            food.transform.DOMove(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0f), .4f)
            .SetEase(Ease.InQuad)
            .SetRelative()
            .OnComplete(() => food.GetComponent <Collider2D>().enabled = true);
            foodToDrop--;
        }
        Destroy(this.gameObject);
    }
Exemplo n.º 2
0
 void OnDestroy()
 {
     if (pounceTimer != null)
     {
         TimeControl.RemoveTimer(pounceTimer.id);
     }
 }