public ToySaver(string _name, float _ammo, RuneSaver _rune, ToyType _type, float _construction_time, tower_stats _tower_stats) { toy_name = _name; ammo = _ammo; rune_saver = _rune; type = _type; construnction_time = _construction_time; tower_stats = _tower_stats; }
void EquipTowers(TOWER_TYPE type, int upgradeLevel) { tower_stats stats = upgradePaths[type][upgradeLevel]; leftTower = Instantiate(stats.towerPrefab, transform.position + leftTowerOffset, Quaternion.identity); rightTower = Instantiate(stats.towerPrefab, transform.position + rightTowerOffset, Quaternion.identity); SetStats(leftTower, stats); SetStats(rightTower, stats); }
void SetStats(GameObject tower, tower_stats stats) { tower_controller controller = tower.GetComponent <tower_controller>(); controller.type = stats.type; controller.bulletPrefab = stats.bulletPrefab; controller.numBullets = stats.numBullets; controller.bullet_damage = stats.damage; controller.fire_rate = stats.fireRate; }
public tower_stats addTowerStats(Toy firearm) { tower_stats hey = new tower_stats(); hey.ID = firearm.GetInstanceID(); hey.name = firearm.gameObject.name; tower_snapshot.Add(hey); return(hey); }
public void loadSnapshot(ToySaver saver) { rune = new Rune(); rune.loadSnapshot(saver.rune_saver); building.loadSnapshot(saver); if (firearm != null) { firearm.loadSnapshot(saver); } if (rune_buttons != null) { rune_buttons.UpdateMe(); } rune.UpdateStats(); #if UNITY_EDITOR my_tower_stats = saver.tower_stats.DeepClone(); #else //ugh awkward my_tower_stats = new tower_stats(); my_tower_stats.island_name = string.Copy(island.transform.parent.name); my_tower_stats.wave_time = Moon.Instance.TIME; my_tower_stats.initSkillStats(runetype); #endif }
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; }