//only for use by the above 2 void setUnitStatsSaver(ref unitStats current_toy, unitStatsSaver toy, bool set_max_lvl) { int old_max_lvl = current_toy.getMaxLvl(); if (set_max_lvl) {// I HATE THIS SHIT if (toy.toy_id.toy_type == ToyType.Hero) { int new_max_lvl = Mathf.Max(toy.getMaxLvl(), old_max_lvl); foreach (Rune h in hero_toy_stats) { //if (h.toy_name.Equals(toy.name)) if (h.runetype == toy.toy_id.rune_type && h.toy_type == toy.toy_id.toy_type) { new_max_lvl = Mathf.Max(toy.getMaxLvl(), (int)h.getMaxLevel()); h.setMaxLevel(new_max_lvl); } } current_toy.setMaxLvl(new_max_lvl); } else { current_toy.setMaxLvl(toy.getMaxLvl()); } } else { current_toy.setMaxLvl(old_max_lvl); } }
public float _getSignalSize(unitStats s) { float size = 0.5f; float distance_bonus = 0f; if (s.toy_id.toy_type == ToyType.Temporary) { distance_bonus = StaticRune.GetDistanceBonus(s.name, islands[island_selected].transform.position, null); } if (s.toy_id.rune_type == RuneType.SensibleCity) { return(0.5f); } if (s != null) { size = StaticRune.time_bonus_aff(StaticStat.getBaseFactor(s.toy_id.rune_type, EffectType.Range, s.toy_id.toy_type == ToyType.Hero), EffectType.Range, s.toy_id.rune_type, s.toy_id.toy_type, distance_bonus) / 2f; } // Debug.Log("Getting signal size for " + selected + " got " + size + "\n"); return(size); }
public StateType canBuildToy(string name, Cost toy_cost, unitStats toy) { bool vocal = false; if (Central.Instance.getToy(name) == null) { if (vocal) { Debug.Log("Central does not know anything about " + name + "\n"); } return(StateType.No); } if (!Central.Instance.getToy(name).isUnlocked) { if (vocal) { Debug.Log("Peripeheral does not have toy " + name + "\n"); } return(StateType.No); } else if (!Peripheral.Instance.canBuildToy(toy)) { if (vocal) { Debug.Log(name + "toy needs a city or is a city and we have a city already\n"); } return(StateType.No); } else if (!peripheral.HaveResource(toy_cost)) { // if (vocal) Debug.Log("Can't afford " + name + "\n"); return(StateType.NoResources); } return(StateType.Yes); }
bool AttemptBuilt(BuildTower tower) { if (tower.done) { return(false); } unitStats stats = Central.Instance.getToy(tower.toy_id.rune_type, tower.toy_id.toy_type); string toy_name = stats.name; bool force = (force_all_towers || tower.force); if (canBuildTower(stats, force)) { Toy f = null; GameObject o = Peripheral.Instance.makeToy(toy_name, tower.island, !force, ref f, false); o.GetComponent <Toy>().my_tower_stats.name = tower.label; if (tower.toy_id.toy_type == ToyType.Temporary) { ghosts.Add(o.GetComponent <Toy>()); } if (tower.disable_tower) { StartCoroutine(DisableTower(o)); } tower.done = true; return(true); } return(false); }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOAD ACTORS public void LoadAllToys(InitLevel level) { for (int i = 0; i < level.toys.Length; i++) { unitStats actor = LoadToy(level.toys[i]); Central.Instance.setUnitStats(actor, true); } }
public wavelet(float mi, float ll, List <string> c, List <int> p) { monster_interval = mi; lull_length = ll; string monster = ""; int count = 0; int path = -1; int paths_length = p.Count; int path_count = 0; // Debug.Log("Paths length " + paths_length + "\n"); for (int i = 0; i < c.Count; i++) { string m = c[i]; // Debug.Log("m " + m + "\n"); if (int.TryParse(m, out count) || (!int.TryParse(m, out count) && monster != "")) { count = -1; int.TryParse(m, out count); if (count == -1) { Debug.LogError("Failed to parse line: " + c + "\n"); } if (!monster.Equals("")) { unitStats stats = Central.Instance.getToy(monster); if (stats != null) { while (count > 0) { monsters.Add(monster); monster_count++; paths.Add(path); count--; } monster = ""; } // else { Debug.Log("Trying to add invalid monster to wavelet " + monster + "\n"); } } } else { // Debug.Log("Got monster " + m + "\n"); monster = m; count = 1; if (path_count < paths_length) { path = p[path_count]; path_count++; } else { path = -1; } } } }
public int CompareTo(object obj) { if (obj == null) { return(1); } unitStats d = obj as unitStats; return(toy_id.CompareTo(d.toy_id)); }
public unitStats getToy(unitStats toy) { foreach (unitStats actor in actors) { if (actor.CompareTo(toy) == 0) { return(actor); } } return(null); }
public bool canBuildToy(unitStats toy) { if (toy.toy_id.rune_type == RuneType.SensibleCity && (have_cities || building_a_city)) { return(false); } if (toy.required_building.Equals("")) { return(true); } return(have_cities); }
public bool TowerBuild(MyPlayerEvent e) { if (e.event_complete) { return(true); } //unitStats stats = Central.Instance.getToy(tower.toy_id.rune_type, tower.toy_id.toy_type); unitStats stats = Central.Instance.getToy(e.attribute_1); string toy_name = stats.name; bool force = true; if (force || canBuildTower(stats, force)) { Toy f = null; Island_Button island = Monitor.Instance.getIslandByID(e.attribute_2); if (island == null) { Debug.LogError("Could not locate island " + e.attribute_2 + " for tower " + e.attribute_1 + "\n"); return(false); } GameObject o = Peripheral.Instance.makeToy(toy_name, island, true, ref f, true); Toy toy = o.GetComponent <Toy>(); toy.my_tower_stats.name = e.metric_1.ToString(); if (toy.toy_type == ToyType.Temporary) { ghosts.Add(toy); } else { toys.Add(toy); } if (toy.toy_type == ToyType.Hero) { loadHeroSkills(skills_and_inventory, toy.runetype); } e.event_complete = true; return(true); } else { Debug.LogError("Could not build tower " + e.attribute_2 + " for tower " + e.attribute_1 + "\n"); return(false); } return(false); }
public void setUnitStats(unitStats toy, bool set_max_lvl) { unitStats current_toy = getToy(toy); // toy.setActive(toy.toy_type != ToyType.Temporary); if (current_toy != null) { current_toy = toy; setUnitStatsSaver(ref current_toy, toy.getSnapshot(), set_max_lvl); return; } actors.Add(toy); }
public void setUnitStats(unitStatsSaver toy, bool set_max_lvl) { unitStats current_toy = getToy(toy.toy_id.rune_type, toy.toy_id.toy_type); if (current_toy != null) { setUnitStatsSaver(ref current_toy, toy, set_max_lvl); return; } else { Debug.LogError("Could not set actor stats from actorStatsSaver for toy " + toy.name + "\n"); } }
public bool SelectToy(string toy, RuneType rune, bool quietly) { // Debug.Log("Select toy " + toy + "\n") ; if (toy == null) { toy = ""; } if (toy.Equals(toy_selected)) { return(toy_selected.Equals("")); } if (toy.Equals("")) { toy_selected = null; SetAllowedRange(""); if (!quietly && onSelected != null) { onSelected(SelectedType.Toy, ""); } return(false); } else { rune_selected = rune; unitStats stats = Central.Instance.getToy(toy); if (stats == null) { return(false); } toy_selected = new SelectedToy(toy, stats.island_type); SetAllowedRange(toy_selected.name); if (!quietly && onSelected != null) { onSelected(SelectedType.Toy, toy_selected.name); } return(true); } }
public unitStats LoadToy(InitToy toy) { unitStats test = Central.Instance.getToy(toy.name); if (test != null) { if (toy.hasMaxLvl()) { test.setMaxLvl(toy.max_lvl); } return(test); } else { Debug.LogError("THIS IS NOT SUPPORTED YET WHY ARE YOU DOING THIS STOP\n"); return(null); } }
bool canBuildTower(unitStats toy, bool force) { Cost toy_cost = null; float cost = 9999; if (toy != null) { toy_cost = toy.cost_type; } if (toy_cost != null) { cost = toy_cost.Amount; } StateType answer = EagleEyes.Instance.canBuildToy(toy.name, toy_cost, toy); return((!force && answer == StateType.Yes) || (force && answer != StateType.No)); }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOAD ACTORS public string oldLoadActors(string what) { string line = file.Dequeue(); while (line != null && !line[0].Equals(':')) { if (what.Equals("Toys")) { unitStats actor = LoadActor(line); line = file.Dequeue(); Central.Instance.setUnitStats(actor, true); } else { enemyStats enemy = LoadEnemy(line); line = file.Dequeue(); Central.Instance.enemies.Add(enemy); Peripheral.Instance.haveMonsters.Add(enemy.name, true); } } return(line); }
public unitStats LoadActor(string line) { // Debug.Log("Loading actor\n"); JSONObject pname = new JSONObject(); JSONObject pcost = new JSONObject(); JSONObject ptoytype = new JSONObject(); //JSONObject pcost_runetype = new JSONObject (); JSONObject prune_type = new JSONObject(); JSONObject pcost_wishtype = new JSONObject(); JSONParser p = new JSONParser(line); JSONObject ppermanent = new JSONObject(); JSONObject pammo = new JSONObject(); JSONObject inv = new JSONObject(); JSONObject pmax_lvl = new JSONObject(); JSONObject exclude_skills = new JSONObject(); JSONObject required_building = new JSONObject(); p.parse(); p.root.TryGetValue("name", out pname); p.root.TryGetValue("cost", out pcost); p.root.TryGetValue("toy_type", out ptoytype); p.root.TryGetValue("rune_type", out prune_type); p.root.TryGetValue("cost_wishtype", out pcost_wishtype); p.root.TryGetValue("max_lvl", out pmax_lvl); p.root.TryGetValue("ammo", out pammo); p.root.TryGetValue("inventory", out inv); p.root.TryGetValue("islandtype", out ppermanent); p.root.TryGetValue("exclude_skills", out exclude_skills); p.root.TryGetValue("required_building", out required_building); unitStats test = Central.Instance.getToy(pname.value); if (test != null) { if (pmax_lvl != null) { test.setMaxLvl(int.Parse(pmax_lvl.value)); } // Debug.Log("Loading actor again\n"); //thing has already been defined in a previous level. do not load most stats again return(test); } else { int cost = int.Parse(pcost.value); unitStats stats = new unitStats(pname.value); if (pmax_lvl != null) { stats.setMaxLvl(int.Parse(pmax_lvl.value)); } stats.isUnlocked = false; RuneType rune_type = (prune_type != null) ? EnumUtil.EnumFromString(prune_type.value, RuneType.Null) : RuneType.Null; ToyType toy_type = (ptoytype != null) ? EnumUtil.EnumFromString(ptoytype.value, ToyType.Null) : ToyType.Null; //WishType wish_type = WishType.Null; CostType cost_type = CostType.Dreams; stats.toy_id.toy_type = toy_type; stats.toy_id.rune_type = rune_type; cost_type = TowerStore.costType(rune_type, toy_type); //if (pcost_wishtype != null) wish_type = Get.WishTypeFromString(pcost_wishtype.value); if (required_building != null) { stats.required_building = (required_building.value); } stats.setCost(cost_type, cost); stats.island_type = ppermanent != null?EnumUtil.EnumFromString(ppermanent.value, IslandType.Permanent) : IslandType.Permanent; if (pammo != null) { stats.ammo = int.Parse(pammo.value); } Central.Instance.setUnitStats(stats, false); return(stats); } }
public void UpdateToyButtons(string mytoy, ToyType kind, bool reset) { bool vocal = false; string selected_toy = peripheral.getSelectedToy(); if (current_GUIState.state != GameState.InGame) { //Debug.Log("UpdateToyButtons is in " + current_GUIState.state + ", not in game state!\n"); return; } if (vocal) { Debug.Log("UpdateToyButtons running " + kind + "\n"); } // Debug.Log("Beep\n"); foreach (MyLabel l in current_GUIState.labels) { if (l == null || l.toytype == ToyType.Null) { continue; } if (l.toytype != kind && kind != ToyType.Null) { continue; } if (reset) { l.ResetButton(); } string name = l.content; float cost = 9999; unitStats toy = central.getToy(name); Cost toy_cost = null; if (toy != null) { toy_cost = toy.cost_type; } if (toy_cost != null) { cost = toy_cost.Amount; } if (cost == 9999) { Debug.Log("Getting name " + name + " " + l.gameObject.name + "\n"); return; } switch (canBuildToy(name, toy_cost, toy)) { case StateType.No: if (vocal) { Debug.Log("Turning off toy No " + l.content + "\n"); } l.SetActive(false); break; case StateType.NoResources: if (vocal) { Debug.Log("Turning off toy NoResources " + l.content + "\n"); } l.SetActive(true); ClearInfo(); SetRowButton(l, false, false); if (mytoy.Equals(name)) { Central.Instance.button_selected = null; // is this used??!! } break; case StateType.Yes: if (vocal) { Debug.Log("Turning on toy " + l.content + "\n"); } l.SetActive(true); if (vocal) { Debug.Log("Turning on thing " + selected_toy + " == " + name + "\n"); } if (selected_toy == name) { if (l != null) { l.SetSelected(true, true); } if (l != null) { l.SetInteractable(true); } } else { //if (l != null) l.SetSelected(true, false); if (l != null) { l.SetInteractable(true); } } break; } string[] vars = new string[2]; vars[0] = name; vars[1] = cost.ToString(); StartCoroutine("DoOnPriceUpdate", vars); } }
void OnInput(bool is_click) { if (Central.Instance.getState() != GameState.InGame) { return; } //bool drag_mode = EagleEyes.Instance.floating_tower_scroll_driver.DragMode(); bool drag_mode = Monitor.Instance.my_spyglass.isDisabledByDragButton(); if (!drag_mode) { Monitor.Instance.my_spyglass.InitiateSpyglass(); } if (block != null && block.gameObject.activeSelf == false) { block = null; } if (blocked && block == null && my_toy == null) { blocked = false; } if (drag_mode && blocked) { return; } if (my_toy != null) { if (onSelected != null) { onSelected(SelectedType.Island, parent.name); } return; } if (!drag_mode && blocked) { if (onSelected != null) { onSelected(SelectedType.Island, parent.name); } return; } Selected_toy = ""; string selected = peripheral.getSelectedToy(); if (is_click && onSelected != null) { onSelected(SelectedType.DirectIsland, parent.name);//when tapping an empty island, deselect everything else, only need bool is_click for mouse, not an issue for phone? } // if (is_click && !blocked && selected != null) Noisemaker.Instance.Click(ClickType.Success); unitStats stats = Central.Instance.getToy(selected); if (stats == null) { //I DON'T KNOW // if (is_click && onSelected != null) onSelected(SelectedType.DirectIsland, parent.name);//when tapping an empty island, deselect everything else, only need bool is_click for mouse, not an issue for phone? return; } if (stats.island_type != IslandType.Either && stats.island_type != island_type) { return; } if (selected != "") { Selected_toy = verify_toy_for_distance(selected); } if (drag_mode && onSelected != null) { onSelected(SelectedType.Island, parent.name); } }
/* * public void StopTween(GameObject obj){ * Tweener[] stopme = obj.GetComponentsInChildren<Tweener> (); * for (int i = 0; i < stopme.Length; i++) * { * stopme[i].StopMe(); * } * } */ public void Do() { // Debug.Log("Doing gameaction " + this._type + " " + this.name + " " + _text + "\n"); switch (_type) { case ActionType.UIFilter: if (_name.Equals("")) { EagleEyes.Instance.ResetUIFilter(); } else { EagleEyes.Instance.SetUIFilter(_name, _text); } break; case ActionType.SetSensibleWishUplift: Peripheral.Instance.getLevelMod().sensible_wish_uplift = _number; break; case ActionType.Panel: if (Peripheral.Instance == null) { Debug.Log("NO PERIPHERAL\n"); return; } if (Peripheral.Instance.zoo == null) { Debug.Log("NO ZOO\n"); return; } GameObject panel = Peripheral.Instance.zoo.getObject(_name, true); if (panel == null) { Debug.LogError("GameAction could not find object " + _name + "\n"); } if (!_bool) { panel.transform.SetParent(EagleEyes.Instance.events.transform); } else { panel.transform.SetParent(EagleEyes.Instance.world_space_events.transform); } panel.gameObject.transform.GetChild(0).gameObject.SetActive(true); panel.transform.localPosition = Vector3.zero; panel.transform.localScale = Vector3.one; panel.transform.localRotation = Quaternion.identity; break; case ActionType.ShowIslands: Debug.Log("Show islands " + _name + " " + _bool); IslandType type = EnumUtil.EnumFromString <IslandType>(_name, IslandType.Null); if (type == IslandType.Null) { Debug.LogError("Event trying to show (" + _bool + ")islands of invalid type: " + _name + "\n"); return; } Monitor.Instance.ShowIslandSprites(_bool, type); break; case ActionType.EnemyDescription: GameObject enemy_desc = Peripheral.Instance.zoo.getObject("Tutorial/Descriptions/generic_enemy_description", true); if (enemy_desc == null) { Debug.LogError("GameAction could not find object " + _name + "\n"); } enemy_desc.transform.SetParent(EagleEyes.Instance.events.transform); enemy_desc.gameObject.transform.GetChild(0).gameObject.SetActive(true); enemy_desc.transform.localPosition = Vector3.zero; enemy_desc.transform.localScale = Vector3.one; enemy_desc.transform.localRotation = Quaternion.identity; enemy_desc.GetComponent <EnemyDescriptionLabel>().setType(_text); RectTransform b = enemy_desc.GetComponent <EnemyDescriptionButton>().button; Vector3 pos = b.localPosition; pos.y += _number * -6.5f; //Debug.Log(_number + "\n"); b.localPosition = pos; break; case ActionType.MakeFloaty: //GameObject floaty = Peripheral.Instance.zoo.getObject(_name, true); //if (floaty == null) { Debug.Log("GameAction could not find object " + _name + "\n"); } // floaty.GetComponent<Floaty>().Init(_vector); break; case ActionType.AddWish: WishType w = Get.WishTypeFromString(_text); // Debug.Log("We should add a wish " + _text + " " + w + "\n"); Peripheral.Instance.my_inventory.AddWish(w, _number, 1); break; case ActionType.AddDream: if (_number <= 0) { return; } Peripheral.Instance.addDreams(_number, Vector3.zero, false); break; case ActionType.GiveSpecialSkill: EffectType effect_type = EnumUtil.EnumFromString <EffectType>(_name, EffectType.Null); RuneType rune_type = EnumUtil.EnumFromString <RuneType>(_text, RuneType.Null); Rune r = Central.Instance.getHeroRune(rune_type); if (r == null) { Debug.LogError("Cannot find a rune for hero of type " + rune_type + ", cannot give skill " + effect_type + "\n"); } r.GiveSpecialSkill(effect_type); break; case ActionType.MakeWish: List <Wish> inv = new List <Wish>(); inv.Add(new Wish(WishType.Sensible, 0.2f * _number)); inv.Add(new Wish(WishType.MoreDamage, 0.1f * _number)); inv.Add(new Wish(WishType.MoreXP, 015f * _number)); inv.Add(new Wish(WishType.MoreDreams, 0.1f * _number)); inv.Add(new Wish(WishType.MoreHealth, 0.1f * _number)); if (onMakeWish != null) { onMakeWish(inv, _vector); } Debug.Log("We should make a wish\n"); break; case ActionType.Pause: Peripheral.Instance.Pause(true); break; case ActionType.Resume: // Debug.Log("Resuming\n"); Peripheral.Instance.Pause(false); break; case ActionType.DisableMonitor: Monitor.Instance.is_active = _bool; break; case ActionType.HideUIElement: //name is include, //text is exclude // Debug.Log("Setting " + _name + " to " + _bool + "\n"); EagleEyes.Instance.PlaceElement(_name, _bool); break; case ActionType.DisableUIElement: //name is include, //text is exclude //BUTTON HAS TO BE in GUI STATES WITH A MYLABEL EagleEyes.Instance.DisableElement(_name, _bool); //EagleEyes.Instance.SetEnableButtons(_name, _text, _bool); break; case ActionType.RemoveEventObjects: RemoveEventObjects(); break; case ActionType.UnlockToy: Debug.Log("Unlocking toy " + _text + "\n"); //Peripheral.Instance.ActivateToy(_text); unitStats toy = Central.Instance.getToy(_text); toy.isUnlocked = true; EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Null, false); break; case ActionType.PointSpyGlass: if (Monitor.Instance != null) { Monitor.Instance.my_spyglass.PointSpyglass(_vector, true); } break; case ActionType.EnableSpyGlass: if (Monitor.Instance != null) { Monitor.Instance.my_spyglass.DisableByEvent(!_bool); } break; case ActionType.RemoveObject: if (_target != null) { foreach (GameObject t in _target) { Peripheral.Instance.zoo.returnObject(t); } } if (_name != null) { Debug.Log("GameAction removing object with name, TERRIBLE\n"); } Peripheral.Instance.zoo.returnObject(GameObject.Find(_name)); break; case ActionType.EnableReward: RewardType rt = EnumUtil.EnumFromString <RewardType>(_text, RewardType.Null); if (rt != RewardType.Null) { RewardOverseer.RewardInstance.EnableReward(rt); } else { Debug.LogError(this.gameObject.name + " RewardType gameAction has an invalid rewardType( " + _text + ")\n"); } break; default: Debug.LogError(this.gameObject.name + " " + _type + " gameAction has an unsupported ActionType\n"); break; } }
public void UpdatePanel(Island_Button button) { if (button == null && selected_island == null) { return; } if (button != null && selected_island != null && button.gameObject.GetInstanceID() == selected_island.gameObject.GetInstanceID()) { return; } if (button == null) { selected_island = null; selected_island_image.gameObject.SetActive(false); my_panel.gameObject.SetActive(false); return; } //if (selected_island != null && button.gameObject.GetInstanceID() != selected_island.gameObject.GetInstanceID()) ResetSelected(); selected_island = button; bool temp_ok = false; temp_ok = (selected_island.island_type == IslandType.Permanent || (selected_island.island_type == IslandType.Temporary && Monitor.Instance.SetAllowedRange("sensible_city"))); int ok_buttons = 0; EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Normal, true); foreach (MyLabel label in my_panel.list) { if (!label.AmIActive()) { label.SetHidden(true); continue; } unitStats stats = Central.Instance.getToy(label.runetype, label.toytype); if (stats != null) { if (stats.island_type != IslandType.Either && stats.island_type != selected_island.island_type) { label.SetHidden(true); label.ShowButtons(false); continue; } if (stats.island_type == IslandType.Temporary) { if (!temp_ok) { label.SetHidden(true); label.ShowButtons(false); continue; } string ok = selected_island.verify_toy_for_distance(label.content); if (ok.Equals("TOOFAR")) { label.SetHidden(true); label.ShowButtons(false); continue; } } //if (label.button.IsInteractable()){ label.SetHidden(false); label.ShowButtons(true); ok_buttons++; /* * }else{ * label.SetHidden(true); * label.ShowButtons(false); * }*/ } } Vector3 set_to = button.transform.position; if (ok_buttons > 0) { my_panel.transform.position = set_to; my_panel.gameObject.SetActive(true); my_panel.radius = (ok_buttons <= 6) ? 1.2f : (ok_buttons == 7) ? 1.35f : (ok_buttons == 8) ? 1.5f : 1.6f; my_panel.spacing = 2f * Mathf.PI * my_panel.radius / ok_buttons; my_panel.UpdatePanel(); // if (Monitor.Instance != null) Monitor.Instance.my_spyglass.PointSpyglass(button.transform.position,.20f); selected_island_image.gameObject.SetActive(true); selected_island_image.transform.position = set_to; } else { selected_island_image.gameObject.SetActive(false); Noisemaker.Instance.Play("island_too_far"); ShowNoResourcesPopup(set_to); } }
public float getSignalSize(string selected) { unitStats s = Central.Instance.getToy(selected); return(_getSignalSize(s)); }
public float getSignalSize(RuneType runeType, ToyType toyType) { unitStats s = Central.Instance.getToy(runeType, toyType); return(_getSignalSize(s)); }
public void initStats(unitStats s, Vector3 scaleV, Island_Button i, string _name, Rune _rune) { tilesize = i.getPeripheral().tileSize; stats = s; float dmg_base = 0; my_name = _name; my_tower_stats = new tower_stats(); my_tower_stats.island_name = string.Copy(i.ID); my_tower_stats.wave_time = Moon.Instance.TIME; my_tower_stats.initSkillStats(runetype); if (building.tower_visual) { building.tower_visual.updateVisuals(); building.tower_visual.setSprite(true); } Rune.onUpgrade += onUpgrade; float bonus = 0f; // float bonus = StaticRune.GetDistanceBonus(my_name, this.transform.position, this); Debug.Log($"TOY Initializing {toy_type} {runetype}\n"); if (_rune == null || toy_type != ToyType.Hero) { rune = new Rune(); SetBonus(bonus); int max_lvl = LevelStore.getMaxLevel(Central.Instance.current_lvl, Peripheral.Instance.difficulty, runetype, toy_type); rune.initStats(runetype, max_lvl, toy_type); Debug.Log($"TOY Initializing {toy_type} {runetype} new rune lvl {max_lvl}\n"); } else { SetBonus(bonus); rune = _rune; rune.UpdateStats(); Debug.Log($"TOY Initializing {toy_type} {runetype} EXISTING rune lvl {rune.getMaxLevel()}\n"); } Active = true; island = i; rune.ID = this.gameObject.GetInstanceID(); center.localPosition = Vector3.Scale(center.localPosition, scaleV); // my_toy.center.localPosition = Vector3.Scale(my_toy.center.localPosition, scaleV); transform.transform.localRotation = Quaternion.identity; building.initStats(this); // // if (rune.level > 0 && rune_buttons != null) rune_buttons.UpdateMe(); if (parent_toy != null) { parent_toy.AddTargetToy(this); } if (toy_type == ToyType.Hero) { //rune.InitHero(Central.Instance.current_lvl);//for testing, gives hero some xp based on current level, if xp is 0 // also sensible hero comes with airattack for free, done by an event in 02level_scene rune.setMaxLevel((int)Mathf.Max(Central.Instance.getToy(my_name).getMaxLvl(), rune.getMaxLevel())); } if (firearm != null) { firearm.initStats(this); } //if (rune_buttons != null) rune_buttons.UpdateMe(); // ghost towers don't get their own rune buttons TIME_AT_START = Time.time; }
public GameObject makeToy(string toy_name, Island_Button island_b, bool check_cost, ref Toy _toy, bool force) { unitStats my_stats = Central.Instance.getToy(toy_name); Cost my_cost_type = my_stats.cost_type; if (!force && check_cost && my_cost_type.type != CostType.Dreams) { if (!HaveResource(my_stats.cost_type)) { Debug.Log("Cannot afford toy " + toy_name + " of type " + my_cost_type + " for " + my_cost_type.Amount + " cost\n"); return(null); } } _toy = InitToyObj(island_b, toy_name, false); GameObject toy_obj = _toy.gameObject; if (_toy.target_toys.Length > 0) { toy_parents.Add(_toy); } if (_toy.firearm != null) { firearms.Add(_toy.firearm); } island_b.my_toy = _toy; _toy.my_name = toy_name; Rune rune = null; bool new_hero = false; if (_toy.toy_type == ToyType.Hero) { Rune have = Central.Instance.getHeroStats(_toy.runetype); if (have != null) { rune = have; } else { new_hero = true; } } if (_toy != null) { _toy.initStats(my_stats, Vector3.one, island_b, toy_name, rune); } if (_toy.building) { _toy.building.StartConstruction(); } // Debug.Log("NEW TOY cost toytype " + my_cost_type.toytype + "\n"); _toy.name = toy_name + "|" + all_toys; _toy.rune.order = all_toys; all_toys++; if (check_cost || my_cost_type.isHero()) { if (my_cost_type.type == CostType.Dreams) { if (_toy.runetype != RuneType.Modulator) { incrementToys(); } addDreams(-my_cost_type.Amount, toy_obj.transform.position, false); Central.Instance.updateCost(toys); // if (Central.Instance.getToy(toy_name).cost_type.cost > dreams) { SelectToy(""); } } else if (my_cost_type.type == CostType.Wishes) { my_inventory.AddWish(WishType.Sensible, -my_cost_type.Amount, 1); } else if (my_cost_type.isHero()) { SetHeroPoint(my_cost_type.getHeroRuneType(), 0, true); SelectToy(null, RuneType.Null); } } if (onPlacedToy != null) { onPlacedToy(_toy.my_name, _toy.runetype, _toy.toy_type); } if (new_hero) { Central.Instance.hero_toy_stats.Add(_toy.rune); } if (check_cost) { Noisemaker.Instance.Play("make_tower"); } if (check_cost) { Tracker.Log(PlayerEvent.TowerBuilt, true, customAttributes: new Dictionary <string, string>() { { "attribute_1", _toy.my_name }, { "attribute_2", island_b.ID } }, customMetrics: new Dictionary <string, double>() { { "metric_1", _toy.rune.order } }); } return(toy_obj); }
public static unitStats getBasicStats(RuneType runetype, ToyType toytype) { unitStats stats = null; switch (runetype) { case RuneType.Sensible: if (toytype != ToyType.Hero) { stats = new unitStats("sensible_tower", runetype, toytype); stats.setCost(costType(runetype, toytype), 40); } else { stats = new unitStats("sensible_tower_hero", runetype, toytype); stats.setCost(costType(runetype, toytype), 1); } stats.island_type = IslandType.Permanent; break; case RuneType.Airy: if (toytype != ToyType.Hero) { stats = new unitStats("airy_tower", runetype, toytype); stats.setCost(costType(runetype, toytype), 30); } else { stats = new unitStats("airy_tower_hero", runetype, toytype); stats.setCost(costType(runetype, toytype), 1); } stats.island_type = IslandType.Permanent; break; case RuneType.Vexing: if (toytype != ToyType.Hero) { stats = new unitStats("vexing_tower", runetype, toytype); stats.setCost(costType(runetype, toytype), 50); } else { stats = new unitStats("vexing_tower_hero", runetype, toytype); stats.setCost(costType(runetype, toytype), 1); } stats.island_type = IslandType.Permanent; break; case RuneType.Castle: stats = new unitStats("castle", runetype, toytype); stats.setCost(costType(runetype, toytype), 9999); stats.island_type = IslandType.Permanent; break; case RuneType.SensibleCity: stats = new unitStats("sensible_city", runetype, toytype); stats.setCost(costType(runetype, toytype), 20); stats.island_type = IslandType.Permanent; break; case RuneType.Modulator: stats = new unitStats("modulator", runetype, toytype); stats.setCost(costType(runetype, toytype), 5); stats.island_type = IslandType.Either; break; case RuneType.Fast: stats = new unitStats("sensible_tower_ghost", runetype, toytype); stats.setCost(costType(runetype, toytype), 2); stats.island_type = IslandType.Temporary; stats.required_building = "sensible_city"; stats.ammo = 5; break; case RuneType.Slow: stats = new unitStats("slow_ghost", runetype, toytype); stats.setCost(costType(runetype, toytype), 2); stats.island_type = IslandType.Temporary; stats.required_building = "sensible_city"; stats.ammo = 5; break; case RuneType.Time: stats = new unitStats("time_ghost", runetype, toytype); stats.setCost(costType(runetype, toytype), 2); stats.island_type = IslandType.Temporary; stats.required_building = "sensible_city"; stats.ammo = 5; break; } stats.isUnlocked = false; /* * * { "name":"castle", "toy_type": "hero", "cost":"9999", "scale":{ "x":"2","z":"2"},"rune_type":"Castle"} * { "name":"sensible_city", "toy_type": "normal", "cost":"20", "scale":{ "x":"2","z":"2"},"rune_type":"SensibleCity"} * { "name":"sensible_tower", "toy_type": "normal", "cost":"40", "rune_type":"Sensible"} * { "name":"airy_tower", "toy_type": "normal", "cost":"30", "rune_type":"Airy"} * { "name":"vexing_tower", "toy_type": "normal", "cost":"50", "rune_type":"Vexing"} * { "name":"sensible_tower_hero", "toy_type": "hero", "cost":"1", "rune_type":"Sensible"} * { "name":"airy_tower_hero", "toy_type": "hero", "cost":"1","rune_type":"Airy"} * { "name":"vexing_tower_hero", "toy_type": "hero", "cost":"1","rune_type":"Vexing"} * { "name":"sensible_tower_ghost","toy_type": "temporary","cost":"2","ammo":"5", "required_building":"sensible_city","islandtype":"temporary","rune_type":"Fast"} * { "name":"slow_ghost", "toy_type": "temporary","cost":"2","ammo":"5", "required_building":"sensible_city","islandtype":"temporary","rune_type":"Slow"} * { "name":"time_ghost", "toy_type": "temporary","cost":"2","ammo":"5","required_building":"sensible_city","islandtype":"temporary","rune_type":"Duration"} * { "name":"modulator", "toy_type": "normal" ,"cost":"5","islandtype":"either","rune_type":"Modulator"} */ return(stats); }