public int AddPlayer(int team) { int actorId = CreatedActorsCount++; CreatedPlayersCount++; Player newPlayer; if (team == 2) { newPlayer = new Player(actorId, team, new GameUtility.Coordinate(250, 70)); } else { newPlayer = new Player(actorId, team, new GameUtility.Coordinate(250, 430)); } if (!actors.TryAdd(actorId, newPlayer)) { //TODO Handle failure } teamActors [team].Add(newPlayer); Log.V("Adding player actor with id " + actorId); ActorType actortype; if (team == 1) { actortype = RandomHuman(); } else { actortype = RandomOrc(); } OutgoingReliableElements.Enqueue(new SpawnElement(actortype, actorId, newPlayer.Team, newPlayer.SpawnLocation.x, newPlayer.SpawnLocation.z)); return(actorId); }
public int AddTower(GameUtility.Coordinate spawnLoc) { int actorId = CreatedActorsCount++; int team = 0; Tower newTower = new Tower(actorId, team, spawnLoc); if (!actors.TryAdd(actorId, newTower)) { //TODO Handle failure } Log.V("Adding tower actor with id " + actorId); OutgoingReliableElements.Enqueue(new SpawnElement(ActorType.TowerA, actorId, team, newTower.SpawnLocation.x, newTower.SpawnLocation.z)); return(actorId); }
/*--------------------------------------------------------------------------------------- * -- FUNCTION: addExp * -- * -- DATE: March 28, 2019 * -- * -- REVISIONS: * -- * -- DESIGNER: Ziqian Zhang * -- * -- PROGRAMMER: Ziqian Zhang * -- * -- INTERFACE: public void addExp (Player player, int exp) * -- player: the player who need to add EXP * -- exp: the exp need to be added * -- * -- RETURNS: void * -- * -- NOTES: This is helper function to add exp to player * -- * ---------------------------------------------------------------------------------------*/ public void addExp(Player player, int exp) { int preLevel = GameUtility.currentLevel(player.Experience); player.Experience += exp; int afterLevel = GameUtility.currentLevel(player.Experience); if (afterLevel > preLevel) { //levelUp, skill change player.Level++; int newSkillId = AbilityEffects.ReturnRandomAbilityId(player); while (player.HasAbility((AbilityType)newSkillId)) { newSkillId = AbilityEffects.ReturnRandomAbilityId(player); } player.AddAbility(afterLevel, (AbilityType)newSkillId); OutgoingReliableElements.Enqueue(new AbilityAssignmentElement(player.ActorId, newSkillId)); } }