Ejemplo n.º 1
0
    void SpawnLevel()
    {
        System.DateTime startTime = System.DateTime.Now;
        ClearLevel();

        //Build Level Geometry
        foreach (int height in loadedLevel.map.mapLayers.Keys)
        {
            MapLayer layer = loadedLevel.map.mapLayers[height];
            for (int x = 0; x < layer.tiles.GetLength(0); x++)
            {
                for (int z = 0; z < layer.tiles.GetLength(1); z++)
                {
                    if (layer.tiles[x, z] == null)
                    {
                        continue;
                    }

                    GameObject tileGO = new GameObject("Tile (" + x + "," + z + ", L" + height + ")");
                    tileGO.transform.SetParent(transform);
                    TileRenderer tileRend = (TileRenderer)tileGO.AddComponent(layer.tiles[x, z].renderer);
                    tileRend.LoadFromMap(loadedLevel.map, new IntVec(x, z, height));
                }
            }
        }

        Debug.Log("Spawned level \"" + loadedLevel.name + "\" geometry in " + System.DateTime.Now.Subtract(startTime).TotalMilliseconds + "ms");
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        if (instance != null)
        {
            Debug.LogError("Warning someone tried to create a new TileRenderer instance even though one already exists! (Use TileRenderer.instance instead)");
            return;
        }
        instance = this;

        previousSelectedTileMaterial = defaultTileMaterial;
        List <VRAR_Level> lvls = lvlManager.getVRARLevels();

        if (lvls.Count == 0)
        {
            Debug.LogWarning("Trying to spawn lvls overview but none seem to be loaded.\nPossibly this script (TileRenderer) is loaded before the LevelManager script.\nYou can change the order in Unity editor: Edit -> Project Settings -> Script Execution Order + LevelManager + TileRenderer and make sure TileRenderer is below LevelManager");
        }
        else
        {
            Debug.Log("thing :" + GameStateManager.instance.getGlobalStateIndex());
            if (GameStateManager.instance.getGlobalStateIndex() == GameStateManager.STATE_CAMPAIGN_EDITOR)
            {
                Debug.Log("EDITOR");
                spawnLevelsOverview();
            }
            else if (GameStateManager.instance.getGlobalStateIndex() == GameStateManager.STATE_PLAYING)
            {
                Debug.Log("PLAY");
                selectedTiles.Add(GameStateManager.instance.getCurrentLevel().levelTile);
                spawnLevel();
            }
        }
    }
Ejemplo n.º 3
0
 void Awake()
 {
     tilemap             = GameManager.Instance.tilemap;
     arenaTilesPositions = GameManager.Instance.arenaTilesPositions;
     playerTag           = GetComponentInParent <Player>().playerTag;
     tileRenderer        = GetComponentInParent <Player>().tileRenderer;
 }
Ejemplo n.º 4
0
 private void Awake()
 {
     TileTrigger = GetComponentInChildren<TileTrigger>();
     m_Renderer = GetComponent<TileRenderer>();
     m_Renderer.Settings = m_Settings;
     m_OnMouseExit = new UnityEvent();
     m_OnMouseOver = new UnityEvent();
 }
        public GameStateRenderer(GameState state)
        {
            _state = state;
            _gl    = state.Manager.Game.Gl;

            _tileRenderer         = new TileRenderer(this);
            _texturedQuadRenderer = new TextureQuadRenderer(_state.Manager.Game, _gl);
        }
Ejemplo n.º 6
0
 void Start()
 {
     status     = GetComponent <TileStatus>();
     renderer   = GetComponent <TileRenderer>();
     graphData  = GetComponent <TileGraphData>();
     searchData = GetComponent <TileUCSData>();
     AStarData  = GetComponent <TileAStarData>();
 }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        GameData.AdventureManager = this;

        tileRenderer           = gameObject.GetComponent <TileRenderer>();
        textHandler            = gameObject.GetComponent <TextHandler>();
        actionPointHandler     = gameObject.GetComponent <ActionPointHandler>();
        simpleEncounterHandler = gameObject.GetComponent <SimpleEncounterHandler>();
    }
