void OnClick() { ShopSlot sS = transform.parent.GetComponent <ShopSlot>(); if (sS.locked) { if (GameController.instance.level >= sS.unlocksAt) { sS.unlock(); } } else if (!sS.bought && GameController.instance.gold >= sS.prefab.GetComponent <M_Mob>().goldCost) { GameController.instance.gold -= sS.prefab.GetComponent <M_Mob>().goldCost; sS.changeButtonToTalent(); } else { TalentWindow.instance.openWindow(sS.prefab.GetComponent <M_Mob>().id); NGUITools.SetActive(GameController.instance.talentWindow, true); } }
void postPrepareLoadedLevel() { cleanLevelForLoad(); M_Boss bossM = GameController.instance.boss.GetComponent <M_Boss>(); bossM.health = savedGame.bossHealth; bossM.mana = savedGame.bossMana; bossM.maxHealth = savedGame.bossMaxHealth; bossM.maxMana = savedGame.bossMaxMana; int i = 0; foreach (M_Mob mob in instantiatedMobs) { mob.health = savedGame.mobs[i][1]; mob.mana = savedGame.mobs[i][2]; mob.maxHealth = savedGame.mobs[i][3]; mob.maxMana = savedGame.mobs[i][4]; i++; } i = 0; foreach (float[] chestAttr in savedGame.chestPos) { GameObject chestPrefab = PrefabIndex.instance.prefabIndex[savedGame.chests[i][0]]; Vector3 chestPos = new Vector3(savedGame.chestPos[i][0], savedGame.chestPos[i][1], savedGame.chestPos[i][2]); GameObject insChest = Instantiate(chestPrefab, chestPos, chestPrefab.transform.rotation) as GameObject; GameController.instance.roomShades[savedGame.chests[i][1]].GetComponent <RoomController>().addChest(insChest); i++; } // Spawn Menu i = 0; while (true) { i++; Transform mobSlot = GameController.instance.mobWindow.transform.Find("Scroller/Grid/Slot" + i); if (mobSlot != null) { ShopSlot sSlot = mobSlot.GetComponent <ShopSlot>(); if (savedGame.spawnSlots[i - 1][0] != 1) { sSlot.unlock(); } if (savedGame.spawnSlots[i - 1][1] == 1) { sSlot.changeButtonToTalent(); } if (savedGame.spawnSlots[i - 1][2] == 1) { sSlot.toggleSelected(); Bottombar.instance.addToBar(PrefabIndex.instance.prefabIndex[savedGame.spawnSlots[i - 1][3]]); } } else { break; } } NGUITools.SetActive(GameController.instance.mobWindow, false); // Talents i = 0; foreach (Talent[] talents in TalentWindow.instance.allTalents) { for (int j = 0; j < 9; j++) { talents[j].active = savedGame.talents[i][j] == 1; } i++; } NGUITools.SetActive(GameController.instance.loadingWindow, false); }