private void Awake() { _magnetic = GetComponent <Magnetic>(); _magnetic.OnPull += _onPlayerPull_Magnetic; _currentState = KlunkState.None; _currentFuel = _maxFuel; OnCurrentFuelChange?.Invoke((float)_currentFuel / _maxFuel); _currentEnergy = _maxEnergy; OnCurrentEnergyChange?.Invoke((float)_currentEnergy / _maxEnergy); _fuelPerSecond = (float)_maxFuel / _fuelTimeDuration; _rechargePerSecond = (float)_maxEnergy / _totalTimeToReloadFullEnergy; _frontAttack = GetComponentInChildren <FrontAttack>(); _frontAttack.gameObject.SetActive(false); _frontAttack.OnTriggerEnterEvent += _frontAttackChecker_OnTriggerEnterEvent; _characterController = GetComponent <KlunkCharController>(); _frictionController = GetComponent <FrictionController>(); var playerInput = GetComponent <PlayerInput>(); _actionMove = playerInput.actions["Move"]; _actionJump = playerInput.actions["Jump"]; _actionJump.performed += _actionJump_performed; _actionJump.canceled += _actionJump_canceled; _actionMov1 = playerInput.actions["Mov1"]; _actionMov2 = playerInput.actions["Mov2"]; _actionMov2.performed += _actionMov2_performed; _actionMov2.canceled += _actionMov2_canceled; inGameUIController = FindObjectOfType <InGameUIController>(); }
public CreatureData(string name, int hitPoints, int level, int experiencePoints, int maxDamage, FrontAttack frontAttack, List <DamageType> types, List <string> sounds, List <Loot> loot) { Name = name; HitPoints = hitPoints; Level = level; ExperiencePoints = experiencePoints; MaxDamage = maxDamage; Sounds = sounds; FrontAttack = frontAttack; Types = types; Loot = loot; }
public CreatureData(string name, int hitPoints, int experiencePoints, int summonMana, int convinceMana, int maxDamage, bool canIllusion, bool canSeeInvisible, FrontAttack frontAttack, List <DamageType> immunities, List <DamageModifier> strenghts, List <DamageModifier> weakness, List <string> sounds, List <Loot> loot) { Name = name; HitPoints = hitPoints; ExperiencePoints = experiencePoints; SummonMana = summonMana; ConvinceMana = convinceMana; MaxDamage = maxDamage; CanIllusion = canIllusion; CanSeeInvisible = canSeeInvisible; Immunities = immunities; Strengths = strenghts; Weaknesses = weakness; Sounds = sounds; FrontAttack = frontAttack; Loot = loot; }
private static void ParseCreature(string html) { html = Regex.Replace(html, "<(.|\n)*?>", ""); html = html.Replace(" ", "").Replace("&", "").Replace("and", ",").Replace("?", ""); int hitPoints = -1; int.TryParse(RegexGetGroup(html, @"^(.*?) Hit points"), out hitPoints); int experiencePoints = -1; int.TryParse(RegexGetGroup(html, @"^(.*?) Experience points per kill"), out experiencePoints); string[] summon = RegexGetGroup(html, @"Summon/Convince:$\n^(.*?)$").Replace("(", "").Replace(")", "").Replace(" ", "/").Split('/'); int summonMana = -1; int convinceMana = -1; if (summon.Length >= 2) { int.TryParse(RegexGetGroup(html, summon[0]), out summonMana); int.TryParse(RegexGetGroup(html, summon[1]), out convinceMana); } int maxDamage = -1; int.TryParse(RegexGetGroup(html, @"Est. Max. Damage:$\n^(.*?)\shp per turn$"), out maxDamage); bool canIllusion = (summon.Length > 2); string immunities = RegexGetGroup(html, @"Immune To:$\n^(.*?)$"); bool canSeeInvisible = immunities.Contains("Invisibility"); string strenghts = RegexGetGroup(html, @"Strong To:$\n^(.*?)$"); string weakness = RegexGetGroup(html, @"Weak To:$\n^(.*?)$"); string abilities = RegexGetGroup(html, @"Abilities:$\n^(.*?)$"); string sounds = RegexGetGroup(html, @"Sounds:$\n^(.*?)$").Trim('.').Replace("\"", ""); string loot = RegexGetGroup(html, @"Loot:$\n^(.*?)$"); FrontAttack frontAttack = (abilities.Contains("wave") && abilities.Contains("beam")) ? FrontAttack.Both : (abilities.Contains("wave")) ? FrontAttack.Wave : (abilities.Contains("beam")) ? FrontAttack.Beam : (abilities.Contains("strike")) ? FrontAttack.Strike : FrontAttack.None; MainTextWriter.Write(hitPoints.ToString() + ", "); MainTextWriter.Write(experiencePoints.ToString() + ", "); MainTextWriter.Write(summonMana.ToString() + ", "); MainTextWriter.Write(convinceMana.ToString() + ", "); MainTextWriter.Write(maxDamage.ToString() + ", "); MainTextWriter.Write(canIllusion.ToString().ToLower() + ", "); MainTextWriter.Write(canSeeInvisible.ToString().ToLower() + ", "); MainTextWriter.WriteLine("FrontAttack." + frontAttack.ToString() + ", "); string buffer; buffer = ""; MainTextWriter.Write(" new List<DamageType>() { "); foreach (string i in immunities.Split(',')) { string s = i.Trim(); s = s.Split(' ')[0].Replace("?", ""); if (DamageTypes.Contains(s)) { buffer += "DamageType." + s + ","; } } buffer = buffer.Trim(',').Replace(",", ", "); MainTextWriter.WriteLine(buffer + "},"); buffer = ""; MainTextWriter.Write(" new List<DamageModifier>() { "); foreach (string i in strenghts.Split(',')) { string s = i.Trim(); int percent = -1; int.TryParse(RegexGetGroup(s, @"\((.*?)\)").Trim("-+%".ToCharArray()), out percent); s = s.Split(' ')[0].Replace("?", ""); if (DamageTypes.Contains(s)) { buffer += "new DamageModifier(DamageType." + s + ", " + percent + "),"; } } buffer = buffer.Trim(',').Replace(",", ", "); MainTextWriter.WriteLine(buffer + "},"); buffer = ""; MainTextWriter.Write(" new List<DamageModifier>() { "); foreach (string i in weakness.Split(',')) { string s = i.Trim(); int percent = -1; int.TryParse(RegexGetGroup(s, @"\((.*?)\)").Trim("-+%".ToCharArray()), out percent); s = s.Split(' ')[0].Replace("?", ""); if (DamageTypes.Contains(s)) { buffer += "new DamageModifier(DamageType." + s + ", " + percent + "),"; } } buffer = buffer.Trim(',').Replace(",", ", "); MainTextWriter.WriteLine(buffer + " },"); buffer = ""; MainTextWriter.Write(" new List<string>() { "); foreach (string i in sounds.Split(';')) { if (string.Compare(i, "none", true) == 0) { break; } buffer += "\"" + i.Trim() + "\", "; } buffer = buffer.Trim(',').Replace(",", ", "); MainTextWriter.WriteLine(buffer + "},"); buffer = ""; MainTextWriter.Write(" new List<Loot>() { "); loot = loot.Replace("gp", "Gold Coin"); foreach (string i in loot.Split(',')) { string s = i.Trim().Split('.')[0]; string p = Regex.Match(s, @"[\\(].*[\\)]", RegexOptions.Multiline | RegexOptions.IgnoreCase).ToString().Trim("()".ToCharArray()); p = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(p.Replace('-', ' ')).Replace(" ", ""); string n = Regex.Match(s, @"[a-z]+[^\\(]*", RegexOptions.Multiline | RegexOptions.IgnoreCase).ToString().Trim(); if (string.Compare(n, "nothing", true) == 0) { break; } int max = 0; string[] l = s.Split(' '); if (l.Length > 0) { l = l[0].Split('-'); } if (l.Length > 1) { int.TryParse(l[1], out max); } if (!LootPossibilities.Contains(p)) { p = "Normal"; } s = s.Split(' ')[0].Replace("?", ""); uint id = 0; Item item = ItemLists.AllItems.Find(delegate(Item find) { return(string.Compare(find.Name, n, true) == 0); }); if (item != null) { id = item.Id; } buffer += "new Loot(\"" + n + "\", " + id + ", LootPossibility." + p + ", " + max + "),"; } buffer = buffer.Trim(',').Replace(",", ", "); MainTextWriter.WriteLine(buffer + "}"); }