Ejemplo n.º 8
0
    void Awake()
    {
        _stageLifetimes = new float[] {
            Random.Range(MinStageLifetime, MaxStageLifetime),
            Random.Range(MinStageLifetime, MaxStageLifetime),
            Random.Range(MinStageLifetime, MaxStageLifetime)
        };

        _tileRenderer = GetComponent <TileRenderer>();
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Draws the tile at zoom level <paramref name="zoomLevel"/> with the tile coordinate <paramref name="tileX"/>/<paramref name="tileZ"/>.
        /// </summary>
        /// <param name="zoomLevel">Zoom level of the tile, with 0 being the closest zoom available.</param>
        /// <param name="tileX">X-coordinate of the tile.</param>
        /// <param name="tileZ">Z-coordinate of the tile.</param>
        internal void DrawMap(int zoomLevel, int tileX, int tileZ)
        {
            // Closest zoom means at the moment 1px = 1 block
            if (zoomLevel == 0)
            {
                // Create a new bitmap
                int tileSizeX = Math.Min(TileSize, BlockProvider.DimensionX - tileX * TileSize);
                int tileSizeZ = Math.Min(TileSize, BlockProvider.DimensionZ - tileZ * TileSize);

                if (tileSizeX <= 0 || tileSizeZ <= 0)
                {
                    throw new ArgumentException("Tile is out of bounds");
                }

                // Create the bitmap
                using (var bmp = new Bitmap(TileSize, TileSize))
                {
                    for (int x = 0; x < tileSizeX; ++x)
                    {
                        for (int z = 0; z < tileSizeZ; ++z)
                        {
                            var tile = BlockProvider.GetTopBlock(x + tileX * TileSize, z + tileZ * TileSize);
                            bmp.SetPixel(x, z, TileRenderer.GetColor(tile));
                        }
                    }

                    TileRenderer.SaveBitmap(GetTileName(zoomLevel, tileX, tileZ), bmp);
                }
            }
            else
            {
                List <Image> bitmaps = new List <Image>();

                using (var bitmap = new Bitmap(TileSize, TileSize))
                    using (var graphics = Graphics.FromImage(bitmap))
                    {
                        for (int dx = 0; dx <= 1; ++dx)
                        {
                            for (int dz = 0; dz <= 1; ++dz)
                            {
                                var previousBitmap = TileRenderer.LoadBitmap(GetTileName(zoomLevel, tileX * 2 + dx, tileZ * 2 + dz));
                                if (previousBitmap != null)
                                {
                                    bitmaps.Add(previousBitmap);
                                    graphics.DrawImage(previousBitmap, 0, 0);
                                }
                            }
                        }

                        TileRenderer.SaveBitmap(GetTileName(zoomLevel, tileX, tileZ), bitmap);
                    }

                bitmaps.ForEach(i => i.Dispose());
            }
        }
Ejemplo n.º 10
0
 private void Awake()
 {
     m_OnMouseOver       = new UnityEvent();
     m_OnMouseExit       = new UnityEvent();
     m_OnLock            = new UnityEvent();
     m_OnStart           = new UnityEvent();
     m_Renderer          = GetComponent <TileRenderer>();
     m_Renderer.Settings = m_Settings;
     m_FaceManager       = GetComponent <FaceManager>();
     m_Events            = GetComponentsInChildren <TileEventsDatas>();
 }
Ejemplo n.º 11
0
 void CreateRenderers(int additionalRendererCount)
 {
     for (int i = 0; i < additionalRendererCount; i++)
     {
         GameObject go = Instantiate(tileRendererPrefab);
         go.transform.SetParent(transform);
         TileRenderer tr = go.GetComponent <TileRenderer>();
         tr.SetVisible(false);
         freeRenderers.Enqueue(tr);
     }
 }
Ejemplo n.º 12
0
    void DeactivateRenderer(Coordinate coordinate, WorldLayer layer)
    {
        Dictionary <Coordinate, TileRenderer> renderDict = GetDictionary(layer);

        if (renderDict.ContainsKey(coordinate))
        {
            TileRenderer tr = renderDict[coordinate];
            renderDict.Remove(coordinate);
            tr.SetVisible(false);
            freeRenderers.Enqueue(tr);
        }
    }
Ejemplo n.º 13
0
    void Init()
    {
        rooms = new List <Room>();
        tiles = new TileType[mapSize.y][];

        for (int i = 0; i < mapSize.y; i++)
        {
            tiles[i] = new TileType[mapSize.x];
        }

        tileRenderer      = new TileRenderer(rooms);
        visibilityManager = VisibilityManager.GetInstance();
    }
Ejemplo n.º 14
0
    TileRenderer GetRenderer(Coordinate coordinate, WorldLayer layer)
    {
        Dictionary <Coordinate, TileRenderer> renderDict = GetDictionary(layer);

        if (renderDict.ContainsKey(coordinate))
        {
            return(renderDict[coordinate]);
        }
        else
        {
            TileRenderer tr = GetFreeRenderer();
            renderDict.Add(coordinate, tr);
            return(tr);
        }
    }
Ejemplo n.º 15
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="tileSize">Size of a each tile, in pixels.</param>
        /// <param name="tileCount">Number of tiles on the tile board.</param>
        /// <param name="tilemapSize">Size of the tilemaps images to be loaded with <see cref="SetTilemap(int, string)"/>, in pixels.</param>
        public OneBitOfGame(Dimension tileSize, Dimension tileCount, Dimension tilemapSize)
        {
            OpenTKWindow = new OpenTKWindow(this)
            {
                Title = ""
            };

            Files    = new FileSystem();
            Renderer = new TileRenderer(Files, tileSize, tileCount, tilemapSize);
            Audio    = new AudioPlayer(Files);
            Sprites  = new SpriteManager();

            UI    = new UIEnvironment(this);
            Input = new InputManager(this);
        }
Ejemplo n.º 16
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            TileRenderer myScript = (TileRenderer)target;

            if (GUILayout.Button("Re-Render"))
            {
                myScript.Build(GameManager.Instance.Game.CurrentLevel);
            }
            if (GUILayout.Button("Copy Coodinates"))
            {
                TextEditor te = new TextEditor {
                    text = string.Format("X=\"{0}\" Z=\"{1}\"", myScript.X, myScript.Z)
                };
                te.SelectAll();
                te.Copy();
            }

            GUILayout.Label("Heigth");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("h++"))
            {
                myScript.OverideTileHeigth++;
                myScript.Build(GameManager.Instance.Game.CurrentLevel);
            }
            if (GUILayout.Button("h--"))
            {
                myScript.OverideTileHeigth--;
                myScript.Build(GameManager.Instance.Game.CurrentLevel);
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Model");
            GUILayout.BeginVertical();
            var allTiles = PrefabManager.Instance.TilePrefabs;

            for (var index = 0; index < allTiles.Count; index++)
            {
                var tile = allTiles[index];
                if (GUILayout.Button(tile.name))
                {
                    myScript.OverideTileId = index;
                    myScript.Build(GameManager.Instance.Game.CurrentLevel);
                }
            }
            GUILayout.EndVertical();
        }
