// Update is called once per frame public void DisplayVictory(TileSprite winner) { victoryText.enabled = true; victoryPanel.enabled = true; newGameBtn.gameObject.SetActive(true); string winnerStr; Color victoryColor; if (winner == TileSprite.SPRITE_YELLOW) { winnerStr = "yellow"; victoryColor = Color.yellow; } else { winnerStr = "red"; victoryColor = Color.red; } victoryColor.a = panelAlpha; victoryPanel.color = victoryColor; victoryText.text = "Winner is " + winnerStr; }
public EditorPage() { InitializeComponent(); _screen = App.ChangeScreen <EditorScreen>(); _prevPoint = null; Objectives = _screen.Objectives.Objectives; ObjectTypes = new List <string>(); BuildObjTypeList(); _gameGrid = new Graphics.Grid(Vector3.Zero, 32); _selected = null; _offset = Vector3.Zero; DeleteModeCombo.Items.Add(ObjectType.Object); DeleteModeCombo.Items.Add(ObjectType.Road); DeleteModeCombo.Items.Add(ObjectType.Zone); DeleteModeCombo.SelectedIndex = 0; var roadMapEntity = _screen.CreateEntity("RoadMap", 0, 0, 1); _roadSprite = roadMapEntity.AddComponent <TileSprite>(); _roadSprite.Load(_screen.Cache, "ms-appx:///Data/Road.map"); _roadSprite.Origin = TileSprite.OriginLocation.TopLeft; AddObjectives(); _pointerDown = false; DataContext = this; }
public Tile(int id, TileSprite sprite) { Id = id; Sprite = sprite; if (Sprite.Count == 0) Sprite.AddFrame(); Properties = TileProperties.Default; }
public override void OnInspectorGUI() { base.OnInspectorGUI (); myTarget = (target as TileSprite); Draw(); }
void Start() { var spritedata = File.ReadAllText("assets/spritedata.json"); TileSprites = JsonConvert.DeserializeObject <List <TileSprite> >(spritedata); var sprite = GetTileSprite("teen"); Debug.Log("test_" + sprite.Name); defaultTileSprite = GetTileSprite(DefaultTileTypeName); Tiles = new Tile[Width, Heigth]; for (var x = 0; x < Width; x++) { for (var y = 0; y < Heigth; y++) { var tile = new Tile(this, "tile-" + x + "_" + y, defaultTileSprite, new Vector2(x, y), TileContainer); Tiles[x, y] = tile; } } Tiles[0, 0].GetNeighbors(); for (var i = 0; i < 100; i++) { var character = new Character(new Vector2(random.Next(0, Width - 1), random.Next(0, Heigth - 1)), GetTileSprite("teen"), this); Characters.Add(character); character.TargetPosition = new Vector2(random.Next(0, Width - 1), random.Next(0, Heigth - 1)); } }
private void SetTiles() // it shoult be noted that the map is generated upside down so some values dont matched their intended image ** { // var index = 0; for (var y = 0; y < MapSize.y - 1; y++) { for (var x = 0; x < MapSize.x - 1; x++) { string sourceFilePath = @"C:\Users\Dagon\Documents\Visual Studio 2017\Projects\csv\csv\bin\Debug\file.txt"; var item = File.ReadAllText(sourceFilePath); var nitem = item.Split(','); int xcord = (y * ((int)MapSize.x - 1)) + x; var tim = nitem[xcord]; System.Int32.TryParse(tim, out index); if (index == 4) { index = AssembleRoad(nitem, xcord, index); } else if (index == 5) { index = AssembleRiver(nitem, xcord, index); } _map[x, y] = new TileSprite(TileSprites[index].Name, TileSprites[index].TileImage, TileSprites[index].TileType); } } }
public TileMap(Vector2 pos, string mapPath, string tileset) { Pos = pos; var map = new TiledSharp.TmxMap(mapPath); var texture = tileset; foreach (var layer in map.Layers) { foreach (var tile in layer.Tiles) { if (tile.Gid == 0) { continue; } var t = new TileSprite { Pos = new Vector2(tile.X * map.TileWidth, tile.Y * map.TileHeight), MapPos = new Point(tile.X, tile.Y), Size = new Point(map.TileWidth, map.TileHeight), TexturePath = texture, Id = tile.Gid }; AddChild(t); } } Size = new Point(map.Width * map.TileWidth, map.Height * map.TileHeight); }
private void generateTiles(int x, int y, int tID) { TileSprite tSprite = new TileSprite(tileSprites[tID].tName, tileSprites[tID].tImage, tileSprites[tID].tType); _map [x, (int)mapSize.y - y] = tSprite; }
public void SetTile(int index, TileSprite sprite) { if (sprites == null) { sprites = new TileSprite[Data.Length]; } this.sprites[index] = sprite; }
public void AddToLookup(EdgeLookupType edgeLookup, string edgeSample, TileSprite tileProp) { if (!edgeLookup.ContainsKey(edgeSample)) { edgeLookup.Add(edgeSample, new List <TileSprite>()); } edgeLookup[edgeSample].Add(tileProp); }
public Tileset Load(FilePath path) { var tileset = new Tileset(); tileset.FilePath = path; var doc = XDocument.Load(path.Absolute); var reader = doc.Element("Tileset"); if (reader == null) throw new Exception("The specified tileset definition file does not contain a Tileset tag."); var sheetPath = FilePath.FromRelative(reader.Attribute("tilesheet").Value, path.BasePath); tileset.ChangeSheetPath(sheetPath.Absolute); int size; if (!int.TryParse(reader.Attribute("tilesize").Value, out size)) throw new Exception("The tileset definition does not contain a valid tilesize attribute."); tileset.TileSize = size; var propParent = reader.Element("TileProperties"); if (propParent != null) { foreach (XElement propNode in propParent.Elements("Properties")) { var prop = new TileProperties(propNode); tileset.AddProperties(prop); } } foreach (XElement tileNode in reader.Elements("Tile")) { int id = int.Parse(tileNode.Attribute("id").Value); string name = tileNode.Attribute("name").Value; var spriteNode = tileNode.Element("Sprite"); if (spriteNode == null) throw new GameXmlException(tileNode, "All Tile tags must contain a Sprite tag."); var sprite = LoadSprite(spriteNode); var tileSprite = new TileSprite(tileset, sprite); Tile tile = new Tile(id, tileSprite); string propName = "Default"; XAttribute propAttr = tileNode.Attribute("properties"); if (propAttr != null) propName = propAttr.Value; tile.Properties = tileset.GetProperties(propName); tile.Sprite.Play(); tileset.Add(tile); } return tileset; }
public Tile(int id, TileSprite sprite) { Id = id; Sprite = sprite; if (Sprite.Count == 0) { Sprite.AddFrame(); } Properties = TileProperties.Default; }
// Used to create default tiles // Not used currently cause I only want tiles that the map // wants has specified to spawn private void defaultTiles() { for (int y = 0; y < mapSize.y; y++) { for (int x = 0; x < mapSize.x; x++) { _map [x, y] = new TileSprite("Unset", defaultImage, Tiles.Unset); } } }
//set the default tiles in the view void DefaultTiles() { for (int y = 0; y < MapSize.y; y++) { for (int x = 0; x < MapSize.x; x++) { _map [x, y] = new TileSprite("unset", DefaultImage, Tiles.Unset); } } }
private void DefaultTiles() { for (var y = 0; y < MapSize.y - 1; y++) { for (var x = 0; x < MapSize.x - 1; x++) { _map[x, y] = new TileSprite("unset", DefaultImage, Tiles.Unset); } } }
public TileSprite[] GetTile(int tilex, int tiley, LayerType type) { Layer[] layers = GetLayerByType(type); TileSprite[] sprites = new TileSprite[layers.Length]; for (int i = 0; i < layers.Length; i++) { sprites[i] = layers[i][tilex, tiley]; } return(sprites); }
public TileSprite[] GetTile(float pixelx, float pixely, LayerType type) { Layer[] layers = GetLayerByType(type); TileSprite[] sprites = new TileSprite[layers.Length]; for (int i = 0; i < layers.Length; i++) { sprites[i] = layers[i][pixelx, pixely]; } return(sprites); }
public void ChangeSprite(TileSprite tileSprite) { int spriteIdx = (int)tileSprite; if (spriteIdx < 0 || spriteIdx >= sprites.Length) { return; } currentSprite = spriteIdx; gameObject.GetComponent <SpriteRenderer>().sprite = sprites[spriteIdx]; }
//Create and return a new Sprite of index i public TileSprite setTile(int i) { TileSprite t = new TileSprite(TileSprites[i].Name, TileSprites[i].tileImage, TileSprites[i].tileType, TileSprites[i].rounded, TileSprites[i].consumable, TileSprites[i].explosive); t.frameNum = Frame; return(t); }
private void _cullSpritesForLights(Light light) { if (!light.IsStatic) { return; } List <Sprite> sprites = Sprites; float xmin = light.X - (light.Radius); float xmax = light.X + (light.Radius); float ymin = light.Y - (light.Radius); float ymax = light.Y + (light.Radius); foreach (Sprite sprite in sprites) { if (!sprite.IsStatic) { continue; } lock (sprite.light_lock) { if (sprite.X + (sprite.Width / 2f) >= xmin && sprite.X - (sprite.Width / 2f) <= xmax && sprite.Y + (sprite.Height / 2f) >= ymin && sprite.Y - (sprite.Height / 2f) <= ymax) { sprite.Lights.Add(light); } } } foreach (Layer layer in Layers) { if (!layer.IsTileLayer) { continue; } for (float x = xmin; x < xmax; x += 16) { for (float y = ymin; y < ymax; y += 16) { TileSprite sprite = layer[x, y]; //TileSprites are always static if (sprite == null || sprite.Lights.Contains(light)) { continue; } lock (sprite.light_lock) { sprite.Lights.Add(light); } } } } }
public override void Create() { world = game.world; game.time.slowMotion = 2.0; view = game.camera.view; space = game.add.tileSprite(0, 0, view.width, view.height, "space"); space.fixedToCamera = true; ship = game.add.sprite(250, game.height - 270, "ship"); ship.angle = -68; ship.anchor.set(0.5); game.physics.enable(ship, Physics.ARCADE); game.physics.arcade.gravity.y = 37.1; var shipBody = (Physics.Arcade.Body)ship.body; //shipBody.angularDrag = 100; //shipBody.bounce.setTo(1); //shipBody.drag.set(10); shipBody.friction.setTo(0); shipBody.maxVelocity.set(150); //debugText = game.add.text(10, 10, "" , new { font = "34px Arial", fill = "#fff" }); konumText = game.add.text(10, 10, "", new { font = "18px Arial", fill = "#fff" }); aciText = game.add.text(10, 40, "", new { font = "18px Arial", fill = "#fff" }); hizText = game.add.text(10, 70, "", new { font = "18px Arial", fill = "#fff" }); ivmeText = game.add.text(10, 100, "", new { font = "18px Arial", fill = "#fff" }); ground = new Phaser.Polygon(new Phaser.Point(0, 300), new Phaser.Point(0, 290), new Phaser.Point(100, 250), new Phaser.Point(150, 150), new Phaser.Point(300, 200), new Phaser.Point(400, 285), new Phaser.Point(550, 285), new Phaser.Point(699, 220), new Phaser.Point(699, 300) ); var graphics = game.add.graphics(0, 0); graphics.beginFill(0xFF33ff); graphics.drawPolygon(ground.points); graphics.endFill(); motor = 40; keyboard = game.input.keyboard; cursors = keyboard.createCursorKeys(); }
public Character(Vector2 startPosition, TileSprite tileSprite, TileEngine tileEngine) { TileEngine = tileEngine; TileSprite = tileSprite; GameObject = new GameObject("character"); spriteRenderer = GameObject.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer; spriteRenderer.sprite = TileSprite.Sprite; spriteRenderer.color = new Color(1f, 1f, 1f, 1f); spriteRenderer.sortingOrder = 1; GameObject.transform.position = startPosition; TargetPosition = startPosition; NextPosition = startPosition; }
private void FulfilTileMap() { int width = (int)mapSize.x; int height = (int)mapSize.y; int [,] tiles = currentChunk.getFinalTiles(); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { _map[x, y] = new TileSprite(sprites[tiles[x, y]]); } } }
public Furniture(Tile tile, TileSprite tileSprite, GameObject FurnitureContainer, int width = 1, int height = 1) { this.tileSprite = tileSprite; Width = width; Height = height; GameObject = new GameObject(tile.TileName + "_" + tileSprite.FullName); this.tileSprite = tileSprite; spriteRenderer = GameObject.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer; spriteRenderer.sprite = tileSprite.Sprite; spriteRenderer.color = new Color(1f, 1f, 1f); GameObject.transform.parent = FurnitureContainer.transform; SetPosition(tile.Position); }
public void Build(TileSprite newSprite) { NewSpirte = newSprite; if (newSprite.Name != tileSprite.Name) { if (newSprite.Type == ObjectType.Wall) { BuildWall(); } else { ChangeTileSprite(newSprite); CheckNextTo(); } } }
void Start() { holder = GetComponent <TileHolder> (); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { TileSprite s = Instantiate(prefab); s.transform.SetParent(this.transform); s.transform.localScale = Vector3.one; s.transform.GetComponent <RectTransform>().anchoredPosition = new Vector2(j * 64, 0 - i * 64); s.spriteNum = j + i * 32; s.btn.image.sprite = holder.sprites [s.spriteNum]; s.btn.image.SetNativeSize(); } } }
protected override void OnResumeDisplay() { foreach (Layer layer in Layers) { if (layer.IsTileLayer) { for (int i = 0; i < layer.Data.Length; i++) { TileSprite t = layer[i]; if (t.IsCollidable) { Hitbox.AddCollidable(t); } } } } }
// set the tiles properties void SetTiles() { var index = 0; for (int y = 0; y < MapSize.y; y++) { for (int x = 0; x < MapSize.x; x++) { _map [x, y] = new TileSprite(TileSprites [index].Name, TileSprites [index].TileImage, TileSprites [index].TileType); index++; if (index > TileSprites.Count - 1) { index = 0; } } } }
public void updateTile() { TileSprite sprT = gameObject.GetComponent <TileSprite> (); if (sprT) { if (tile.fog) { sprT.setTile(GetInfo(), TileInfo.tileType.None, false); } else { sprT.setTile(GetInfo(), tile.type, tile.interaction); } sprT.setUnit(info); } }
public bool CheckLinks(int columnIdx, int tileIdx, TileSprite tileType) { for (int i = 0; i < combinations.Length; i++) { if (!combinations[i].ContainsCoord(columnIdx, tileIdx)) { continue; } int val = combinations[i].InsertToken(tileType); if (val == 4) { GameManager.Instance.EndGame(); } } return(false); }
// public Furniture Furniture; public Tile(TileEngine tileEngine, string tileName, TileSprite tileSprite, Vector2 startPosition, GameObject parent = null, float opacity = 1f) { TileName = tileName; TileEngine = tileEngine; GameObject = new GameObject(tileName); this.tileSprite = tileSprite; Debug.Log(tileSprite.Name); spriteRenderer = GameObject.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer; spriteRenderer.sprite = tileSprite.Sprite; spriteRenderer.color = new Color(1f, 1f, 1f, opacity); if (parent != null) { GameObject.transform.parent = parent.transform; } SetPosition(startPosition); }
public int InsertToken(TileSprite tileType) { if (tileType == TileSprite.SPRITE_YELLOW && redVal > 0 || tileType == TileSprite.SPRITE_RED && yellowVal > 0) { redVal = yellowVal = -1; return(-1); } else if (tileType == TileSprite.SPRITE_YELLOW) { yellowVal++; return(yellowVal); } else { redVal++; return(redVal); } }
public void ChangePlayer() { if (currentPlayer == TileSprite.SPRITE_YELLOW && yellowTilesNo <= 0 || currentPlayer == TileSprite.SPRITE_RED && redTilesNo <= 0) { EndGame(true); return; } if (currentPlayer == TileSprite.SPRITE_YELLOW) { yellowTilesNo--; currentPlayer = TileSprite.SPRITE_RED; return; } redTilesNo--; currentPlayer = TileSprite.SPRITE_YELLOW; }
public Map(string fileName, Game1 game, Mapper mapper, List<String> enemyList) { FileInputHandler fileIn = new FileInputHandler(game); tiles = fileIn.parseToArray(fileName); this.gameRef = game; this.mapper = mapper; this.enemyList = enemyList; loadList = new List<Sprite>(); int dim = 16; string s = ""; for (int x = 0; x < dim; x++) { for (int y = 0; y < dim; y++) { Vector2 position = new Vector2(x * 64, y * 64); s = this.tiles[y, x]; //if (s.Equals("0")) //{ // ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); // loadList.Add(ts); //} if (s.Contains("map_")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); loadList.Add(ts); string selectedBoss = s.Substring(s.IndexOf("_") + 1); Enemy bossObject; switch (selectedBoss) { case "clark": bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character); break; case "pay": bossObject = new JerryPay(gameRef.Character.Level, gameRef, gameRef.Character); break; case "fletcher": bossObject = new Fletcher(gameRef.Character.Level, gameRef, gameRef.Character); break; case "halliday": bossObject = new Halliday(gameRef.Character.Level, gameRef, gameRef.Character); break; case "king_james": bossObject = new Boss(gameRef.Character.Level, gameRef, gameRef.Character); break; default: bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character); break; } BossSprite combatSprite = new BossSprite(gameRef.Content.Load<Texture2D>(@"Images/map" + s.Substring(s.IndexOf('_'))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero, gameRef, bossObject); loadList.Add(combatSprite); } else if (s.Contains("3d")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); ts.passable = false; loadList.Add(ts); } else if (s.Contains("i")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); Treasure t = new Treasure(gameRef.Content.Load<Texture2D>(@"Images/mapItem"), position, 0, mapper, gameRef); loadList.Add(ts); loadList.Add(t); } else if (s.Contains("d")) { int i = 0; string mapID = s.Substring(1, 2); float placeAtX = (float.Parse(s.Substring(s.IndexOf(";") + 1, 2))) * 64; float placeAtY = (float.Parse(s.Substring(s.IndexOf("_") + 1, 2))) * 64; Door d = new Door(gameRef.Content.Load<Texture2D>(@"Images/tiled"), position, 0, mapID, mapper, new Vector2(placeAtX, placeAtY), gameRef); d.passable = false; d.isInteractable = true; loadList.Add(d); } else if (s.Contains("k")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); Key k = new Key(gameRef.Content.Load<Texture2D>(@"Images/key"), position, 0, mapper, gameRef); loadList.Add(ts); loadList.Add(k); } else if (s.Contains("l")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); LockedDoor ld = new LockedDoor(gameRef.Content.Load<Texture2D>(@"Images/lockedDoor"), position, 0, mapper, gameRef); loadList.Add(ts); loadList.Add(ld); } else if (s.Contains("s")) { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); ts.passable = false; ShopSprite ss = new ShopSprite(gameRef.Content.Load<Texture2D>(@"Images/shop"), position, 25, mapper, gameRef); loadList.Add(ts); loadList.Add(ss); } else if (s == "0") { int wallType = r.Next(0, 9); switch (wallType) { case 0: break; case 1: wallType = 0; break; case 2: wallType = 1; break; case 3: wallType = 1; break; case 4: wallType = 2; break; case 5: wallType = 2; break; case 6: wallType = 3; break; case 7: wallType = 1; break; case 8: wallType = 2; break; } ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/wallTile" + wallType), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); ts.passable = false; loadList.Add(ts); } else { ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero); if (s == "0" || s == "b") { ts.passable = false; } loadList.Add(ts); } } } }
private void OnPaint(object sender, PaintEventArgs ee) { // Demonstrate the GDI_Draw_Tile() method on top of the main form // Not sure how often such a thing will be wanted for UI purposes, // but it is nice to have the capability. Graphics gg = this.CreateGraphics(); TileSprite sta = new TileSprite(ts, NEW_OBJID, 21); TileSprite spr = new TileSprite(reticle_four_files_ts, NEW_OBJID, 0 + 15, 16 + 15, 32 + 15, 48 + 15); // Bottom right tile in each image in the stack TileSprite ani = new TileSprite(ts, NEW_OBJID, 224, 225, 226, 227); // Might also get an Image Attributes value, rather than passing null for the last argument... int x1 = 10; int x2 = 10 + 32 + 10; // to the right of the first tile int y1 = 512 + 10 + 5 + 13 + 13 + 10; // below the TVPC // Note that these will both be updated at 'frame' speed // (No need for "marching ants" via GDI+, and GDI+ rendering // gets choppy when updated at much faster than 'frame' speed) ani.GDI_Draw_Tile(gg, x1, y1, null, tvpc.frame); // Demonstrate an animated tile via GDI+ spr.GDI_Draw_Tile(gg, x1, y1, null, tvpc.frame); // Demonstrate transparency via GDI+ sta.GDI_Draw_Tile(gg, x2, y1, null, tvpc.frame); // Hmmm...wrong-facing horse, is the index off for GDI_Draw_Tile() vs blit_square_tile() ??? }
void OnShown(object sender, EventArgs ee) { // Note: Events are fired in the order (Load, Activated, Shown), // It is said that using a MessageBox() can perturb the order of these events, // causing Shown to occur before Load. // http://stackoverflow.com/questions/3070163/order-of-form-load-form-shown-and-form-activated-events // It is also said that "depending on the order of events fired" is undesirable / bad style; // so perhaps once I understand what the idiomatic alternative would be, // this should be changed. // // To call any GL methods (such as setting the GL Viewport, or loading textures) // the OpenGL system must be initialized, which occurs upon the 'Load' event // firing for a Form which contains a GLControl. // http://www.opentk.com/doc/chapter/2/glcontrol // See also, regarding OpenTK.Graphics.GraphicsContext: // http://www.opentk.com/book/export/html/140 // // For this reason, the GL setup, and GL texture loading (via TileSheet constructor calls) // code has been moved here, in a method we set up to be called upon the 'Shown' event // (which is fired upon the first display of this Form). ts = new TileSheet(16, 16, NEW_OBJID, @"media/tiles/U4.B_enhanced-32x32.png"); f1234 = new TileSheet(4, 9, 32, 32, 1, 1, 1, 1, NEW_OBJID, @"media/tiles/example_all_facings.4_frames.intra_1.png"); f1234_stack = new TileSheet(1, 9, 32, 32, 1, 1, 1, 1, NEW_OBJID, @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_1.png", @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_2.png", @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_3.png", @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_4.png"); wp_ts = new TileSheet(4, 1, NEW_OBJID, @"media/tiles/whirlpool_bright.png"); wp_stack_ts = new TileSheet(1, 1, NEW_OBJID, @"media/tiles/whirlpool.stacked/whirlpool_1.png", @"media/tiles/whirlpool.stacked/whirlpool_2.png", @"media/tiles/whirlpool.stacked/whirlpool_3.png", @"media/tiles/whirlpool.stacked/whirlpool_4.png"); creatures_stack = new TileSheet(4, 7, NEW_OBJID, @"media/tiles/creatures.stacked/creatures.frame_1.png", @"media/tiles/creatures.stacked/creatures.frame_2.png", @"media/tiles/creatures.stacked/creatures.frame_3.png", @"media/tiles/creatures.stacked/creatures.frame_4.png"); //string[] empty_file_names_list = { }; //TileSheet null_filenames_ts = new TileSheet(4, 4, NEW_OBJID, null ); // Will throw an exception //TileSheet empty_filenames_list_ts = new TileSheet(4, 4, NEW_OBJID, empty_file_names_list); // Will throw an exception TileSprite anim_blue_wiz = new TileSprite(ts, NEW_OBJID, 32, 33); TileSprite anim_red_wiz = new TileSprite(ts, NEW_OBJID, 224, 225, 226, 227); // Counters for 3 frames (A,B,C) and for 4 frames (1,2,3,4) // This illustrates why the master frame cycle need be the Least Common Multiple of (3,4) // (or whatever other set of ITileSprite.num_frames values). TileSprite count_ABC = new TileSprite(ts, NEW_OBJID, 96, 97, 98); //ts[0, 6], ts[1, 6], ts[2, 6]); TileSprite count_1234 = new TileSprite(f1234_stack, NEW_OBJID, 0, 9 + 0, 18 + 0, 27 + 0); // Same as count_1234, but frames from 4 files // TileSprite whirlpool = new TileSprite(wp_ts, NEW_OBJID, 0, 1, 2, 3); TileSprite whirlpool = new TileSprite(wp_stack_ts, NEW_OBJID, 0, 1, 2, 3); // Save as from wp_ts, but using 4 image files in a stack TileSprite bat = new TileSprite(creatures_stack, NEW_OBJID, (0 * 28) + 1, (1 * 28) + 1, (2 * 28) + 1, (3 * 28) + 1); TileSprite skel_mage = new TileSprite(creatures_stack, NEW_OBJID, (0 * 28) + 21, (1 * 28) + 21, (2 * 28) + 21, (3 * 28) + 21); LF = new TileSheet(8, 1, NEW_OBJID, @"media/tiles/lava.wave_down.speed_4.frames_8.png"); // LF == LavaFlow TileSprite lava_flow = new TileSprite(LF, NEW_OBJID, 0, 1, 2, 3, 4, 5, 6, 7); // TODO: Support some manner of ITileSprite for "wave" sprites // TileSheet TW = new TileSheet(1, 9, NEW_OBJID, @"media/tiles/example_wave_test.intra_1.png"); // Will need WaveTileSprite to support this... TileSprite grass = new TileSprite(ts, NEW_OBJID, 4); TileSprite trees = new TileSprite(ts, NEW_OBJID, 6); TileSprite boulder = new TileSprite(ts, NEW_OBJID, 57); int[] path_rect_5x4 = new int[] { // 5 = grass, 7 = trees, 58 = boulder boulder.ID, grass.ID, grass.ID, trees.ID, grass.ID, grass.ID, grass.ID, grass.ID, trees.ID, trees.ID, trees.ID, trees.ID, trees.ID, trees.ID, 0, // 0 is a "hole in the map" for blitting / map composition purposes grass.ID, grass.ID, trees.ID, grass.ID, grass.ID, }; DenseGrid map_16x64 = new DenseGrid(16, 64, lava_flow.ID); // Blit a non-square grid onto the map, demonstrating the various possible rotations and flips: DenseGrid flip_none = new DenseGrid(5, 4, path_rect_5x4); DenseGrid flip_we = flip_none.Flip_WE(); DenseGrid flip_ns = flip_none.Flip_NS(); DenseGrid flip_wens = flip_we.Flip_NS(); DenseGrid.BlitFromAOntoB(flip_none, map_16x64, 1, 1); DenseGrid.BlitFromAOntoB(flip_we, map_16x64, 7, 1); DenseGrid.BlitFromAOntoB(flip_ns, map_16x64, 1, 7); DenseGrid.BlitFromAOntoB(flip_wens, map_16x64, 7, 7); DenseGrid flip_none_rot090 = flip_none.Rotate090(); DenseGrid flip_we_rot090 = flip_we.Rotate090(); DenseGrid flip_ns_rot090 = flip_ns.Rotate090(); DenseGrid flip_wens_rot090 = flip_wens.Rotate090(); DenseGrid.BlitFromAOntoB(flip_none_rot090, map_16x64, 1, 52); DenseGrid.BlitFromAOntoB(flip_we_rot090, map_16x64, 7, 52); DenseGrid.BlitFromAOntoB(flip_ns_rot090, map_16x64, 1, 58); DenseGrid.BlitFromAOntoB(flip_wens_rot090, map_16x64, 7, 58); map = new SimpleMapV1(16, 64); map.AddTerrainRegion(map_16x64, 0, 0); tvpc.scroll_constraint = ScrollConstraint.CenterTile; tvpc.set_center(map, 2, 2); // Add some elements to the Beings layer of the Map: // BUG: (in demo data) // The below are bare integers which do not correspond // to a constructed TileSprite; those display wrongly (confusion between object ID and OpenGL texture ID or somesuch?) // The fix is merely to create TileSprite objects and use their .ID // (This fossil is due to the TileSheet + TileSprite refactor; // the sprites are no longer implicitly created and stored within the TileSheet) /* map.layers[MapLayers.Beings].set_contents_at_XY( 8, 7, 256+21); // Horse map.layers[MapLayers.Beings].set_contents_at_XY( 4, 15, 256+21); // Horse map.layers[MapLayers.Beings].set_contents_at_XY( 8, 20, 33); // Wizard map.layers[MapLayers.Beings].set_contents_at_XY( 3, 25, 70); // Force field map.layers[MapLayers.Beings].set_contents_at_XY(10, 30, 29); // Stair down map.layers[MapLayers.Beings].set_contents_at_XY( 9, 35, 30); // Ruin map.layers[MapLayers.Beings].set_contents_at_XY( 6, 40, 45); // Archer map.layers[MapLayers.Beings].set_contents_at_XY(12, 45, 23); // Purple tiles map.layers[MapLayers.Beings].set_contents_at_XY( 5, 50, 19); // Ship */ map.layers[MapLayers.Beings].set_contents_at_XY(2, 1, anim_blue_wiz.ID); // Blue Wizard, animated (2 frames) map.layers[MapLayers.Beings].set_contents_at_XY(3, 3, anim_red_wiz.ID); // Red Wizard, animated (4 frames) map.layers[MapLayers.Beings].set_contents_at_XY(4, 1, count_ABC.ID); // 3 frames (A,B,C) map.layers[MapLayers.Beings].set_contents_at_XY(5, 1, count_1234.ID); // 4 frames (1,2,3,4) map.layers[MapLayers.Beings].set_contents_at_XY(6, 6, bat.ID); map.layers[MapLayers.Beings].set_contents_at_XY(4, 7, skel_mage.ID); map.layers[MapLayers.Beings].set_contents_at_XY(0, 0, whirlpool.ID); // Add some elements to the UI_elements layer of the TileViewPort: // Over-sized cursor // Drawback: outside of tile bounds // is off-viewport for edge-of-viewport sides of cursor on edge-of-viewport tiles. // Also, the "quanta" animation rate for the cursor blinking is too fast, as in "pokemon epilepsy warning" too-fast. // (Blinking at "frame" rate seems OK...may want a modestly faster rate.) // // This cursor _does_ look a lot better, other than for edge-of-viewport tiles. // One possible solution to that issue would be for the "rest" state of the viewport // to have an n-pixel border along all edges, showing partial tiles. // Will need to coordinate all this with smooth-scrolling, too... ts_cursor_blink_40x40 = new TileSheet(1, 1, 40, 40, 0, 0, 0, 0, NEW_OBJID, @"media/cursors/cursor_40x40_blink.stacked/cursor_40x40.frame_1.png", @"media/cursors/cursor_40x40_blink.stacked/cursor_40x40.frame_2.png"); TileSprite large_cursor = new TileSprite(ts_cursor_blink_40x40, NEW_OBJID, 0, 1); int LC = large_cursor.ID; tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.center_x, tvpc.center_y, LC); // Center tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, 0, LC); // NW tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, 0, LC); // NE tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, tvpc.max_y, LC); // SW tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, tvpc.max_y, LC); // SE // // "Marquee" cursor // // Drawback: cursor itself is entirely within tile bounds, thus clips edge pixels of the under-cursor tile... // // //reticle_single_file_ts = new TileSheet(4, 1, NEW_OBJID, @"media/tiles/bright_marquee.frame_1234.png"); reticle_four_files_ts = new TileSheet(4, 4, NEW_OBJID, @"media/tiles/bright_marquee.frame_1.png", @"media/tiles/bright_marquee.frame_2.png", @"media/tiles/bright_marquee.frame_3.png", @"media/tiles/bright_marquee.frame_4.png"); // Also used in Form1.OnPaint() //TileSprite anim_reticle = new TileSprite(reticle_four_files_ts, 15, 31, 47, 63); // Bottom right tile in each image file //int reticle = anim_reticle.ID; //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.center_x, tvpc.center_y, reticle); // Center //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, 0, reticle); // NW //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, 0, reticle); // NE //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, tvpc.max_y, reticle); // SW //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, tvpc.max_y, reticle); // SE // A few method calls to demonstrate that Archetype and Obj are working: Archetype aa = new Archetype("first_test_archetype", 0); aa.add_field("int_2a", FieldType.INT); aa.add_field("string_2a", FieldType.STRING); aa.add_field("decimal_2a", FieldType.DECIMAL); aa.add_field("ID_2a", FieldType.ID); aa.add_field("int_list", FieldType.LIST_INT); aa.add_field("string_list", FieldType.LIST_STRING); aa.add_field("decimal_list", FieldType.LIST_DECIMAL); aa.add_field("ID_list", FieldType.LIST_ID); Obj obj1 = new Obj(aa, "first_test_obj", 0); stdout.print("archetype.serialize()\n"); stdout.print("{0}", aa.serialize() ); stdout.print("\n"); stdout.print("obj.serialize()\n"); stdout.print("{0}", obj1.serialize() ); stdout.print("\n"); }