Exemple #1
0
    //Affect everything in the radius of the prefab
    IEnumerator AOE(SpellInfo info)
    {
        GameObject aoeObject = Instantiate(aoePrefab, info.collisionPoints[0], Quaternion.identity);

        aoeObject.transform.localScale *= info.potency * aoeSizeAmplifier;
        SpellTriggerHandler sth = aoeObject.GetComponent <SpellTriggerHandler>();

        while (sth.containedObjects.Count == 0)
        {
            yield return(info);
        }

        info.collisionObjects.Clear();

        foreach (GameObject obj in sth.containedObjects)
        {
            if (obj == null)
            {
                break;
            }

            info.collisionObjects.Add(obj);
        }

        aoeObject.transform.GetChild(0).gameObject.SetActive(true);

        yield return(info);
    }
Exemple #2
0
    //Affect everything in a small area around the point of impact after a delay
    IEnumerator Timer(SpellInfo info)
    {
        GameObject obj = sie.SpawnAsSet(spellID, timerPrefab, "Timer", info.collisionPoints[0]);

        obj.transform.localScale *= info.potency;
        TimerController timer = obj.GetComponent <TimerController>();

        timer.sml     = this;
        timer.potency = info.potency;

        while (!timer.isDepleted)
        {
            yield return(info);
        }

        if (timer.shouldContinue)
        {
            SpellTriggerHandler sth = timer.timerObj.GetComponent <SpellTriggerHandler>();

            while (sth.containedObjects.Count == 0)
            {
                yield return(info);
            }

            info.collisionObjects.Clear();

            foreach (GameObject gameObj in sth.containedObjects)
            {
                if (gameObj == null)
                {
                    break;
                }

                info.collisionObjects.Add(gameObj);
            }

            Destroy(timer.timerObj);
            Destroy(timer.gameObject);
        }
        else
        {
            Destroy(timer.gameObject);

            info.shouldContinue = false;
        }

        yield return(info);
    }
Exemple #3
0
    //Affect everything in a small area around the point of impact after something enters the area
    IEnumerator Proximity(SpellInfo info)
    {
        GameObject obj = sie.SpawnAsSet(spellID, proxPrefab, "Prox", info.collisionPoints[0]);

        obj.transform.localScale *= info.potency;
        ProxController prox = obj.GetComponent <ProxController>();

        prox.sml = this;

        while (!prox.isTriggered)
        {
            yield return(info);
        }

        if (prox.shouldContinue)
        {
            SpellTriggerHandler sth = prox.proxObj.GetComponent <SpellTriggerHandler>();

            while (sth.containedObjects.Count == 0)
            {
                yield return(info);
            }

            info.collisionObjects.Clear();

            foreach (GameObject gameObj in prox.proxObj.GetComponent <SpellTriggerHandler>().containedObjects)
            {
                if (gameObj == null)
                {
                    break;
                }

                info.collisionObjects.Add(gameObj);
            }

            Destroy(prox.proxObj);
            Destroy(prox.gameObject);
        }
        else
        {
            Destroy(prox.gameObject);

            info.shouldContinue = false;
        }

        yield return(info);
    }
Exemple #4
0
    //Produce spell efects at the player's hand
    IEnumerator Touch(SpellInfo info)
    {
        RaycastHit hit        = new RaycastHit();
        GameObject aoeObject  = null;
        Vector3    touchPoint = Vector3.zero;

        if (Info.IsCurrentlyVR())
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit, touchDistanceVR, ~chargeIgnoreRays))
            {
                touchPoint = hit.point;
            }
            else
            {
                touchPoint = transform.position + transform.forward * touchDistanceVR;
            }
        }
        else
        {
            Animator arm = FindObjectOfType <PlayerController>().animator;

            arm.SetTrigger(PlayerController.touchHash);

            while (arm.GetCurrentAnimatorStateInfo(0).IsTag("Neutral"))
            {
                yield return(info);
            }

            while (arm.GetCurrentAnimatorStateInfo(0).IsTag("Start"))
            {
                yield return(info);
            }

            touchPoint = Physics.Raycast(transform.position, transform.forward, out hit, touchDistance, ~chargeIgnoreRays) ? hit.point : Camera.main.transform.position + Camera.main.transform.forward * touchDistance;

            //         if (Physics.Raycast(transform.position, transform.forward, out hit, touchDistance))
            //{
            //	touchPoint = hit.point;
            //}
            //else
            //{
            //	touchPoint = Camera.main.transform.position + Camera.main.transform.forward * touchDistance;
            //}
        }

        info.collisionPoints.Add(touchPoint);
        GameObject FX = Instantiate(touchFX);

        FX.transform.position = touchPoint;
        Destroy(FX, FX.GetComponent <ParticleSystem>().main.duration);
        aoeObject = Instantiate(aoePrefab, touchPoint, Quaternion.identity);
        aoeObject.transform.localScale *= touchSize;
        SpellTriggerHandler sth = aoeObject.GetComponent <SpellTriggerHandler>();

        while (sth.containedObjects.Count == 0)
        {
            yield return(info);
        }

        foreach (GameObject obj in sth.containedObjects)
        {
            if (obj == null)
            {
                break;
            }

            info.collisionObjects.Add(obj);
        }

        Destroy(aoeObject);

        info.potency = 2;

        playerRotation = rotationReference.transform.rotation;

        yield return(info);

        NotifySpellCasted();
    }