Ejemplo n.º 17
0
    // Load Prefab references.
    //void Awake() {
    //    tileRendererPrefab = (GameObject)Resources.Load("/Prefabs/TileRenderer");
    //}

    // Use this for initialization
    void Start()
    {
        mapGraphPrefab     = (GameObject)Resources.Load("Prefabs/MapGraph");
        tileRendererPrefab = (GameObject)Resources.Load("Prefabs/TileRenderer");
        alphaWalkPrefab    = (GameObject)Resources.Load("Prefabs/AlphaWalk");

        for (int col = 0; col < COL_COUNT; col++)
        {
            List <TileData> rowData = new List <TileData>();
            for (int row = 0; row < ROW_COUNT; row++)
            {
                //TileKind k = (rand(0, 7) > 1) ? TileKind.GROUND : TileKind.HALF_GROUND;
                TileKind k = TileKind.GROUND;

                if (row % 2 != 0)
                {
                    k = TileKind.HALF_GROUND;
                }

                Vector3  worldPos = new Vector3(col, 0, row);
                TileData td       = new TileData(worldPos, k);

                rowData.Add(td);
            }
            testMap.AddRange(rowData);
        }

        GameObject tileContainer = new GameObject();

        tileContainer.name = "TilesContainer";

        mapGraph = InitMapGraph();

        // probably an unnecessary loop
        foreach (TileData td in testMap)
        {
            Tile         tile         = new Tile(td.kind, td.worldPos);
            TileRenderer tileRenderer = Instantiate(tileRendererPrefab)
                                        .GetComponent <TileRenderer>();

            tileRenderer.SetTile(tile);
            tileRenderer.transform.SetParent(tileContainer.transform);

            mapGraph.AddNode(tile.WorldPosition, tile.Kind);
        }
        mapGraph.FinalizeMap();
        FinalizeMapGraph();
    }
