public void addPlayer(Player p) { pinfo pi = new pinfo(p); pi.nbFlags = 0; pi.nbDeaths = 0; pi.nbGames = 0; pi.nbKills = 0; pi.nbLoose = 0; pi.nbPoints = 0; pi.nbWin = 0; DataTable playerDb = MySQL.fillData("SELECT * FROM ctf WHERE Name='" + p.name + "'"); if (playerDb.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO ctf (Name, nbKills, nbDeaths, nbJeux, nbWins, nbLooses, nbFlags, nbPoints)" + "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbDeaths + ", " + pi.nbGames + ", " + pi.nbWin + ", " + pi.nbLoose + ", " + pi.nbFlags + ", " + pi.nbPoints + ")"); } else { pi.nbKills = int.Parse(playerDb.Rows[0]["nbKills"].ToString()); pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString()); pi.nbGames = int.Parse(playerDb.Rows[0]["nbJeux"].ToString()); pi.nbWin = int.Parse(playerDb.Rows[0]["nbWins"].ToString()); pi.nbLoose = int.Parse(playerDb.Rows[0]["nbLooses"].ToString()); pi.nbFlags = int.Parse(playerDb.Rows[0]["nbFlags"].ToString()); pi.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString()); } playerDb.Dispose(); players.Add(pi); }
private static int compKill(pinfo a, pinfo b) { if (a == null || b == null) { return(0); } if (a == null) { return(-1); } if (b == null) { return(1); } if (a.lastKill == b.lastKill) { return(0); } if (a.lastKill > b.lastKill) { return(-1); } if (a.lastKill < b.lastKill) { return(1); } return(0); }
public void GameEnd(Team winTeam) { lvl.ChatLevel("Le jeu est termine ! " + winTeam.teamstring + " a gagne avec " + winTeam.points + " point(s)!"); pinfo pi = null; foreach (Team team in teams) { ReturnFlag(null, team, false); foreach (Player p in team.players) { p.hasflag = null; p.carryingFlag = false; pi = players.Find(pin => pin.p == p); if (pi != null) { pi.nbGames++; if (team == winTeam) { pi.nbWin++; pi.nbPoints += 10; } else { pi.nbLoose++; } savePlayer(pi); players.Remove(pi); } } team.points = 0; } gameOn = false; stopGame(null); }
public static void stats(Player p, string pname) { DataTable playerDb = MySQL.fillData("SELECT * FROM ctf WHERE Name='" + pname + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur le ctf"); } else { pinfo pi = new pinfo(null); pi.nbKills = int.Parse(playerDb.Rows[0]["nbKills"].ToString()); pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString()); pi.nbFlags = int.Parse(playerDb.Rows[0]["nbFlags"].ToString()); pi.nbGames = int.Parse(playerDb.Rows[0]["nbJeux"].ToString()); pi.nbWin = int.Parse(playerDb.Rows[0]["nbWins"].ToString()); pi.nbLoose = int.Parse(playerDb.Rows[0]["nbLooses"].ToString()); pi.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString()); Player.SendMessage(p, "Statistiques de '" + pname + " :"); Player.SendMessage(p, "> > Nombre de points : &2" + pi.nbPoints); Player.SendMessage(p, "> > Nombre de parties : &2" + pi.nbGames); Player.SendMessage(p, "> > Nombre de victiores : &2" + pi.nbWin); Player.SendMessage(p, "> > Nombre de defaites : &2" + pi.nbLoose); Player.SendMessage(p, "> > Nombre de drapeaux attrape : &2" + pi.nbFlags); Player.SendMessage(p, "> > Nombre de kills : &2" + pi.nbKills); Player.SendMessage(p, "> > Nombre de morts : &2" + pi.nbDeaths); } playerDb.Dispose(); }
public void CaptureFlag(Player p, Team playerTeam, Team capturedTeam) { pinfo pi = players.Find(pin => pin.p == p); if (pi != null) { pi.nbFlags++; pi.nbPoints++; } playerTeam.points++; lvl.Blockchange(capturedTeam.tempFlagblock.x, capturedTeam.tempFlagblock.y, capturedTeam.tempFlagblock.z, capturedTeam.tempFlagblock.type); lvl.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " a capture le drapeau " + capturedTeam.teamstring + " !"); if (playerTeam.points >= maxPoints) { GameEnd(playerTeam); return; } lvl.ChatLevel(playerTeam.teamstring + " a maintenant " + playerTeam.points + " point(s)."); p.hasflag = null; p.carryingFlag = false; ReturnFlag(null, capturedTeam, false); for (int i = 0; i < playerTeam.players.Count; i++) { playerTeam.players[i].addMessage(Server.DefaultColor + "Team " + playerTeam.teamstring + " Points : " + playerTeam.points, true, 1); } }
public void tntExplose(tnt tInfo, pinfo pi) { lvl.Blockchange(tInfo.x, (ushort)(gameZone.y + 1), tInfo.z, Block.air); bool canExplode = true; for (int i = 0; i < pi.puissanceTnt && canExplode; i++) { canExplode = createExplosion(pi, (ushort)(tInfo.x + i), tInfo.z); } canExplode = true; for (int i = 1; i < pi.puissanceTnt && canExplode; i++) { canExplode = createExplosion(pi, (ushort)(tInfo.x - i), tInfo.z); } canExplode = true; for (int i = 1; i < pi.puissanceTnt && canExplode; i++) { canExplode = createExplosion(pi, tInfo.x, (ushort)(tInfo.z + i)); } canExplode = true; for (int i = 1; i < pi.puissanceTnt && canExplode; i++) { canExplode = createExplosion(pi, tInfo.x, (ushort)(tInfo.z - i)); } }
public static void stats(Player p, string pname) { DataTable playerDb = MySQL.fillData("SELECT * FROM bomberman WHERE Name='" + pname + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur le bomberman"); } else { pinfo pi = new pinfo(); pi.nbKills = int.Parse(playerDb.Rows[0]["nbKills"].ToString()); pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString()); pi.nbPowerUp = int.Parse(playerDb.Rows[0]["nbPowers"].ToString()); pi.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString()); pi.overAllWalls = int.Parse(playerDb.Rows[0]["nbWalls"].ToString()); Player.SendMessage(p, "Statistiques de '" + pname + " :"); Player.SendMessage(p, "> > Nombre de points : &2" + pi.nbPoints); Player.SendMessage(p, "> > Nombre de kills : &2" + pi.nbKills); Player.SendMessage(p, "> > Nombre de morts : &2" + pi.nbDeaths); Player.SendMessage(p, "> > Nombre de powers up attrape : &2" + pi.nbPowerUp); Player.SendMessage(p, "> > Nombre de murs pose : &2" + pi.overAllWalls); } playerDb.Dispose(); }
public void killPlayer(Player p, tntExp tE) { if (p.lastDeath.AddSeconds(2) > DateTime.Now) { return; } pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return; } pi.lastKill = 0; pi.nbWalls = 4; pi.nbTnt = 2; pi.puissanceTnt = 4; pi.nbDeaths++; pi.nbPoints--; p.addMessage("&eMurs : " + pi.nbWalls + " - Tnt : " + pi.nbTnt + " - Puissance : " + pi.puissanceTnt, true, 1); p.addMessage("&eKills : " + pi.nbKills + " - Morts : " + pi.nbDeaths + " - lastKills : " + pi.lastKill, true, 2); if (tE.pi == null) { p.HandleDeath(Block.stone, "&c explose."); } else { if (tE.pi.p == p) { p.HandleDeath(Block.stone, "&c explose dans sa propre tnt !"); } else { p.HandleDeath(Block.stone, "&c explose dans la tnt de " + tE.pi.p.color + tE.pi.p.Name()); } if (tE.pi.p != p) { tE.pi.nbKills++; tE.pi.lastKill++; tE.pi.nbPoints += tE.pi.lastKill; if (tE.pi.lastKill == 5) { Player.GlobalMessageLevel(lvl, tE.pi.p.color + tE.pi.p.Name() + Server.DefaultColor + " - quintuple kills !"); } if (tE.pi.lastKill == 10) { Player.GlobalMessageLevel(lvl, tE.pi.p.color + tE.pi.p.Name() + Server.DefaultColor + " - expert ! 10 kills !"); } if (tE.pi.lastKill == 20) { Player.GlobalMessageLevel(lvl, tE.pi.p.color + tE.pi.p.Name() + Server.DefaultColor + " - 20 kills ! Bomberman !"); } tE.pi.p.addMessage("&eKills : " + tE.pi.nbKills + " - Morts : " + tE.pi.nbDeaths + " - lastKills : " + tE.pi.lastKill, true, 2); } } }
public void delPlayer(pinfo pi) { pi.p.sendAll(); pi.p.ingame = false; pi.p.tailleBufferGame = 0; pi.p.gameMessages.Clear(); players.Remove(pi); }
public bool createExplosion(pinfo pi, ushort x, ushort z) { tntExp tE = new tntExp(); tE.pi = pi; tE.x = x; tE.z = z; bool explodeNext = true; if (gameZone.xMin > tE.x || gameZone.xMax < tE.x || gameZone.zMin > tE.z || gameZone.zMax < tE.z) { return(false); } byte b = lvl.GetTile(tE.x, (ushort)(gameZone.y + 1), tE.z); if (b == Block.blackrock) { return(false); } if (b == Block.water) { removeBonus(tE.x, tE.z); explodeNext = false; } if (b == Block.wood) { lvl.Blockchange(tE.x, (ushort)(gameZone.y + 1), tE.z, Block.air); lvl.Blockchange(tE.x, (ushort)(gameZone.y + 2), tE.z, Block.air); lvl.Blockchange(tE.x, (ushort)(gameZone.y + 3), tE.z, Block.glass); explodeNext = false; } if (lvl.GetTile(tE.x, gameZone.y, tE.z) != Block.lava) { explose.Add(tE); lvl.Blockchange(tE.x, gameZone.y, tE.z, Block.lava); } if (b == Block.tnt) { for (int i = 0; i < players.Count; i++) { if (players[i].tnts.Count == 0) { continue; } tnt ptnt = players[i].tnts.Find(t => t.x == tE.x && t.z == tE.z); if (ptnt == null) { continue; } tntExplose(ptnt, players[i]); } } return(explodeNext); }
public void but(Player p, Team t) { if (p != null) { pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return; } if (p.team == null) { return; } } Thread butThread = new Thread(new ThreadStart(delegate { inBut = true; t.points++; foreach (pinfo pin in players) { pin.p.addMessage("&ePoints : &9bleu " + blueTeam.points + " &e/ &crouge " + redTeam.points, true, 1); } if (p != null) { if (p.team == t) { Player.GlobalMessageLevel(lvl, "But marque par l'" + p.team.teamstring); } else { Player.GlobalMessageLevel(lvl, "But contre son camp par " + p.team.color + p.name); } } else { Player.GlobalMessageLevel(lvl, "But marque par l'" + p.team.teamstring); } Thread.Sleep(2000); if (redTeam.points >= points) { endGame(redTeam); } else if (blueTeam.points >= points) { endGame(blueTeam); } else { Player.GlobalMessageLevel(lvl, "Respawn du ballon"); respawnBallon(); } inBut = false; })); butThread.Start(); }
public void removePlayer(Player p, bool end = true) { pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return; } if (end) { savePlayer(pi); } players.Remove(pi); }
public void addPlayer(Player p) { pinfo pi = new pinfo(p); pi.p = p; p.ingame = true; p.tailleBufferGame = 4; p.gameMessages.Clear(); p.addMessage("&e------------- foot ---------------", true); p.addMessage("&ePoints : &9bleu " + blueTeam.points + " &e/ &crouge " + redTeam.points, true); p.addMessage("&e----------------------------------", true); abort(p); players.Add(pi); }
public void addPlayer(Player p) { pinfo pi = new pinfo(); pi.p = p; pi.lastKill = 0; pi.nbDeaths = 0; pi.nbKills = 0; pi.nbTnt = 2; pi.nbWalls = 4; pi.puissanceTnt = 4; pi.tnts = new List <tnt>(); pi.nbPoints = 0; pi.nbPowerUp = 0; pi.overAllWalls = 0; DataTable playerDb = MySQL.fillData("SELECT * FROM bomberman WHERE Name='" + p.name + "'"); if (playerDb.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO bomberman (Name, nbKills, nbDeaths, nbPowers, nbPoints, nbWalls)" + "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbDeaths + ", " + pi.nbPowerUp + ", " + pi.nbPoints + ", " + pi.overAllWalls + ")"); } else { pi.nbKills = int.Parse(playerDb.Rows[0]["nbKills"].ToString()); pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString()); pi.nbPowerUp = int.Parse(playerDb.Rows[0]["nbPowers"].ToString()); pi.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString()); pi.overAllWalls = int.Parse(playerDb.Rows[0]["nbWalls"].ToString()); } playerDb.Dispose(); p.ingame = true; p.tailleBufferGame = 4; p.gameMessages.Clear(); p.addMessage("&e---------- bomberman -------------", true); p.addMessage("&eMurs : " + pi.nbWalls + " - Tnt : " + pi.nbTnt + " - Puissance : " + pi.puissanceTnt, true); p.addMessage("&eKills : " + pi.nbKills + " - Morts : " + pi.nbDeaths + " - lastKills : " + pi.lastKill, true); p.addMessage("&e----------------------------------", true); abort(p); players.Add(pi); }
public override void death(Player p) { if (p.team != null) { if (p.carryingFlag) { DropFlag(p, p.hasflag); } p.team.SpawnPlayer(p); p.addMessage(Server.DefaultColor + "Vie : &" + p.team.color + 100, true, 3); p.health = 100; pinfo pi = players.Find(pin => pin.p == p); if (pi != null) { pi.nbDeaths++; } } }
public void infecter(pinfo cible, pinfo infecteur = null) { nbSurvivants--; cible.nbKilled++; cible.zombie = true; Player.GlobalDie(cible.p, false); for (int i = 0; i < players.Count; i++) { if (players[i].p != cible.p) { players[i].p.SendDie(cible.p.id); players[i].p.SendSpawn(cible.p.id, "&4_Infected_", cible.p.pos[0], cible.p.pos[1], cible.p.pos[2], cible.p.rot[0], cible.p.rot[1]); } } if (infecteur == null) { Player.GlobalMessageLevel(lvl, cible.p.color + cible.p.name + Server.DefaultColor + " est un zombie, courez !!!"); } else { Player.GlobalMessageLevel(lvl, infecteur.p.color + infecteur.p.name + Server.DefaultColor + " mange " + cible.p.color + cible.p.name); infecteur.nbKills++; infecteur.lastKill++; } if (!gameStarted) { return; } if (nbSurvivants == 0) { endGame(false); } }
public static void stats(Player p, string pname) { DataTable playerDb = MySQL.fillData("SELECT * FROM infection WHERE Name='" + pname + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur l'infection"); } else { pinfo pi = new pinfo(null); pi.nbKills = int.Parse(playerDb.Rows[0]["nbkills"].ToString()); pi.nbKilled = int.Parse(playerDb.Rows[0]["nbkilled"].ToString()); pi.nbSurvie = int.Parse(playerDb.Rows[0]["nbsurvie"].ToString()); pi.nbGames = int.Parse(playerDb.Rows[0]["nbgames"].ToString()); Player.SendMessage(p, "Statistiques de '" + pname + " :"); Player.SendMessage(p, "> > Nombre de parties joue : &2" + pi.nbGames); Player.SendMessage(p, "> > Nombre de survie : &2" + pi.nbSurvie); Player.SendMessage(p, "> > Nombre de fois zombifie : &2" + pi.nbKilled); Player.SendMessage(p, "> > Nombre de tue : &2" + pi.nbKills); } playerDb.Dispose(); }
public void savePlayer(pinfo pi) { MySQL.executeQuery("UPDATE infection SET nbkills=" + pi.nbKills + ", nbkilled=" + pi.nbKilled + ", nbsurvie=" + pi.nbSurvie + ", nbgames=" + pi.nbGames + " WHERE Name='" + pi.p.name + "'"); }
public void takeBonus(Player p, ushort x, ushort z, int index) { pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { lvl.Blockchange(x, gameZone.y, z, Block.darkgrey); lvl.Blockchange(x, (ushort)(gameZone.y + 1), z, Block.air); lvl.Blockchange(x, (ushort)(gameZone.y + 2), z, Block.air); lvl.Blockchange(x, (ushort)(gameZone.y + 3), z, Block.glass); bonus.RemoveAt(index); return; } Random rand = new Random(); switch (rand.Next(3)) { case 0: //walls if (pi.nbWalls + 6 < 30) { pi.nbWalls += 6; } else { pi.nbWalls = 30; } break; case 1: //puissance if (pi.puissanceTnt + 2 < 12) { pi.puissanceTnt += 2; } else { pi.puissanceTnt = 12; } break; case 2: //tnt if (pi.nbTnt + 2 < 12) { pi.nbTnt += 2; } else { pi.nbTnt = 12; } break; default: break; } pi.nbPowerUp++; p.addMessage("&eMurs : " + pi.nbWalls + " - Tnt : " + pi.nbTnt + " - Puissance : " + pi.puissanceTnt, true, 1); lvl.Blockchange(x, gameZone.y, z, Block.darkgrey); lvl.Blockchange(x, (ushort)(gameZone.y + 1), z, Block.air); lvl.Blockchange(x, (ushort)(gameZone.y + 2), z, Block.air); lvl.Blockchange(x, (ushort)(gameZone.y + 3), z, Block.glass); bonus.RemoveAt(index); return; }
public void addPlayer(Player p, bool zombie) { pinfo pi = new pinfo(p); pi.zombie = zombie; pi.nbBlocs = nbBlocsAllow; pi.lastKill = 0; pi.nbGames = 0; pi.nbKilled = 0; pi.nbKills = 0; pi.nbSurvie = 0; pi.lastBloc = new ushort[] { 0, 0, 0 }; pi.nbWarning = 0; DataTable playerDb = MySQL.fillData("SELECT * FROM infection WHERE Name='" + p.name + "'"); if (playerDb.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO infection (Name, nbkills, nbkilled, nbsurvie, nbgames)" + "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbKilled + ", " + pi.nbSurvie + ", " + pi.nbGames + ")"); } else { pi.nbKills = int.Parse(playerDb.Rows[0]["nbkills"].ToString()); pi.nbKilled = int.Parse(playerDb.Rows[0]["nbkilled"].ToString()); pi.nbSurvie = int.Parse(playerDb.Rows[0]["nbsurvie"].ToString()); pi.nbGames = int.Parse(playerDb.Rows[0]["nbgames"].ToString()); } playerDb.Dispose(); p.ingame = true; p.tailleBufferGame = 4; p.addMessage("&e---------- Infection -------------", true); if (zombie) { p.addMessage("&eVous etes un &4zombie " + Server.DefaultColor + "! Tuez !", true); } else { p.addMessage("&eVous survivez !", true); } p.addMessage("&eSurvivants : &2 0 " + Server.DefaultColor + "- Temps : &4" + (DateTime.Now - startDate).Minutes + ":" + (DateTime.Now - startDate).Seconds, true); p.addMessage("&e----------------------------------", true); if (zombie) { infecter(pi); } players.Add(pi); for (int i = 0; i < players.Count; i++) { if (p == players[i].p) { continue; } if (!players[i].zombie) { continue; } p.SendDie(players[i].p.id); p.SendSpawn(players[i].p.id, "&4_Infected_", players[i].p.pos[0], players[i].p.pos[1], players[i].p.pos[2], players[i].p.rot[0], players[i].p.rot[1]); } }
public override bool checkPos(Player p, ushort x, ushort y, ushort z) { if (!gameOn || !gameStarted) { return(true); } pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return(true); } if (pi.zombie) { double dist = 0; for (int i = 0; i < players.Count; i++) { if (players[i].p == p) { continue; } if (players[i].zombie) { continue; } dist = Math.Sqrt((p.pos[0] - players[i].p.pos[0]) * (p.pos[0] - players[i].p.pos[0]) + (p.pos[2] - players[i].p.pos[2]) * (p.pos[2] - players[i].p.pos[2])); if (dist < 64) { if (Math.Abs(p.pos[1] - players[i].p.pos[1]) < 64) { infecter(players[i], pi); } } } } else { double dist = 0; for (int i = 0; i < players.Count; i++) { if (players[i].p == p) { continue; } if (!players[i].zombie) { continue; } dist = Math.Sqrt((p.pos[0] - players[i].p.pos[0]) * (p.pos[0] - players[i].p.pos[0]) + (p.pos[2] - players[i].p.pos[2]) * (p.pos[2] - players[i].p.pos[2])); if (dist < 64) { if (Math.Abs(p.pos[1] - players[i].p.pos[1]) < 64) { infecter(pi, players[i]); } } } } return(true); }
public override bool changebloc(Player p, byte type, ushort x, ushort y, ushort z, byte action) { if (!gameOn) { return(true); } byte b = lvl.GetTile(x, y, z); if (nbBlocsAllow == 0) { p.SendBlockchange(x, y, z, b); Player.SendMessage(p, "Impossible de placer ca ici"); return(false); } if (Block.OPBlocks(b)) { p.SendBlockchange(x, y, z, b); Player.SendMessage(p, "Impossible de placer ca ici"); return(false); } if (Block.RightClick(Block.Convert(b))) { p.SendBlockchange(x, y, z, b); return(false); } if (action == 0) { lvl.Blockchange(x, y, z, Block.air); return(false); } else { pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return(true); } if (!cheat) { if (pi.lastBloc[0] == x && pi.lastBloc[2] == z) { if (pi.lastBloc[1] == y || pi.lastBloc[1] == y - 1) { pi.nbWarning++; if (pi.nbWarning < 3) { Player.SendMessage(p, "Les piliers interdits !"); } else if (pi.nbWarning == 3) { Player.SendMessage(p, "&4Attention, kick a la prochaine alerte !"); } else { p.Kick("Kick auto : les piliers sont interdit !"); } } } } if (pi.nbBlocs == 0) { p.SendBlockchange(x, y, z, b); Player.SendMessage(p, "Vous n'avez plus de blocs"); return(false); } pi.nbBlocs--; if (pi.nbBlocs % 10 == 0) { Player.SendMessage(p, "Blocs restant : &2" + pi.nbBlocs); } else if (pi.nbBlocs <= 5) { Player.SendMessage(p, "Blocs restant : &2" + pi.nbBlocs); } lvl.Blockchange(x, y, z, type); return(false); } }
public void savePlayer(pinfo pi) { }
public override bool checkPos(Player p, ushort x, ushort y, ushort z) { if (!gameOn || inBut) { return(true); } if (p.team == null) { return(true); } pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { return(true); } double dist = Math.Sqrt((p.pos[0] - posBallon.x) * (p.pos[0] - posBallon.x) + (p.pos[2] - posBallon.z) * (p.pos[2] - posBallon.z)); if (dist > 3 * 32) { return(true); } if (Math.Abs(p.pos[1] - posBallon.y) > 3 * 32) { return(true); } for (int i = 0; i < players.Count; i++) { double dist2 = Math.Sqrt((players[i].p.pos[0] - posBallon.x) * (players[i].p.pos[0] - posBallon.x) + (players[i].p.pos[2] - posBallon.z) * (players[i].p.pos[2] - posBallon.z)); if (Math.Abs(players[i].p.pos[1] - posBallon.y) < 3 * 32) { if (dist2 < dist) { return(true); } } } int dirX = 0, dirZ = 0;//angle de 32 if (p.rot[0] >= 240 || p.rot[0] < 16) { dirZ = 3; } if (p.rot[0] >= 16 && p.rot[0] < 48) { dirZ = 2; dirX = -2; } if (p.rot[0] >= 48 && p.rot[0] < 80) { dirX = -3; } if (p.rot[0] >= 80 && p.rot[0] < 112) { dirX = -2; dirZ = -2; } if (p.rot[0] >= 112 && p.rot[0] < 144) { dirZ = -3; } if (p.rot[0] >= 144 && p.rot[0] < 176) { dirZ = -2; dirX = 2; } if (p.rot[0] >= 176 && p.rot[0] < 208) { dirX = 3; } if (p.rot[0] >= 208 && p.rot[0] < 240) { dirX = 2; dirZ = 2; } if (dirX == 0 && dirZ == 0) { return(true); } pos newPosBallon = new pos(); newPosBallon.x = (ushort)(x + dirX); newPosBallon.y = posBallon.y; newPosBallon.z = (ushort)(z + dirZ); if (newPosBallon.x == posBallon.x && newPosBallon.y == posBallon.y && newPosBallon.z == posBallon.z) { return(true); } if (posBallon.y < y) { bool under = true; while (under) { if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y++; } else { under = false; } } } if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y++; if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y--; newPosBallon.x = (ushort)(newPosBallon.x - Math.Sign(dirX)); newPosBallon.z = (ushort)(newPosBallon.z - Math.Sign(dirZ)); if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y++; if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y--; newPosBallon.x = (ushort)(newPosBallon.x - Math.Sign(dirX)); newPosBallon.z = (ushort)(newPosBallon.z - Math.Sign(dirZ)); if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { newPosBallon.y++; if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { if (dirX == 3 || dirZ == 3) { newPosBallon.y--; newPosBallon.x = (ushort)(newPosBallon.x - Math.Sign(dirX)); newPosBallon.z = (ushort)(newPosBallon.z - Math.Sign(dirZ)); } if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) != Block.air) { bool ballonIn = false; while (!ballonIn) { if (newPosBallon.y >= lvl.depth) { Player.GlobalMessageLevel(lvl, "Ballon sortit, respawn"); respawnBallon(); return(true); } newPosBallon.y++; if (lvl.GetTile(newPosBallon.x, newPosBallon.y, newPosBallon.z) == Block.air) { ballonIn = true; } } } } } } } } } if (newPosBallon.x == posBallon.x && newPosBallon.y == posBallon.y && newPosBallon.z == posBallon.z) { return(true); } lvl.Blockchange(posBallon.x, posBallon.y, posBallon.z, Block.air); posBallon.x = newPosBallon.x; posBallon.y = newPosBallon.y; posBallon.z = newPosBallon.z; lvl.Blockchange(posBallon.x, posBallon.y, posBallon.z, Block.white); checkBut(p); return(true); }
public void savePlayer(pinfo pi) { MySQL.executeQuery("UPDATE bomberman SET nbKills=" + pi.nbKills + ", nbDeaths=" + pi.nbDeaths + ", nbPowers=" + pi.nbPowerUp + ", nbPoints=" + pi.nbPoints + ", nbWalls=" + pi.overAllWalls + " WHERE Name='" + pi.p.name + "'"); }
public void savePlayer(pinfo pi) { MySQL.executeQuery("UPDATE ctf SET nbKills= " + pi.nbKills + ", nbDeaths= " + pi.nbDeaths + ", nbJeux= " + pi.nbGames + ", nbWins= " + pi.nbWin + ", nbLooses= " + pi.nbLoose + ", nbFlags= " + pi.nbFlags + ", nbPoints=" + pi.nbPoints + " WHERE Name='" + pi.p.name + "'"); }
public override bool changebloc(Player p, byte type, ushort x, ushort y, ushort z, byte action) { if (!gameOn) { return(true); } if (x > gameZone.xMax || x < gameZone.xMin || y > gameZone.y + 4 || y < gameZone.y || z > gameZone.zMax || z < gameZone.zMin) { return(true); } byte b = lvl.GetTile(x, y, z); if (y != gameZone.y + 1 || action == 0) { p.SendBlockchange(x, y, z, b); return(false); } if (type != Block.tnt && type != Block.wood) { p.SendBlockchange(x, y, z, b); return(false); } if (b != Block.air) { p.SendBlockchange(x, y, z, b); return(false); } if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.lava) { p.SendBlockchange(x, y, z, b); return(false); } pinfo pi = players.Find(pin => pin.p == p); if (pi == null) { p.SendBlockchange(x, y, z, b); return(false); } if (type == Block.tnt) { if (pi.tnts.Count >= pi.nbTnt) { p.SendBlockchange(x, y, z, b); return(false); } tnt tInfo = new tnt(x, z); pi.tnts.Add(tInfo); lvl.Blockchange(x, y, z, Block.tnt); } else if (type == Block.wood) { if (pi.nbWalls <= 0) { p.SendBlockchange(x, y, z, b); return(false); } pi.nbWalls--; pi.overAllWalls++; p.addMessage("&eMurs : " + pi.nbWalls + " - Tnt : " + pi.nbTnt + " - Puissance : " + pi.puissanceTnt, true, 1); lvl.Blockchange(x, (ushort)(gameZone.y + 1), z, Block.wood); lvl.Blockchange(x, (ushort)(gameZone.y + 2), z, Block.wood); lvl.Blockchange(x, (ushort)(gameZone.y + 3), z, Block.wood); } else { p.SendBlockchange(x, y, z, b); } return(false); }