Пример #1
0
    //spawns a shield trap in a given lane with a given holder
    void SpawnShieldTrap(int lane, ShieldTrapHolder holder)
    {
        Debug.Log("lane in spawnshieldtrap: " + lane);
        int  currentLane = GetCurrentLaneID() - 1;
        int  laneDif     = laneList.MinDistanceBetween(currentLane, lane);
        Dial dialCon     = GameObject.Find("Dial").gameObject.GetComponent <Dial>();

        if (dialCon.IsShielded(lane)) //if there's already a shield there
        {
            Debug.Log("already a shield here, not placing ShieldTrap");
            return;
        }
        GameObject shieldTrap = Instantiate(Resources.Load("Prefabs/MainCanvas/ShieldTrap")) as GameObject; //make a shield

        shieldTrap.transform.SetParent(Dial.underLayer, false);
        ShieldTrap sc = shieldTrap.GetComponent <ShieldTrap>();

        //make it the type of shield-trap this thing deploys
        ConfigureShieldTrap(sc);
        //find your angle, adding +/- 60 for each lane removed from This gun's lane
        float shieldOwnangle = this.transform.eulerAngles.z + (60 * laneDif);
        float shieldAngle    = (shieldOwnangle + 90) % 360;

        shieldAngle *= (float)Math.PI / 180;
        //find where to spawn the shield
        RectTransform shieldRt = sc.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(lane, shieldTrap); //mark current lane as shielded (placed in array)
        sc.SetMyLane(lane);
        sc.SetHolder(holder);
        holder.AddShield(sc);
    }
Пример #2
0
 //Assigns skill values to shield traps
 private void ConfigureShieldTrap(ShieldTrap sc)
 {
     //Debug.Log("tempdisplace of gun is " + tempDisplace);
     sc.absorb       = absorb;
     sc.duplicate    = duplicate;
     sc.tempDisplace = tempDisplace;
     sc.field        = field;
     sc.vampDrain    = vampDrain;
 }
Пример #3
0
 public void AddShield(ShieldTrap st)
 {
     //Debug.Log(shields == null);
     shields.Add(st);
     lanesCovered.Add(st.GetMyLane());
 }