Ejemplo n.º 18
0
    // Use this for initialization
    private void Start()
    {
        texture              = new Texture2D(sizeX, sizeY, TextureFormat.RGBA32, false);
        texture.filterMode   = FilterMode.Point;
        TileRenderer         = GetComponentInParent <TileRenderer>();
        TileRenderer.OnSwap += OnSwap;

        gameObject.AddComponent <SpriteRenderer>().sprite = Sprite.Create(texture, new Rect(
                                                                              0,
                                                                              0,
                                                                              130,
                                                                              80),
                                                                          new Vector2(0.5f, 0.5f),
                                                                          1
                                                                          );
    }
Ejemplo n.º 19
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            _rootViewController = new UIViewController();

            //
            // Create the root view
            //
            _worldView = new WorldView(window.Bounds)
            {
                ShowSun = false,
            };
            _rootViewController.View.AddSubview(_worldView);
            window.RootViewController = _rootViewController;
            _worldView.Run(4);

            //
            // Add a layer of tiles
            //
            var tiles       = new TileRenderer();
            var sourceIndex = 0;

            tiles.Source = _tileSources[sourceIndex];
            _worldView.AddDrawable(tiles);

            //
            // Add a button to toggle tile sources
            //
            var toggle = new UIButton(new RectangleF(0, 450, 120, 30));

            toggle.Font = UIFont.BoldSystemFontOfSize(14);
            toggle.SetTitle(_tileSources[0].Name, UIControlState.Normal);
            toggle.SetTitleColor(UIColor.Black, UIControlState.Normal);
            toggle.TouchUpInside += delegate {
                sourceIndex = (sourceIndex + 1) % _tileSources.Length;
                toggle.SetTitle(_tileSources[sourceIndex].Name, UIControlState.Normal);
                tiles.Source = _tileSources[sourceIndex];
            };
            window.AddSubview(toggle);

            window.MakeKeyAndVisible();

            return(true);
        }
Ejemplo n.º 20
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Debug.Log("Warning: multiple " + this + " in scene!");
            DestroyImmediate(this.gameObject);
            return;
        }

        Debug.Log("Made a new GameManager");
        DontDestroyOnLoad(Instance);

        gameObject.AddComponent <GamePlayManagerAR>();
        levelManager = gameObject.AddComponent <LevelManager>();
        tileRenderer = gameObject.AddComponent <TileRenderer>();
    }
