public void Initialize() { // Debug.Log("NavigationMaster"); detailsList = new List <GameObject>(); teamBuilderMaster = GameObject.Find("AllyListMaster").GetComponent <Button>(); teamBuilderDetail = GameObject.Find("AllyListDetail"); levelSelectMaster = GameObject.Find("LevelSelectMaster").GetComponent <Button>(); levelSelectDetail = GameObject.Find("LevelSelectDetail"); forgeMaster = GameObject.Find("ForgeMaster").GetComponent <Button>(); forgeDetail = GameObject.Find("ForgeDetail"); tavernMaster = GameObject.Find("TavernMaster").GetComponent <Button>(); tavernDetail = GameObject.Find("TavernDetail"); detailsList.Add(teamBuilderDetail); detailsList.Add(levelSelectDetail); detailsList.Add(forgeDetail); detailsList.Add(tavernDetail); teamBuilderMaster.onClick.AddListener(TeamBuilderMasterClicked); levelSelectMaster.onClick.AddListener(levelSelectMasterClicked); forgeMaster.onClick.AddListener(ForgeMasterClickerd); tavernMaster.onClick.AddListener(TavernMasterClicked); TownManager.Initialize(); AllDetailHide(null); TeamBuilderMasterClicked(); }
private void Awake() { if (instance == null) { instance = this; } }
public override void UpdateUpgradeTrees(bool afterPurchase = false) { NomadWagon.UpdateBuilding(DarkestDungeonManager.Campaign.Estate.TownPurchases); float ratio = DarkestDungeonManager.Campaign.Estate.GetBuildingUpgradeRatio(BuildingType.NomadWagon); upgradeWindow.upgradedValue.text = Mathf.RoundToInt(ratio * 100).ToString() + "%"; wagonInventory.UpdatePrices(); if (afterPurchase && Mathf.Approximately(ratio, 1)) { DarkestSoundManager.PlayOneShot("event:/town/purchase_upgrade_last"); } foreach (var tree in upgradeWindow.upgradeTrees) { var currentUpgrades = DarkestDungeonManager.Data.UpgradeTrees[tree.treeId].Upgrades; int lastPurchaseIndex = -1; for (int i = 0; i < tree.upgrades.Count; i++) { var status = DarkestDungeonManager.Campaign.Estate.GetUpgradeStatus(tree.treeId, currentUpgrades[i]); TownManager.UpdateUpgradeSlot(status, tree.upgrades[i]); if (status == UpgradeStatus.Purchased) { lastPurchaseIndex = i; } } tree.UpdateConnector(lastPurchaseIndex); } }
public void ClosePanel() { PlayerDataTransfer.SavePlayerData(player); this.gameObject.SetActive(false); int availableSkillCount = player.knownSkills.Count; int equippedSkillCount = player.equippedSkills.Count; if (availableSkillCount != 0) { var skillSlots = availableSkillsList.GetComponentsInChildren <SkillSlot>(); foreach (var skill in skillSlots) { Destroy(skill.gameObject); } } if (equippedSkillCount != 0) { var skillSlots = equippedSkillsList.GetComponentsInChildren <SkillSlot>(); foreach (var skill in skillSlots) { Destroy(skill.gameObject); } } TownManager townManager = FindObjectOfType <TownManager>(); townManager.megaBossButton.gameObject.SetActive(true); townManager.normalBossButton.gameObject.SetActive(true); }
public override void PlaceTile(TownManager tm, Map map, List <Tile> buildingTiles, int rotAmt, Vector2 curBuildRotScale) { ResourceTile rT = buildingTiles[0] as ResourceTile; rotatedScale = curBuildRotScale; CollectResourceBuildingTile bMain = new CollectResourceBuildingTile(buildingTiles[0].GetMapLoc(), buildingTiles[0].GetWorldLoc(), 'B', buildingTiles[0].GetTileObj(), this, rT.GetIsTrees()); bMain.mapScript = map; bMain.tm = tm; Vector2 tileMapPos = buildingTiles[0].GetMapLoc(); List <WorldResource> resources = rT.GetResourcesList(); map.SetTileFromMapPos((int)tileMapPos.x, (int)tileMapPos.y, bMain); bMain.SetResourcesLeft(resources.Count); for (int i = 0; i < resources.Count; i++) { // Create a task for each tree and send it to the town manager citizenTasks list Queue <Target> taskQ = new Queue <Target>(); Vector3 loc = resources[i].GetResourceObject().transform.position; taskQ.Enqueue(new Target(loc, bMain, resources[i], null, 4f, false, true)); taskQ.Enqueue(new Target(new Vector3(0, 0, 0), false)); Task t = new Task(taskQ, true); tm.AddTask(t); } }
// Start is called before the first frame update void Start() { ui = canvas.GetComponent <UIManager>(); buildMode = gameObject.GetComponent <BuildMode>(); // assignMode = gameObject.GetComponent<AssignMode>(); tm = gameObject.GetComponent <TownManager>(); }
public override void Initialize() { heroOverview.Initialize(TownManager); Blacksmith = DarkestDungeonManager.Campaign.Estate.Blacksmith; float ratio = DarkestDungeonManager.Campaign.Estate.GetBuildingUpgradeRatio(BuildingType.Blacksmith); upgradeWindow.upgradedValue.text = Mathf.RoundToInt(ratio * 100).ToString() + "%"; foreach (var tree in upgradeWindow.upgradeTrees) { var currentUpgrades = DarkestDungeonManager.Data.UpgradeTrees[tree.treeId].Upgrades; int lastPurchaseIndex = -1; for (int i = 0; i < tree.upgrades.Count; i++) { tree.upgrades[i].Tree = DarkestDungeonManager.Data.UpgradeTrees[tree.treeId]; tree.upgrades[i].UpgradeInfo = currentUpgrades[i]; if (tree.treeId == "blacksmith.cost") { tree.upgrades[i].TownUpgrades = new List <ITownUpgrade>(new ITownUpgrade[] { Blacksmith.GetUpgradeByCode(currentUpgrades[i].Code) }); } tree.upgrades[i].onClick += BlacksmithWindow_onUpgradeClick; var status = DarkestDungeonManager.Campaign.Estate.GetUpgradeStatus(tree.treeId, currentUpgrades[i]); TownManager.UpdateUpgradeSlot(status, tree.upgrades[i]); if (status == UpgradeStatus.Purchased) { lastPurchaseIndex = i; } } tree.UpdateConnector(lastPurchaseIndex); } }
// Start is called before the first frame update void Start() { ui = canvas.GetComponent <UIManager>(); mm = gameObject.GetComponent <MasterManager>(); tm = gameObject.GetComponent <TownManager>(); originalMat = tileSelectorPrefab.transform.GetChild(0).gameObject.GetComponent <Renderer>().sharedMaterial; }
private void CheckIfAttack(TownManager town) { List <GameObject> tmpHouses = new List <GameObject>(); GameObject[] gos = GameObject.FindGameObjectsWithTag("House"); //Debug.Log(gos.Length); gos = gos.OrderBy((el) => (el.transform.position - town.transform.position).sqrMagnitude).ToArray(); foreach (GameObject go in gos) { if (go.GetComponent <TownManager>().CurrentOwner != Owner.Enemy) { tmpHouses.Add(go); } } TownManager target = tmpHouses[0].GetComponent <TownManager>(); if (target.CurrentTroop < (town.CurrentTroop - 1)) { Debug.Log("Enemy Launch Attack"); target.HasAttacked = true; town.spawnTroop(target); } }
public override void Initialize() { NomadWagon = DarkestDungeonManager.Campaign.Estate.NomadWagon; wagonInventory.NomadWagon = NomadWagon; wagonInventory.UpdateShop(); float ratio = DarkestDungeonManager.Campaign.Estate.GetBuildingUpgradeRatio(BuildingType.NomadWagon); upgradeWindow.upgradedValue.text = Mathf.RoundToInt(ratio * 100).ToString() + "%"; foreach (var tree in upgradeWindow.upgradeTrees) { var currentUpgrades = DarkestDungeonManager.Data.UpgradeTrees[tree.treeId].Upgrades; int lastPurchaseIndex = -1; for (int i = 0; i < tree.upgrades.Count; i++) { tree.upgrades[i].Tree = DarkestDungeonManager.Data.UpgradeTrees[tree.treeId]; tree.upgrades[i].UpgradeInfo = currentUpgrades[i]; tree.upgrades[i].TownUpgrades = new List <ITownUpgrade>(new ITownUpgrade[] { NomadWagon.GetUpgradeByCode(tree.treeId, currentUpgrades[i].Code) }); tree.upgrades[i].onClick += WagonWindow_onUpgradeClick; var status = DarkestDungeonManager.Campaign.Estate.GetUpgradeStatus(tree.treeId, currentUpgrades[i]); TownManager.UpdateUpgradeSlot(status, tree.upgrades[i]); if (status == UpgradeStatus.Purchased) { lastPurchaseIndex = i; } } tree.UpdateConnector(lastPurchaseIndex); } }
public void TestMigration() { //var LiteDatabase = new LiteDB.LiteDatabase("main2v.db"); DataBase.Drop(); var tm = new TownManager(); var bdm = new BuildingDataManager(tm); var loader = new XmlLoader(bdm, tm, tm, tm); loader.LoadModel(); var max = loader.Items.OrderByDescending(x => x.Key.Length).First(); var md = new MarketDataManager(); md.Save(max.Key, 1, false, new ItemFromMarketData()); var ord = md.GetOrders(); Assert.AreEqual(1, ord.Count()); //DataBase.Instance.GetCollection<> }
public void Initialize(TownManager townManager) { TownManager = townManager; for (int i = 0; i < campingSkills.Length; i++) { campingSkills[i].onClick += CampingTrainerHeroWindow_onSkillClick; } }
void Start() { txt = transform.GetComponent <Text>(); NewText(); manager = GameObject.FindObjectOfType <TownManager>(); curPage = -1; twnMove = GameObject.FindObjectOfType <TownMovement>(); }
public override void DoProduction(TownManager townManager) { townManager.AddGold(ProductionValue); if (BuildingLevel > 2) { townManager.AddSilver(ProductionValue / 2); } }
public void TownManagerCircleTest() { for (int i = 0; i <= TownManager.NumberOfAllTowns; i++) { TownManager.GetNextTown(); } Assert.IsNotNull(TownManager.currentTown); }
private void SelectPlayerTown(TownManager selectedTown) { if (selectedTown.CurrentOwner == Owner.Player) { Debug.Log("Player Town Selected"); selectedPlayerTown = selectedTown; } }
private void SelectTargetTown(TownManager selectedTown) { if (selectedPlayerTown != null) { Debug.Log("Target Town Selected"); selectedTargetTown = selectedTown; } }
void SanitariumWindow_onTreatmentButtonClick(TreatmentHeroSlot slot) { if (slot.TreatmentSlot.Status == ActivitySlotStatus.Paid) { TownManager.GetHeroSlot(slot.TreatmentSlot.Hero).SetStatus(HeroStatus.Available); slot.SetStatus(ActivitySlotStatus.Available); } }
public void Initialize(TownManager townManager) { TownManager = townManager; for (int i = 0; i < diseaseSlots.Count; i++) { diseaseSlots[i].onSelect += SanitariumDiseaseWindow_onSelect; diseaseSlots[i].onDeselect += SanitariumDiseaseWindow_onDeselect; } }
// Use this for initialization void Start() { // TownManagerScript = Building.TownManagerScript; // Set the correct character collider that will interact with this trigger. Activator = TownManagerScript.PlayerCollider; // make this object invisible this.gameObject.GetComponent <MeshRenderer>().enabled = false; }
public void ClosePanel() { this.gameObject.SetActive(false); TownManager townManager = FindObjectOfType <TownManager>(); townManager.megaBossButton.gameObject.SetActive(true); townManager.normalBossButton.gameObject.SetActive(true); }
public void Initialize(TownManager townManager) { TownManager = townManager; for (int i = 0; i < skillTrees.Length; i++) { skillTrees[i].currentSkill.onClick += GuildHeroWindow_onSkillClick; for (int j = 0; j < skillTrees[i].upgrades.Count; j++) skillTrees[i].upgrades[j].onClick += GuildHeroWindow_onUpgradeClick; } }
public virtual void PlaceTile(TownManager tm, Map map, List <Tile> buildingTiles, int rotAmt, Vector2 curBuildRotScale) { // Decide how to handle the placing of the tile BuildableTile bMain = new BuildableTile(buildingTiles[0].GetMapLoc(), buildingTiles[0].GetWorldLoc(), 'B', null, this); bMain.rotatedScale = curBuildRotScale; for (int i = 0; i < buildingTiles.Count; i++) { Vector3 pos = buildingTiles[i].GetWorldLoc(); Vector2 tileMapPos = buildingTiles[i].GetMapLoc(); Vector3 adjustedObjPos = new Vector3(pos.x + 0.5f, 0, pos.z + 0.5f); Quaternion tileRot = Quaternion.Euler(0, 90 * rotAmt + 90, 0); GameObject newTileObj; if (needsBuilt) { if (preBuiltPrefabs.Length > 0) { buildingTiles[i].DestroyTileObject(); newTileObj = (GameObject)GameObject.Instantiate(preBuiltPrefabs[i], adjustedObjPos, tileRot); } else { newTileObj = buildingTiles[i].GetTileObj(); } newTileObj.transform.parent = map.gameObject.transform; } else { // Wait for worker to be assigned to the tile buildingTiles[i].DestroyTileObject(); newTileObj = (GameObject)GameObject.Instantiate(tileStages[0].tilePrefabs[i], adjustedObjPos, tileRot); newTileObj.transform.parent = map.gameObject.transform; } if (i == 0) { bMain.SetTileObj(newTileObj); map.SetTileFromMapPos((int)tileMapPos.x, (int)tileMapPos.y, bMain); } else { BuildableTileChild bChild = new BuildableTileChild(buildingTiles[i].GetMapLoc(), buildingTiles[i].GetWorldLoc(), 'b', newTileObj, bMain); bMain.AddBuildTileChild(bChild); map.SetTileFromMapPos((int)tileMapPos.x, (int)tileMapPos.y, bChild); } } if (needsBuilt) { bMain.SetBeingBuilt(true); // Call town manager to get first available citizen villager // Call BeginBuildPhase(citizen) } bMain.PlacedTile(); tm.AddBuilding(bMain); }
void Awake() { if (instance == null) { instance = this; } else if (instance != null) { Destroy(gameObject); } }
public void Initialize(TownManager townManager) { TownManager = townManager; for (int i = 0; i < equipmentTrees.Length; i++) { for (int j = 0; j < equipmentTrees[i].upgrades.Count; j++) { equipmentTrees[i].upgrades[j].onClick += BlacksmithHeroWindow_onUpgradeClick; } } }
public void ClosePanel() { //save player data on close. SavePlayerData(); this.gameObject.SetActive(false); TownManager townManager = FindObjectOfType <TownManager>(); townManager.megaBossButton.gameObject.SetActive(true); townManager.normalBossButton.gameObject.SetActive(true); }
public void TestUpdatePrice() { { DataBase.Drop(); var tm = new TownManager(); var bdm = new BuildingDataManager(tm); var loader = new XmlLoader(bdm, tm, tm, tm); loader.LoadModel(); var buildings = loader.CraftBuildings; var all = loader.Items; Assert.AreEqual(10, buildings["T8_FORGE"].Tax); buildings["T8_FORGE"].Tax = 0; _exp = 80000; var fired = 0; all["T4_OFF_SHIELD"].CostUpdate += () => { Assert.AreEqual(_exp, all["T4_OFF_SHIELD"].Cost); fired++; }; Assert.AreEqual(0, all["T4_OFF_SHIELD"].Cost); Assert.AreEqual(1, fired); Assert.AreEqual(80000, all["T4_OFF_SHIELD"].Cost); _exp = 3580000; buildings["T8_FORGE"].Tax = 10; // all["T4_OFF_SHIELD"].Building.Tax= 10; Assert.AreEqual(2, fired); Assert.AreEqual(3580000, all["T4_OFF_SHIELD"].Cost); } { var tm = new TownManager(); var mdm = new MarketDataManager(); var bdm = new BuildingDataManager(tm); var loader = new XmlLoader(bdm, tm, tm, tm); var model = loader.LoadModel(); var all = loader.Items; Assert.AreEqual(3580000, all["T4_OFF_SHIELD"].Cost); } }
// Start is called before the first frame update private void Awake() { LoadTown(); if (instance == null) { instance = this; } town = SceneManger.instance.interactedTown; InitialPop = true; // LoadTown(); }
public void spawnTroop(TownManager target) { sendTroopTarget = target; if (currentTroop > 1) { int tmpTroopSend = currentTroop - 1; currentTroop -= tmpTroopSend; troopToSend = tmpTroopSend; } }
public Manager() { repo_category = new CategoryManager(); repo_email = new EmailManager(); repo_team = new TeamManager(); repo_product = new ProductManager(); repo_member = new MemberManager(); repo_order = new OrderManager(); repo_city = new CityManager(); repo_town = new TownManager(); repo_offer = new OfferManager(); repo_orderdetail = new OrderDetailManager(); }
void Awake () { if (CombatData == null) { CombatData = new CombatData (); } TownManager = GetComponent<TownManager>(); _startupList = new List<IGameManager>(); _startupList.Add(TownManager); if (WorldDataStore == null) { foreach (IGameManager manager in _startupList) { manager.StartUp (); } WorldDataStore = new WorldDataStore (); Manager.WorldDataStore.storeTownsData (Manager.TownManager._towns); } else { Manager.TownManager.setTowns (Manager.WorldDataStore._towns); Manager.TownManager.UpdateTownsBasedOnCombatResults(); } }
// Use this for initialization void Start() { main = this; PartyManager.ENewWeekStart += DoEndOfWeekChanges; }
public override void Initialize() { HandleCommandLine(Environment.GetCommandLineArgs()); if (!Directory.Exists(SavePath)) Directory.CreateDirectory(SavePath); #if DEBUG Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false); #else Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All & ~LogLevel.Debug, false); #endif AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; try { if (File.Exists(Path.Combine(SavePath, "tshock.pid"))) { Log.ConsoleInfo( "TShock was improperly shut down. Please avoid this in the future, world corruption may result from this."); File.Delete(Path.Combine(SavePath, "tshock.pid")); } File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture)); ConfigFile.ConfigRead += OnConfigRead; FileTools.SetupConfig(); HandleCommandLine_Port(Environment.GetCommandLineArgs()); if (Config.StorageType.ToLower() == "sqlite") { string sql = Path.Combine(SavePath, "tshock.sqlite"); DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); } else if (Config.StorageType.ToLower() == "mysql") { try { var hostport = Config.MySqlHost.Split(':'); DB = new MySqlConnection(); DB.ConnectionString = String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", hostport[0], hostport.Length > 1 ? hostport[1] : "3306", Config.MySqlDbName, Config.MySqlUsername, Config.MySqlPassword ); } catch (MySqlException ex) { Log.Error(ex.ToString()); throw new Exception("MySql not setup correctly"); } } else { throw new Exception("Invalid storage type"); } Backups = new BackupManager(Path.Combine(SavePath, "backups")); Backups.KeepFor = Config.BackupKeepFor; Backups.Interval = Config.BackupInterval; Bans = new BanManager(DB); Warps = new WarpManager(DB); Users = new UserManager(DB); Groups = new GroupManager(DB); Groups.LoadPermisions(); Regions = new RegionManager(DB); Itembans = new ItemManager(DB); RememberedPos = new RemeberedPosManager(DB); Inventory = new InventoryManager(DB); HomeManager = new HomeManager(DB); ArmorShopManager = new ArmorShopManager(DB); WeaponShopManager = new WeaponShopManager(DB); ItemShopManager = new ItemShopManager(DB); BlockShopManager = new BlockShopManager(DB); OtherShopManager = new OtherShopManager(DB); Towns = new TownManager(DB); Chat = new ChatManager(DB); Restart = new RestartManager(); RestApi = new SecureRest(Netplay.serverListenIP, 8080); RestApi.Verify += RestApi_Verify; RestApi.Port = Config.RestApiPort; RestManager = new RestManager(RestApi); RestManager.RegisterRestfulCommands(); var geoippath = Path.Combine(SavePath, "GeoIP.dat"); if (Config.EnableGeoIP && File.Exists(geoippath)) Geo = new GeoIPCountry(geoippath); profiles = @"Z:\profiles\"; temp = @"Z:\profiles\temp\"; Console.Title = string.Format("TerrariaShock Version {0} ({1})", Version, VersionCodename); Log.ConsoleInfo(string.Format("TerrariaShock Version {0} ({1}) now running.", Version, VersionCodename)); GameHooks.PostInitialize += OnPostInit; GameHooks.Update += OnUpdate; ServerHooks.Connect += OnConnect; ServerHooks.Join += OnJoin; ServerHooks.Leave += OnLeave; ServerHooks.Chat += OnChat; ServerHooks.Command += ServerHooks_OnCommand; NetHooks.GetData += OnGetData; NetHooks.SendData += NetHooks_SendData; NetHooks.GreetPlayer += OnGreetPlayer; NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc; NpcHooks.SetDefaultsInt += OnNpcSetDefaults; ProjectileHooks.SetDefaults += OnProjectileSetDefaults; WorldHooks.StartHardMode += OnStartHardMode; WorldHooks.SaveWorld += OnSaveWorld; GetDataHandlers.InitGetDataHandler(); Commands.InitCommands(); if (Config.BufferPackets) PacketBuffer = new PacketBufferer(); Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes, 30, false); Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes * 2, 100, false); Users.DeletePlayersAfterMinutes(TShock.Config.DeleteUserAfterMinutes * 3, 10000, true); Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled")); Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled")); if (Initialized != null) Initialized(); } catch (Exception ex) { Log.Error("Fatal Startup Exception"); Log.Error(ex.ToString()); TShock.Backups.Backup(); Environment.Exit(1); } }