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; }