Ejemplo n.º 21
0
        /*
         * def parse (self, fields, path, host):
         *      param = {}
         *      for key in ['bbox', 'layers', 'request', 'version']:
         *              if fields.has_key(key.upper()):
         *                      param[key] = fields[key.upper()]
         *              elif fields.has_key(key):
         *                      param[key] = fields[key]
         *              else:
         *                      param[key] = ""
         *      if param["request"] == "GetCapabilities":
         *              return self.getCapabilities(host + path, param)
         *      else:
         *              return self.getMap(param)
         */
        #endregion
        public void ProcessRequest(IHttpContext context)
        {
            var requestParams = context.Request.Params;

            //NameValueCollection requestParams, string pathInfo, string host
            if ("GetCapabilities".Equals(requestParams["request"], StringComparison.OrdinalIgnoreCase))
            {
                //TODO: Get host and pathInfo
                var host         = "dummy-host";
                var pathInfo     = "dummy-path-info";
                var capabilities = GetCapabilities(host + pathInfo);
                context.Response.ContentType = capabilities.Format;
                context.Response.Write(capabilities.Data);
                return;
            }

            var  forceParam = requestParams["force"];
            bool force      = !string.IsNullOrEmpty(forceParam) && forceParam == "true";

            TileRenderer.RenderTile(context.Response, GetMap(requestParams), force);
            //return this.GetMap(requestParams);
        }
Ejemplo n.º 22
0
    public static Dictionary <string, Sprite> GetSprites(TileData tileData)
    {
        Dictionary <string, Sprite> sprites   = new Dictionary <string, Sprite>();
        AutoTileAnimated            animation = tileData.GetModifierOfType <AutoTileAnimated>() as AutoTileAnimated;

        if (animation != null)
        {
            for (int i = 0; i < animation.frames; ++i)
            {
                foreach (TerrainBrush.TileType tileType in Enum.GetValues(typeof(TerrainBrush.TileType)))
                {
                    sprites[tileData.Name + tileType.ToString("") + i] = GetTileSprite(tileData.Name + tileType.ToString("") + i);
                }
            }
            return(sprites);
        }
        AutoTile autoTile = tileData.GetModifierOfType <AutoTile>() as AutoTile;

        if (autoTile != null)
        {
            foreach (TerrainBrush.TileType tileType in Enum.GetValues(typeof(TerrainBrush.TileType)))
            {
                sprites[tileData.Name + tileType.ToString("")] = GetTileSprite(tileData.Name + tileType.ToString(""));
            }
            return(sprites);
        }
        TileRenderer renderer = tileData.GetModifierOfType <TileRenderer>() as TileRenderer;

        if (renderer != null)
        {
            for (int i = 0; i < renderer.tileAmounts; ++i)
            {
                sprites[tileData.Name + i] = GetTileSprite(tileData.Name + i);
            }
            return(sprites);
        }
        return(null);
    }
Ejemplo n.º 23
0
    void UpdateTiles()
    {
        foreach (GameObject tileObject in board.gridFaces)
        {
            if (tileObject != null)
            {
                TileRenderer tileRenderer = tileObject.GetComponent <TileRenderer>();

                if (tileRenderer != null)
                {
                    tileRenderer.noneTile     = tileSets[tileSetSelection].noneTile;
                    tileRenderer.forestTile   = tileSets[tileSetSelection].forestTile;
                    tileRenderer.hillTile     = tileSets[tileSetSelection].hillTile;
                    tileRenderer.meadowTile   = tileSets[tileSetSelection].meadowTile;
                    tileRenderer.mountainTile = tileSets[tileSetSelection].mountainTile;
                    tileRenderer.fieldTile    = tileSets[tileSetSelection].fieldTile;
                    tileRenderer.desertTile   = tileSets[tileSetSelection].desertTile;

                    tileRenderer.UpdateTileObject();
                }
            }
        }
    }
