예제 #1
0
    public Unit CreateUnit(Tile t, Unit u, bool explosion)
    {
        Unit g;

        //if there is a unit on the tile
        if (t.Resident != null)
        {
            return(null);
            //if the tile is empty
        }
        else
        {
            //make a new unit at the tile
            g             = (Unit)Instantiate(u);
            g.CurrentTile = t;
            g.SetTile(t);
            g.ClickToTile(t);
            //g.Moved=true;
            g.Player = CurrTurn;

            if (explosion)
            {
                ((GameObject)Instantiate(Resources.Load("Prefabs/TurretBulletExplosion", typeof(GameObject)), g.transform.position, g.transform.rotation)).transform.parent = g.CurrentTile.transform;
            }

            //* Aesthetics for the spawning *//
            t.audio.PlayOneShot(spawnUnitNoise);

            AscendLight al = (AscendLight)((GameObject)Instantiate(Resources.Load("prefabs/AscendLight"))).GetComponent("AscendLight");
            al.setTile(t);
            al.OneShot();
        }

        return(g);
    }
예제 #2
0
    override public void Update()
    {
        //oscillate the glow intensity
        if (glowLight)
        {
            glowLight.intensity += (-glowLight.intensity + .45f) / 15;
        }

        if (run)
        {
            return;
        }

        //if ascendlights have not been created yet, create them on the surrounding tiles
        Tile t = u.CurrentTile;

        for (int i = 0; i < t._adjacentTiles.Length; i++)
        {
            if (!t._adjacentTiles[i] || !t._adjacentTiles[i].Above)
            {
                continue;
            }

            AscendLight al = (AscendLight)t._adjacentTiles[i].GetComponentInChildren(typeof(AscendLight));

            if (al)
            {
                al.attachShrine(this);
                continue;
            }

            //create it on the tiles around the shrine
            al = (AscendLight)((GameObject)Instantiate(Resources.Load("Prefabs/AscendLight"))).GetComponent("AscendLight");
            al.setTile(t._adjacentTiles[i]);
            al.attachShrine(this);

            //create it on the tiles above, as well, if applicable
            if (t._adjacentTiles[i].Above)
            {
                AscendLight al2 = (AscendLight)((GameObject)Instantiate(Resources.Load("Prefabs/AscendLight"))).GetComponent("AscendLight");
                al2.setTile(t._adjacentTiles[i].Above);
                al2.attachShrine(this);

                al.Above = al2;
            }
        }
        run = true;
    }