public void addPlayer(Player P, int num) { players[num] = P; }
public void updatePlayer(String PData) { int px, py, direction, shot, health, coin, pointss,id; String[] playerData = PData.Split(';'); String[] cordinates = playerData[1].Split(','); id = int.Parse(playerData[0].ToCharArray()[1]+""); px = int.Parse(cordinates[0]); py = int.Parse(cordinates[1]); direction = int.Parse(playerData[2]); shot = int.Parse(playerData[3]); health = int.Parse(playerData[4]); coin = int.Parse(playerData[5]); pointss = int.Parse(playerData[6]); Player player = new Player(px, py, id, direction, shot.Equals(1), health, coin, pointss); if (shot.Equals(1)) { int size = 600 / Battle.getLength(); //DateTime t = DateTime.Now(); // Bullet b = new Bullet(1000, px, py, direction,DateTime.Now(),size); // Battle.addBullet(b); } if (health ==0) { if (!Battle.getShotPlayerList().Contains(id)) { CoinPile cpt = new CoinPile(100, px, py, 86400000, coin, this); Battle.addObjects(cpt, px, py); Battle.addPlayer(id); } } else { if (Battle.getObject(px, py) != null) { int t = Battle.getObject(px, py).getID(); if ((t == 100) || (t == 200)) { Battle.addObjects(null, px, py); } } } Battle.pdatePlayer(player, id); }
public void pdatePlayer(Player P, int num) { players[num] = P; }
public void start(String startS) { //set players String[] temp = startS.Split(':'); String[] temp2; int px,py,pd; int playerNum; Player player; for (int i = 1; i < temp.Length; i++) { temp2 = temp[i].Split(';'); playerNum = int.Parse(temp2[0].ToCharArray()[1]+""); px = int.Parse(temp2[1].Split(',')[0]); py = int.Parse(temp2[1].Split(',')[1]); pd = int.Parse(temp2[2]); player = new Player(px, py, playerNum, pd, false, 100, 0, 0); Battle.addPlayer(player, playerNum); } }