override public void OnEnter() { Tile[,] map_plan = MapMaker.generateMap(); board = new Board(); board.initBoard(map_plan); player = new Creature("You", "char-456"); player.x = 10 * tw; player.y = 4 * th; Futile.stage.AddChild(player); board.addCreature(player); //player.color = UnityEngine.Color.yellow; fco = new FCamObject(); fco.follow(player); fco.setWorldBounds(new Rect(-120, -80, 480, 30 * MainDemoScript.th)); //map_plan.GetLength(0)*MainDemoScript.th)); fco.setBounds(new Rect(-240, -160, 240, 160)); AddChild(fco); Monster m = new Monster("Blood Mage", "char-460"); m.str = 1; m.x = 15 * tw; m.y = 12 * th; Futile.stage.AddChild(m); board.addCreature(m); creatures.Add(m); NPC knight = new NPC("Holy Knight", "char-466", "The heart of this cast\nle has become corrupted."); knight.x = 16 * tw; knight.y = 5 * th; knight.color = UnityEngine.Color.yellow; Futile.stage.AddChild(knight); board.addCreature(knight); creatures.Add(knight); knight = new NPC("Holy Knight", "char-466", "You should not enter.\nYou cannot save it."); knight.x = 13 * tw; knight.y = 5 * th; knight.color = UnityEngine.Color.yellow; Futile.stage.AddChild(knight); board.addCreature(knight); creatures.Add(knight); for (int i = 0; i < map_plan.GetLength(0); i++) { for (int j = 0; j < map_plan.GetLength(1); j++) { board.tilemap[i, j] = map_plan[i, j]; if (map_plan[i, j] != null) { AddChild(map_plan[i, j]); } } } uibar = new FSprite("uibar"); uibar.anchorX = 0; uibar.anchorY = 1.0f; uibar.x = 0; uibar.y = Futile.screen.height; uibar.scaleY = 0.8f; fco.AddChild(uibar); chatbar = new FSprite("uibar"); chatbar.anchorX = 0; chatbar.anchorY = 0; chatbar.x = 0; chatbar.y = 0; chatbar.scaleY = 1.4f; chatbar.alpha = 0f; fco.AddChild(chatbar); turnCounterLabel = new FLabel("mainfont", "Turn " + turnNumber); turnCounterLabel.anchorX = 0; turnCounterLabel.anchorY = 1.0f; //turnCounterLabel.scale = 0.8f; //turnCounterLabel.scale = 0.5f; turnCounterLabel.x = 4; turnCounterLabel.y = Futile.screen.height - 2; turnCounterLabel.color = UnityEngine.Color.white; fco.AddChild(turnCounterLabel); timerLabel = new FLabel("mainfont", "Tick"); timerLabel.anchorX = 1.0f; timerLabel.anchorY = 1.0f; //timerLabel.scale = 0.8f; timerLabel.x = Futile.screen.width - 4; timerLabel.y = Futile.screen.height - 2; timerLabel.color = UnityEngine.Color.red; fco.AddChild(timerLabel); messageLabel = new FLabel("mainfont", ""); messageLabel.anchorX = 0f; messageLabel.anchorY = 0f; messageLabel.x = 2f; messageLabel.y = 4f; messageLabel.color = UnityEngine.Color.white; fco.AddChild(messageLabel); gameOverLabel = new FLabel("mainfont", "The Castle Falls Silent"); gameOverLabel.anchorX = 0.5f; gameOverLabel.anchorY = 0.5f; gameOverLabel.x = Futile.screen.width / 2; gameOverLabel.y = Futile.screen.height / 2; gameOverLabel.color = UnityEngine.Color.white; fco.MoveToFront(); //Futile.stage.AddChild(gameOverLabel); }
public World(int level) { string beginningMessage = ""; if (beginningMessages.Length > level) { beginningMessage = beginningMessages[level]; } beginningLabel = new FLabel("Large", beginningMessage); beginningLabel.alpha = 1.0f; beginningLabel.y = -70; beginningLabelShadow = new FLabel("Large", beginningMessage); beginningLabelShadow.color = Color.black; beginningLabelShadow.SetPosition(beginningLabel.GetPosition()); beginningLabelShadow.x += 1; beginningLabelShadow.y += -1; this.currentLevelNum = level; string levelName = "Maps/map" + level; this.startNumPlayers = enemiesOnLevel[level]; clock = new Clock(); clock.enableSound(); enemyClock = new EnemyClock(); gui = new FCamObject(); gui.AddChild(clock); gui.AddChild(enemyClock); setClock(clock); Futile.stage.AddChild(playerLayer); tmxMap.LoadTMX(levelName); tilemap = (FTilemap)(tmxMap.getLayerNamed("Tilemap")); FTilemap objectLayer = (FTilemap)(tmxMap.getLayerNamed("Objects")); for (int xInd = 0; xInd < objectLayer.widthInTiles; xInd++) { for (int yInd = 0; yInd < objectLayer.heightInTiles; yInd++) { switch (objectLayer.getFrameNum(xInd, yInd)) { case 0: break; case 10: FNode newSpawn = new FNode(); newSpawn.x = xInd * tilemap._tileWidth + tilemap._tileWidth / 2; newSpawn.y = -yInd * tilemap._tileHeight - tilemap._tileHeight / 2; spawnPoints.Add(newSpawn); break; case 11: playerSpawn = new FNode(); playerSpawn.x = xInd * tilemap._tileWidth + tilemap._tileWidth / 2; playerSpawn.y = -yInd * tilemap._tileHeight - tilemap._tileHeight / 2; break; } } } this.miniMap = new Minimap(this); playerLayer.AddChild(tmxMap); tilemap.clipNode = gui; Player player = new Player(true); gui.follow(player); addPlayer(player); player.setScale(2.0f, true); miniMap.setFollow(player); for (int ind = 0; ind < startNumPlayers; ind++) { Player p = new Player(); addPlayer(p); } Futile.stage.AddChild(gui); gui.AddChild(new MuteMusicButton()); gui.AddChild(miniMap); gui.AddChild(beginningLabelShadow); gui.AddChild(beginningLabel); }