public void Enter(S_Entity enterer) { if (enterer is S_Player && content != null) { content.Pickup(); } }
static void TestAtom() { UnQEntitybase db = new UnQEntitybase(); db.Save("12", "123"); string res = db.Get("12"); db.Save("12", 12); int res1 = db.GetInt32("12"); db.Save("12a", 12L); long res2 = db.GetInt64("12a"); db.Save("12b", 12.0f); float res3 = db.GetSingle("12b"); db.Save("12c", 12.0); double res4 = db.GetDouble("12c"); db.Save("12d", false); bool res5 = db.GetBoolean("12d"); db.Save("123", DateTime.Now); DateTime res6 = db.GetDateTime("123"); db.SaveStructure("1234", new S_Entity() { ID = 10, Name = "we", Title = "123$" }); S_Entity res7 = db.GetStructure <S_Entity>("1234"); db.SaveObject("12345", new T_Entity1() { ID = 10, Name = "we", Title = "123$" }); T_Entity1 res8 = db.GetObject <T_Entity1>("12345"); }
void InitTilesAndEntities() { //init tiles array int tilesAcross = levelData.width; int tilesDown = levelData.height - 1; tiles = new S_Tile[tilesAcross, tilesDown]; gridWidth = (int)(tilesAcross * (S_Tile.BASE_TILE_SIZE + 1) * S_Camera.scale + S_Camera.scale); gridHeight = (int)(tilesDown * (S_Tile.BASE_TILE_SIZE + 1) * S_Camera.scale + S_Camera.scale); //use colours in leveldata to setup entities for (int x = 0; x < tilesAcross; x++) { for (int y = 0; y < tilesDown; y++) { S_Tile tile; switch (FromColour(levelData.GetPixel(x, y))) { case LevelContent.wall: break; case LevelContent.blank: tile = MakeTile(x, y); break; case LevelContent.food: tile = MakeTile(x, y); tile.AddPickup(); pickupsRemaining++; totalPickups++; break; case LevelContent.player: tile = MakeTile(x, y); GameObject playerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/player"))); player = playerObject.GetComponent <S_Player>(); player.Init(); entities.Add(player); player.MoveToTile(tile, true); break; case LevelContent.charger: tile = MakeTile(x, y); GameObject chargerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/charger"))); S_Entity charger = chargerObject.GetComponent <S_Charger>(); charger.Init(); entities.Add(charger); charger.MoveToTile(tile, true); break; case LevelContent.enemy: tile = MakeTile(x, y); GameObject pincerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/pincer"))); S_Entity enemy = pincerObject.GetComponent <S_Pincer>(); enemy.Init(); entities.Add(enemy); enemy.MoveToTile(tile, true); break; } } } //hierarchy object for entities GameObject entityParent = new GameObject("entities"); entityParent.transform.SetParent(mapObject.transform, false); foreach (S_Entity e in entities) { e.positionSetter.transform.SetParent(entityParent.transform, false); } //setup map border GameObject rect = Primitives.CreateRectangle(tilesAcross * S_Tile.width + S_Camera.scale, tilesDown * S_Tile.height + S_Camera.scale, Colours.RED); rect.transform.SetParent(mapObject.transform, false); rect.GetComponent <SpriteRenderer>().sortingLayerName = "Tiles"; rect.GetComponent <SpriteRenderer>().sortingOrder = 0; rect.name = "level_background"; //add level number (rethink into something symbolic maybe?) /*levelNumberObject = Primitives.CreateText(("level " + (Game.Get().levelNumber))); * S_Follower follow = levelNumberObject.AddComponent<S_Follower>(); * follow.Follow(slider.gameObject, 2 * S_Camera.scale, Screen.height - 28 * S_Camera.scale);*/ }