예제 #1
0
 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);
     }
 }
예제 #2
0
    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);
            }
        }
    }
예제 #3
0
        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"));
        }
예제 #4
0
    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);
    }
예제 #5
0
        public void NotifyAddXP(Champion champion, float experience)
        {
            var xp = new AddXP(champion, experience);

            _game.PacketHandlerManager.broadcastPacket(xp, Channel.CHL_S2C);
        }