Exemplo n.º 1
0
    public void CastChannel()
    {
        Vector3 pos = Camera.main.WorldToScreenPoint(spell.transform.position);
        Vector3 dir;

        Physics.IgnoreCollision(spell.GetComponent <Collider>(), GetComponent <Collider>());

        if (WiimoteStatus.WiiEnabled)
        {
            fireSpell = WiimoteStatus.buttonA;
        }
        else
        {
            fireSpell = Input.GetMouseButton(0);
        }


        if (fireSpell)
        {
            channeling = true;
            spell.SetActiveRecursively(true);

            if (WiimoteStatus.WiiEnabled)
            {
                dir = wiiPointer.transform.position - pos;
            }
            else
            {
                dir = Input.mousePosition - pos;
            }

            float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
            spell.transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
        }
        else if (!fireSpell && channeling)
        {
            casting    = false;
            channeling = false;
            cs.StopEmit();
        }
    }