コード例 #1
0
    // generate a nova effect
    // 360 degree spilt
    private IEnumerator generateNovaSpell()
    {
        Vector3 hitpoint = transform.position + distance * caster.transform.forward;

        Quaternion lookedQua = Quaternion.LookRotation(hitpoint - transform.position);

        for (int i = 0; i < NumberOfBalls; i++)             // TODO num of fireballs
        {
            float randomAngle = 360.0f * i / NumberOfBalls; // TODO range angles

            GameObject gb = GameObject.Instantiate(subFireball, transform.position, lookedQua) as GameObject;

            //  add caster delegate
            NovaExplodeLink explodeLink = gb.GetComponent <NovaExplodeLink>();
            if (explodeLink)
            {
                explodeLink.caster = caster;
                explodeLink.depth  = depth - 1;
            }
            else
            {
                Debug.LogWarning("[Spell] Spell has no explode delegate");
            }



            gb.transform.Rotate(gb.transform.up, randomAngle, Space.Self);

            MovableUnit movUnit     = gb.GetComponent <MovableUnit> ();
            Vector3     newHitPoint = MathUtil.RotatePointAroundPivot(hitpoint, transform.position,
                                                                      new Vector3(0, randomAngle, 0));
            movUnit.MoveTo(newHitPoint);
            yield return(new WaitForSeconds(Time.fixedDeltaTime));
        }
    }
コード例 #2
0
ファイル: MeteorSpell.cs プロジェクト: al3css92/WizardCombat
    public override IEnumerator castMagic(GameObject caster, Vector3 hitpoint = default(Vector3))
    {
        Debug.Log("Meteor Activiated!");
        Vector3     castLocation = hitpoint + new Vector3(0, 20, 0);
        GameObject  gb           = GameObject.Instantiate(meteor, castLocation, caster.transform.rotation) as GameObject;
        MovableUnit movUnit      = gb.GetComponent <MovableUnit> ();

        movUnit.MoveTo(hitpoint);
        yield return(new WaitForSeconds(0.1f));
    }
コード例 #3
0
ファイル: IceBallSpell.cs プロジェクト: al3css92/WizardCombat
    public override IEnumerator castMagic(GameObject caster, Vector3 hitpoint = default(Vector3))
    {
        Quaternion lookedQua = Quaternion.LookRotation(hitpoint - caster.transform.position);
        GameObject gb        = GameObject.Instantiate(iceball, caster.transform.position, lookedQua) as GameObject;


        MovableUnit movUnit = gb.GetComponent <MovableUnit> ();

        movUnit.MoveTo(hitpoint);
        yield return(new WaitForSeconds(0.1f));
    }
コード例 #4
0
    public override IEnumerator castMagic(GameObject caster, Vector3 hitpoint = default(Vector3))
    {
//		Debug.Log("Fireball Activiated!");
//		float transformed_angle = Vector3.Angle (new Vector3 (0, 0, 1), hitpoint-caster.transform.position);
//
//		Debug.Log ("Angle: " + transformed_angle);
        Quaternion lookedQua = Quaternion.LookRotation(hitpoint - caster.transform.position);
        GameObject gb        = GameObject.Instantiate(fireball, caster.transform.position, lookedQua) as GameObject;


        MovableUnit movUnit = gb.GetComponent <MovableUnit> ();

        movUnit.MoveTo(hitpoint);
        yield return(new WaitForSeconds(0.1f));
    }
コード例 #5
0
ファイル: FireballSpell.cs プロジェクト: wjkcow/Kool
    public override IEnumerator castMagic(GameObject caster, Vector3 hitpoint = default(Vector3))
    {
//		Debug.Log("Fireball Activiated!");
//		float transformed_angle = Vector3.Angle (new Vector3 (0, 0, 1), hitpoint-caster.transform.position);
//
//		Debug.Log ("Angle: " + transformed_angle);
        Quaternion lookedQua = Quaternion.LookRotation(hitpoint - caster.transform.position);

        for (int i = 0; i < NumberOfBalls; i++)                  // TODO num of fireballs
        {
            float randomAngle = Random.Range(-1 * Range, Range); // TODO range angles

            GameObject gb = GameObject.Instantiate(fireball, caster.transform.position, lookedQua) as GameObject;
            //  add caster delegate
            ExplodeLink explodeLink = gb.GetComponent <ExplodeLink>();
            if (explodeLink)
            {
                explodeLink.caster = caster;
            }
            else
            {
                Debug.LogWarning("[Spell] Spell has no explode delegate");
            }


            // scale
            ScaleFireball(gb, scale);


            gb.transform.Rotate(gb.transform.up, randomAngle, Space.Self);

            MovableUnit movUnit     = gb.GetComponent <MovableUnit> ();
            Vector3     newHitPoint = MathUtil.RotatePointAroundPivot(hitpoint, caster.transform.position,
                                                                      new Vector3(0, randomAngle, 0));
            movUnit.MoveTo(newHitPoint);
            yield return(new WaitForSeconds(TimeInterval));
        }
        // GameObject gb = GameObject.Instantiate (fireball, caster.transform.position, lookedQua) as GameObject;



        yield return(null);
    }
コード例 #6
0
ファイル: MeteorController.cs プロジェクト: wjkcow/Kool
    private IEnumerator CastMeteorTo(Vector3 targetPosition)
    {
        Vector3 hitpoint     = targetPosition;
        Vector3 castLocation = targetPosition + new Vector3(0, 20, 0);
        // TODO Hard code
        Quaternion lookedQua = Quaternion.LookRotation(castLocation - hitpoint);



        // TODO create a indicator on the ground


        GameObject.Instantiate(targetIndicator, hitpoint, Quaternion.identity);
        yield return(new WaitForSeconds(1.0f));

        GameObject  gb      = GameObject.Instantiate(meteor, castLocation, lookedQua) as GameObject;
        MovableUnit movUnit = gb.GetComponent <MovableUnit> ();

        movUnit.MoveTo(hitpoint);
    }