void LoadGuild() { XmlDocument xmlDoc = new XmlDocument(); string path = Application.dataPath + @"/Resources/XML/GuildList.xml"; if (File.Exists(path)) { xmlDoc.Load(path); //load players XmlNodeList players = xmlDoc.GetElementsByTagName("char"); foreach(XmlNode player in players){ PlayerShell p = new PlayerShell(); p.name = player.Attributes["name"].InnerText; p.desc = player.Attributes["desc"].InnerText; p.health = int.Parse(player.Attributes["health"].InnerText); p.str = int.Parse(player.Attributes["str"].InnerText); p.end = int.Parse(player.Attributes["end"].InnerText); p.agi = int.Parse(player.Attributes["agi"].InnerText); p.mag = int.Parse(player.Attributes["mag"].InnerText); p.luck = int.Parse(player.Attributes["luck"].InnerText); p.weaponID = int.Parse(player.Attributes["weaponID"].InnerText); p.armorID = int.Parse(player.Attributes["armorID"].InnerText); if(player.Attributes["active"].InnerText.Equals ("False")) p.active = false; else p.active = true; allPlayers.Add(p); } } }
public void RecruitGuildMember() { PlayerShell temp = new PlayerShell(); temp.name = genName(); temp.desc = "A new Recruit"; //temp.health = 50; temp.health = (int)UnityEngine.Random.Range(25, 80); double str = UnityEngine.Random.Range(30, 70); double end = UnityEngine.Random.Range(30, 70); double agi = UnityEngine.Random.Range(30, 70); double mag = UnityEngine.Random.Range(30, 70); double luck = UnityEngine.Random.Range(30, 70); double total = str + end + agi + mag + luck; temp.str = (int)(str / total * 42); temp.end = (int)(end / total * 42); temp.agi = (int)(agi / total * 42); temp.mag = (int)(mag / total * 42); temp.luck = (int)(luck / total * 42); temp.weaponID = (int)UnityEngine.Random.Range(0, 4); temp.armorID = (int)UnityEngine.Random.Range(0, 4); temp.active = false; inventory.allPlayers.Add(temp); nothingToSave = false; setUpGuild(); }
private void DestroyGate(Gate gate, Collision collision) { PlayerShell shell = collision.gameObject.GetComponent <PlayerShell>(); if (shell) { gate.Hit(1); shell.Explosion(); } }
private void EnemyTakeDamage(Enemy enemy, Collider collider) { PlayerShell shell = collider.GetComponent <PlayerShell>(); if (shell) { enemy.Hit(1); shell.Explosion(); } }
void ToggleActive(int position) { PlayerShell temp = new PlayerShell(); temp.name = inventory.allPlayers[position].name; temp.desc = inventory.allPlayers[position].desc; temp.str = inventory.allPlayers[position].str; temp.agi = inventory.allPlayers[position].agi; temp.end = inventory.allPlayers[position].end; temp.mag = inventory.allPlayers[position].mag; temp.luck = inventory.allPlayers[position].luck; temp.weaponID = inventory.allPlayers[position].weaponID; temp.armorID = inventory.allPlayers[position].armorID; temp.active = !inventory.allPlayers[position].active; inventory.allPlayers[position] = temp; nothingToSave = false; }
void LoadGuild() { XmlDocument xmlDoc = new XmlDocument(); string path = Application.dataPath + @"/Resources/XML/GuildList.xml"; if (File.Exists(path)) { xmlDoc.Load(path); //load players XmlNodeList players = xmlDoc.GetElementsByTagName("char"); foreach (XmlNode player in players) { PlayerShell p = new PlayerShell(); p.name = player.Attributes["name"].InnerText; p.desc = player.Attributes["desc"].InnerText; p.health = int.Parse(player.Attributes["health"].InnerText); p.str = int.Parse(player.Attributes["str"].InnerText); p.end = int.Parse(player.Attributes["end"].InnerText); p.agi = int.Parse(player.Attributes["agi"].InnerText); p.mag = int.Parse(player.Attributes["mag"].InnerText); p.luck = int.Parse(player.Attributes["luck"].InnerText); p.weaponID = int.Parse(player.Attributes["weaponID"].InnerText); p.armorID = int.Parse(player.Attributes["armorID"].InnerText); if (player.Attributes["active"].InnerText.Equals("False")) { p.active = false; } else { p.active = true; } allPlayers.Add(p); } } }
private void TakeDamage(float amount, bool fromRanged) { if (currentShellStats.CanBlock && animator.GetBool("Block")) { amount *= ConstantsManager.ShieldAbsorbRate; if (fromRanged) { SFXManager.PlaySFX(SFXManager.SFXType.CannonImpactBlock); } else { SFXManager.PlaySFX(SFXManager.SFXType.MeleeWeaponBlock); } } else { if (fromRanged) { SFXManager.PlaySFX(SFXManager.SFXType.CannonImpact); } else { SFXManager.PlaySFX(SFXManager.SFXType.MeleeWepon); } } if (currentShellHealth > 0) { currentShellHealth = currentShellHealth - amount; if (currentShellHealth < 0) { currentShellHealth = 0; } shellValue.SetValue(currentShellHealth / currentShellStats.ShellHealth); if (currentShellHealth <= 0) { // Break the current shell SetupShell(baseShellStats); SFXManager.PlaySFX(SFXManager.SFXType.ShellBreak); Destroy(Instantiate(ConstantsManager.PlayerDieVFXPrefab, transform.position, Quaternion.identity), 10); } else if (shellValue.Value <= 0.5f) { // Setup broken material PlayerShell playerShell = GetComponentInChildren <PlayerShell>(); if (playerShell != null) { playerShell.ActivateBrokenMaterial(); SFXManager.PlaySFX(SFXManager.SFXType.ShellBreak); } } } else { currentHealth = currentHealth - amount; if (currentShellHealth < 0) { currentShellHealth = 0; } healthValue.SetValue(currentHealth / ConstantsManager.BaseCrabLife); if (currentHealth <= 0) { // Die SFXManager.PlaySFX(SFXManager.SFXType.Death); IsAlive = false; areControlsEnabled = false; animator.SetBool("Walking", false); myRigidbody.velocity = Vector3.zero; Destroy(gameObject, 3); } } }
public void RecruitGuildMember() { PlayerShell temp = new PlayerShell(); temp.name = genName (); temp.desc = "A new Recruit"; //temp.health = 50; temp.health = (int)UnityEngine.Random.Range(25,80); double str = UnityEngine.Random.Range(30, 70); double end = UnityEngine.Random.Range(30, 70); double agi = UnityEngine.Random.Range(30, 70); double mag = UnityEngine.Random.Range(30, 70); double luck = UnityEngine.Random.Range(30, 70); double total = str+end+agi+mag+luck; temp.str = (int)(str/total*42); temp.end = (int)(end/total*42); temp.agi = (int)(agi/total*42); temp.mag = (int)(mag/total*42); temp.luck = (int)(luck/total*42); temp.weaponID = (int)UnityEngine.Random.Range (0,4); temp.armorID = (int)UnityEngine.Random.Range (0,4); temp.active = false; inventory.allPlayers.Add(temp); nothingToSave = false; setUpGuild(); }
void ToggleActive(int position) { PlayerShell temp = new PlayerShell(); temp.name = inventory.allPlayers[position].name; temp.desc = inventory.allPlayers[position].desc; temp.str = inventory.allPlayers[position].str; temp.agi = inventory.allPlayers[position].agi; temp.end = inventory.allPlayers[position].end; temp.mag = inventory.allPlayers[position].mag; temp.luck = inventory.allPlayers[position].luck; temp.weaponID = inventory.allPlayers[position].weaponID; temp.armorID = inventory.allPlayers[position].armorID; temp.active = !inventory.allPlayers[position].active; inventory.allPlayers[position] = temp; nothingToSave = false; }