Beispiel #1
0
    private Tile CreateOneTile(Coordinate _coordinate, Tile.TileType _type)
    {
        GameObject go = Instantiate(tilePrefabs[(int)_type].gameObject, GetWorldSpacePositionFromCoordinate(_coordinate), Quaternion.identity) as GameObject;

        go.SetActive(true);                     // local reference copy was set as inactive, so it has to be activated
        Tile t = go.GetComponent <Tile>();

        t.transform.SetParent(transform);
        t.Initialize(tileGrid, _coordinate, _type);
        tileGrid.AddTile(_coordinate, t);

        // initialize light source if it has one
        LightSource lightSource = go.GetComponent <LightSource>();

        if (lightSource != null)
        {
            lightSource.Initialize();
        }

        EventBroadcast.Instance.TriggerEvent(EventBroadcast.Event.LEVEL_CHANGE);

        return(t);
    }