Ejemplo n.º 24
0
 /// <summary>
 /// (Internal) Called before the first game loop. Creates the VBO.
 /// </summary>
 /// <param name="renderer">The tile renderer to use to draw the sprites VBO</param>
 internal void OnLoad(TileRenderer renderer)
 {
     SpriteVBO = new VBO(renderer, 0, 0);
     Viewport_ = new Area(Position.Zero, renderer.TileCount);
     BeginNewSprite();
 }
Ejemplo n.º 25
0
    void Update()
    {
        //Debug.Log(brushTicking);
        if (brushTicking && GameStateManager.instance.getGlobalStateIndex() == GameStateManager.STATE_LEVEL_EDITOR)
        {
            if (brushTickDivider-- == 0)
            {
                brushTickDivider = 4;
                //VRAR_Level lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position));
                VRAR_Level lvl = TileRenderer.getCurrLVL();

                VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y);
                if (tile != null)
                {
                    currentlySelected = tile;
                    List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize);
                    if (!menuOpen)
                    {
                        OpenTileProperties(tile);
                        menuOpen = true;
                    }
                    //resetPrevous.Clear();
                    // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position).x, lvlManager.getTilePosFromWorldPos(leftHandCursor.position).y));
                    foreach (VRAR_Tile surroundTile in effectedTiles)
                    {
                        if (surroundTile != null)
                        {
                            switch (brushActionDropdown.value)
                            {
                            case 0:
                                if (surroundTile.height_ < maxTileHeight)
                                {
                                    surroundTile.setHeight(surroundTile.height_ + 0.05f);
                                    //Debug.Log(surroundTile);
                                }
                                //else { surroundTile.setHeight(minTileHeight); }
                                break;

                            case 1:
                                if (surroundTile.height_ > minTileHeight)
                                {
                                    surroundTile.setHeight(surroundTile.height_ - 0.05f);
                                }
                                //else { surroundTile.setHeight(maxTileHeight); }
                                break;

                            case 2:
                                if (surroundTile.hexObject != null)
                                {
                                    //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.defaultTileMaterial;
                                    surroundTile.SetTerrain("Mountain");
                                    TileRenderer.instance.updateTile(surroundTile);
                                }
                                break;

                            case 3:
                                if (surroundTile.hexObject != null)
                                {
                                    //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.waterTileMaterial;
                                    surroundTile.SetTerrain("Water");
                                    TileRenderer.instance.updateTile(surroundTile);
                                }
                                break;

                            case 4:
                                if (surroundTile.hexObject != null)
                                {
                                    //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.selectedTileMaterial;
                                    surroundTile.SetTerrain("Grass");
                                    TileRenderer.instance.updateTile(surroundTile);
                                }
                                break;
                            }
                        }
                        else
                        {
                            Debug.Log("sur was null");
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 26
0
 /// <summary>
 /// (Internal) Called before the first game loop. Creates the VBO.
 /// </summary>
 /// <param name="renderer">The tile renderer to use to draw the cursor VBO</param>
 internal void OnLoad(TileRenderer renderer)
 {
     CursorVBO    = new VBO(renderer, 1, 1);
     BoundingBox_ = new Area(Position.Zero, renderer.TileCount);
     UpdateCursor();
 }
Ejemplo n.º 27
0
 public Tile setTextureCoords(int x, int y)
 {
     this.Renderer = new TileRenderer(x, y);
     return(this);
 }
Ejemplo n.º 28
0
 private void Awake()
 {
     TileRenderer._instance = this;
 }
        public void TestRenderTileRendersAllTiles(int paletteIndex, string fileToCompare)
        {
            var romData = new ROMData();

            romData.Data[ROMs.PAC_MAN_COLOR.FileName]   = VideoHardwareTestData.COLOR_ROM;
            romData.Data[ROMs.PAC_MAN_PALETTE.FileName] = VideoHardwareTestData.PALETTE_ROM;
            romData.Data[ROMs.PAC_MAN_TILE.FileName]    = null;
            romData.Data[ROMs.PAC_MAN_SPRITE.FileName]  = null;

            var video = new VideoHardware(romData);

            video.InitializeColors();
            video.InitializePalettes();

            var tileRenderer = new TileRenderer(VideoHardwareTestData.TILE_ROM, video._palettes);

            // There are 256 tiles, so we can render a grid of 16x16 tiles.
            // Each tile is 8x8 pixels.
            var width  = 16 * 8;
            var height = 16 * 8;

            // Holds the (x, y) coordinates of the origin (top/left) of the location
            // to render the next tile.
            var tileOriginX = 0;
            var tileOriginY = 0;

            // The image we'll be rendering all the tiles to.
            var image = new Image <Rgba32>(width, height);

            // Render each of the 256 tiles.
            for (var tileIndex = 0; tileIndex < 256; tileIndex++)
            {
                // Render the tile with the given color palette.
                var tile = tileRenderer.RenderTile(tileIndex, paletteIndex);

                // Copy the rendered tile over into the full image.
                for (var y = 0; y < 8; y++)
                {
                    for (var x = 0; x < 8; x++)
                    {
                        image[tileOriginX + x, tileOriginY + y] = tile[x, y];
                    }
                }

                if ((tileIndex + 1) % 16 == 0)
                {
                    // Row is finished, wrap back around.
                    tileOriginX  = 0;
                    tileOriginY += 8;
                }
                else
                {
                    // Next column.
                    tileOriginX += 8;
                }
            }

            // Assert: the rendered image should be the same as the reference image.

            byte[] actualBytes = null;

            using (var steam = new MemoryStream())
            {
                image.Save(steam, new BmpEncoder());
                actualBytes = steam.ToArray();
            }

            var expectedBytes = File.ReadAllBytes($"../../../ReferenceData/{fileToCompare}");

            Assert.Equal(expectedBytes, actualBytes);
        }
Ejemplo n.º 30
0
    void Awake()
    {
        _stageLifetimes = new float[] {
            Random.Range (MinStageLifetime, MaxStageLifetime),
            Random.Range (MinStageLifetime, MaxStageLifetime),
            Random.Range (MinStageLifetime, MaxStageLifetime)
        };

        _tileRenderer = GetComponent<TileRenderer>();
    }
Ejemplo n.º 31
0
    void Update()
    {
        if (brushTicking)
        {
            if (brushTickDivider-- == 0)
            {
                brushTickDivider = 4;
                //VRAR_Level lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(ingameCursor.position));
                VRAR_Level lvl = TileRenderer.getCurrLVL();

                VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y);
                if (tile != null)
                {
                    List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize);

                    //resetPrevous.Clear();
                    // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y));
                    foreach (VRAR_Tile surroundTile in effectedTiles)
                    {
                        if (surroundTile != null)
                        {
                            switch (brushActionDropdown.value)
                            {
                            case 0:
                                if (surroundTile.height_ < maxTileHeight)
                                {
                                    surroundTile.setHeight(surroundTile.height_ + 0.05f);
                                    //Debug.Log(surroundTile);
                                }
                                //else { surroundTile.setHeight(minTileHeight); }
                                break;

                            case 1:
                                if (surroundTile.height_ > minTileHeight)
                                {
                                    surroundTile.setHeight(surroundTile.height_ - 0.05f);
                                }
                                //else { surroundTile.setHeight(maxTileHeight); }
                                break;

                            case 2:
                                if (surroundTile.hexObject != null)
                                {
                                    surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.defaultTileMaterial;
                                }
                                break;

                            case 3:
                                if (surroundTile.hexObject != null)
                                {
                                    surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.waterTileMaterial;
                                }
                                break;

                            case 4:
                                if (surroundTile.hexObject != null)
                                {
                                    surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.selectedTileMaterial;
                                }
                                break;
                            }
                        }
                        else
                        {
                            Debug.Log("sur was null");
                        }
                    }
                }
            }
        }
    }