示例#1
0
    void SpawnProjectileShield()
    {
        Dial dialCon = GameObject.Find("Dial").gameObject.GetComponent <Dial>();

        if (dialCon.IsShielded(GetCurrentLaneID() - 1))          //if there's already a shield there
        {
            //play some sort of error sound
            cooldown = 0f;
            Debug.Log("already a shield in lane " + GetCurrentLaneID());
            return;
        }
        GameObject shield = Instantiate(Resources.Load("Prefabs/MainCanvas/ProjectileShield")) as GameObject;           //make a shield

        shield.transform.SetParent(Dial.underLayer, false);
        BulletShield bsc = shield.GetComponent <BulletShield>();

        //make it the type of shield this thing deploys
        ConfigureProjectileShield(bsc);
        //find your angle
        float shieldOwnangle = this.transform.eulerAngles.z;
        float shieldAngle    = (shieldOwnangle + 90) % 360;

        shieldAngle *= (float)Math.PI / 180;
        //find where to spawn the shield
        RectTransform shieldRt = bsc.GetComponent <RectTransform>();

        shieldRt.anchoredPosition = new Vector2(shieldRange * Mathf.Cos(shieldAngle), shieldRange * Mathf.Sin(shieldAngle));
        //Debug.Log("shield y should be " + shieldRange * Mathf.Sin(shieldAngle));
        shieldRt.rotation = this.gameObject.transform.rotation;
        dialCon.PlaceShield(GetCurrentLaneID() - 1, shield);          //mark current lane as shielded (placed in array)
    }
示例#2
0
 //Assigns skill values to projectile shields
 private void ConfigureProjectileShield(BulletShield bsc)
 {
     bsc.reflect            = reflect;
     bsc.frequency          = frequency;
     bsc.penetration        = penetration;
     bsc.continuousStrength = continuousStrength;
     bsc.vampDrain          = vampDrain;
 }