/// <summary> /// Adds a sprite to a tilemap at a position, and puts the sprite in a list to animate if it's animated /// </summary> /// <param name="tilemap"></param> /// <param name="pos"></param> /// <param name="sprites"></param> /// <param name="animated"></param> private void AddSprite(Vector2Int pos, String[] sprites, bool animated, bool detail) { TileRegistry.GetInstance().SetTile(pos, sprites[0], detail); if (animated) { animatedSprites.Add(new AnimatedSprite(pos, sprites, detail)); } }
public void DoProgress() { chopProgress++; if (chopProgress == treeToughness) { Map.GetInstance().SetDetail(treeTile, null); TileRegistry.GetInstance().RemoveTree(treeTile); isDone = true; } }
/// <summary> /// Update an animated sprite to the next sprite in sequence /// </summary> /// <param name="sprite"></param> private void UpdateSprite(AnimatedSprite sprite) { if (sprite.playingForward) { sprite.currSpriteIdx++; if (sprite.currSpriteIdx == 3) { sprite.playingForward = false; } } else { sprite.currSpriteIdx--; if (sprite.currSpriteIdx == 0) { sprite.playingForward = true; } } TileRegistry.GetInstance().SetTile(sprite.pos, sprite.sprites[sprite.currSpriteIdx], sprite.detail); }
private void CreateDetails() { for (int x = 0; x < tiles.GetLength(0); x++) { for (int y = 0; y < tiles.GetLength(1); y++) { Vector2Int pos = new Vector2Int(x, y); IList <Vector2Int> immediateTiles = new List <Vector2Int>(Utils.GetAdjCoordsArr(pos)) { pos }; if (SurroundedBy(immediateTiles, IsSandTile)) { if (Utils.r.Next(100) < 10) { SetDetail(pos, Detail.Palm, false); TileRegistry.GetInstance().SetPalmTile(pos); } else if (Utils.r.Next(100) < 1) { SetDetail(pos, Detail.DessertRock, false); TileRegistry.GetInstance().SetRockBeachTile(pos); } } else if (SurroundedBy(immediateTiles, IsGrassTile) || SurroundedBy(immediateTiles, IsCliffTile)) { if (Utils.r.Next(100) < 10) { SetDetail(pos, Detail.Tree, false); TileRegistry.GetInstance().SetTreeTile(pos); } else if (Utils.r.Next(100) < 1) { SetDetail(pos, Detail.Rock, false); TileRegistry.GetInstance().SetRockTile(pos); } } } } }
public void DoProgress() { Map.GetInstance().SetItem(pos, item); TileRegistry.GetInstance().SetItem(pos, item); isDone = true; }
private void CreateSprite(int spriteNum) { sprite = new GameObject("Sprite"); TileRegistry.GetInstance().SetCharSprite(sprite.AddComponent <SpriteRenderer>(), sex, spriteNum); sprite.transform.SetParent(Constants.GRID.transform); }