Beispiel #1
0
    protected override bool DoUse()
    {
        reviveTarget = null;

        List <GameObject> revivableCorpses = detectVolume.DetectedObjects;
        float             closestDist      = -1f;

        foreach (GameObject corpse in revivableCorpses)
        {
            UnitCorpse unitCorpse = corpse.GetComponent <UnitCorpse>();
            if (!unitCorpse.CanRevive)
            {
                continue;
            }

            float dist = Vector3.Distance(corpse.transform.position, transform.position);

            if (reviveTarget == null || dist < closestDist)
            {
                reviveTarget = unitCorpse;
                closestDist  = dist;
            }
        }

        if (reviveTarget != null)
        {
            return(MyUser.TryDrainMana(ManaCost));
        }

        return(false);
    }
Beispiel #2
0
    public override bool Use()
    {
        reviveTarget = null;

        List <GameObject> revivableCorpses = detectVolume.DetectedObjects;
        float             closestDist      = -1f;

        foreach (GameObject corpse in revivableCorpses)
        {
            UnitCorpse unitCorpse = corpse.GetComponent <UnitCorpse>();
            if (!unitCorpse.CanRevive)
            {
                continue;
            }

            float dist = (corpse.transform.position - transform.position).magnitude;

            if (reviveTarget == null || dist < closestDist)
            {
                reviveTarget = unitCorpse;
                closestDist  = dist;
            }
        }

        if (reviveTarget != null)
        {
            state = AbilityState.Channeling;
            timer = channelTime;

            return(true);
        }

        return(false);
    }
Beispiel #3
0
    void Update()
    {
        if (unitModel.IsDead)
        {
            return;
        }

        float h_axis    = Input.GetAxisRaw("Horizontal");
        float v_axis    = Input.GetAxisRaw("Vertical");
        bool  useRevive = Input.GetButtonDown("Revive");
        bool  usePotion = Input.GetButtonDown("Potion");

        Quaternion camRot = Quaternion.AngleAxis(gameCamera.transform.rotation.eulerAngles.y, Vector3.up);

        unitMover.Move(camRot * new Vector3(h_axis, 0f, v_axis));

        if (useRevive && unitModel.mana.amount >= reviveManaCost && revivableCorpses.Count > 0)
        {
            UnitCorpse closestCorpse = null;
            float      closestDist   = -1f;

            foreach (GameObject corpse in revivableCorpses)
            {
                UnitCorpse unitCorpse = corpse.GetComponent <UnitCorpse>();
                if (!unitCorpse.CanRevive)
                {
                    continue;
                }

                float dist = (corpse.transform.position - transform.position).magnitude;

                if (closestCorpse == null || dist < closestDist)
                {
                    closestCorpse = unitCorpse;
                    closestDist   = dist;
                }
            }

            if (closestCorpse != null && closestCorpse.Revive())
            {
                unitModel.TryDrainMana(reviveManaCost);
                revivableCorpses.Remove(closestCorpse.gameObject);
            }
        }
    }