public bool AddXP(AddXP model) { using (var ctx = new ApplicationDbContext()) { Character character = ctx.Character.Single(e => e.ID == model.CharacterID); character.XP = character.XP + model.XPChange; if (character.XP > MaxXP) { character.Level = 10; } else if (character.XP <= 20) { character.Level = 1; } else { character.Level = SetLevel(character.XP); } if (ctx.SaveChanges() == 1) { return(true); } return(false); } }
private void StillAlive() { /////////////////////////////////////////////// //Local Variables GameObject gameController; GameObject messageWindow = GameObject.FindWithTag(TagKeys.MESSAGE_WINDOW_KEY); /////////////////////////////////////////////// if (Attributes.CurrentHP <= 0) { if (IsPlayer == true) { gameObject.GetComponent <InputAction>().enabled = false; messageWindow.GetComponent <MessageWindow>().AddText("Game Over. Press any key to restart."); } else { gameController = GameObject.FindWithTag(TagKeys.MAIN_CONTROLLER_KEY); messageWindow.GetComponent <MessageWindow>().AddText(String.Format("{0} is dead!", gameObject.name)); gameController.GetComponent <MonsterController>().RemoveMonster(gameObject); AddXP.Start(Attributes.XP); GameObject.Destroy(gameObject); } } }
public IHttpActionResult Put(AddXP model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCharacterService(); if (!service.AddXP(model)) { return(InternalServerError()); } return(Ok("Character XP Adjusted")); }
public void GetXP(float XP) { Debug.Log("get xp called"); experience += XP; float XPNeeded = AddXP.ExperienceForNextLevel(level); float previousXP = AddXP.ExperienceForNextLevel(level - 1); while (experience >= XPNeeded) { LevelUP(); XPNeeded = AddXP.ExperienceForNextLevel(level); previousXP = AddXP.ExperienceForNextLevel(level - 1); } exprienceBar.GetComponent <Image> ().fillAmount = (experience - previousXP) / (XPNeeded - previousXP); }
public void NotifyAddXP(Champion champion, float experience) { var xp = new AddXP(champion, experience); _game.PacketHandlerManager.broadcastPacket(xp, Channel.CHL_S2C); }