void Start() { player1id = game.SP1; playerOptions PO = playerOptions.Load("playerData"); // loop through each player in playerOptions // when id == selectedPlayer1.ID // set everything else thats belongs to that playerOption equal to this players att's foreach (player Player in PO.players) { if (Player.ID == player1id) { maxHealth = Player.Health; Name = Player.CharName; dps = Player.Dps; moveSpeed = 600 * Player.MoveSpeed; attSpeed = Player.AttSpeed; armor = Player.Armor; } } curHealth = maxHealth; attacking = false; attackCD = .03f; attackTimer = 0; }
public static playerOptions Load(string path) { TextAsset xmlData = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(playerOptions)); StringReader reader = new StringReader(xmlData.text); playerOptions players = serializer.Deserialize(reader) as playerOptions; reader.Close(); return(players); }