Example #1
0
    public override void ReceiveDamage(float damage, Vector3 damageDealerPosition)
    {
        base.ReceiveDamage(damage, damageDealerPosition);

        if (IsAlive)
        {
            if (!target)
            {
                task = Task.move;
                nav.SetDestination(damageDealerPosition);
            }
            if (HealthPercent > .5f)
            {
                animator.SetTrigger("Get Hit");
                nav.velocity = Vector3.zero;
            }
        }
        else
        {
            if (!IsAlive && Money.TryAddMoney(reward) && reward > 0)
            {
                MoneyEarner.ShowMoneyText(transform.position, (int)reward);
                reward = 0;
            }
        }
    }
Example #2
0
    void Spawn(GameObject prefab)
    {
        var buyable = prefab.GetComponent <Buyable>();

        if (!buyable || !Money.TrySpendMoney(buyable.cost))
        {
            return;
        }

        var unit = Instantiate(prefab, spawnPoint.position, spawnPoint.rotation);

        unit.SendMessage("Command", flag.position, SendMessageOptions.DontRequireReceiver);
        MoneyEarner.ShowMoneyText(unit.transform.position, -(int)buyable.cost);
    }