コード例 #1
0
        /// <summary>
        /// 用户获得道具
        /// </summary>
        /// <returns></returns>
        public bool AddSkill(int id)
        {
            if (id == 0)
            {
                return(false);
            }

            var skill = SkillList.Find(t => (t.ID == id));

            if (skill != null)
            {
                return(false);
            }
            skill    = new SkillData();
            skill.ID = id;
            skill.Lv = 1;
            SkillList.Add(skill);
            return(true);
        }
コード例 #2
0
        public override void HandleInput(InputHelper inputHelper)
        {
            Action onLeftClick = () =>
            {
                Event e = new EndTurnEvent(this);
                Server.Send(e);
            };

            if (Tile != null)
            {
                inputHelper.IfMouseLeftButtonPressedOn(Tile, onLeftClick);
            }

            Action onRightClick = () =>
            {
                SkillEvent SkE = new SkillEvent((GameWorld.Find(Player.LocalPlayerName) as Player), this);
                Server.Send(SkE);
            };

            inputHelper.IfMouseRightButtonPressedOn(this, onRightClick);

            //TODO: make this less copypasty
            #region SkillSelection
            if (inputHelper.KeyPressed(Keys.D1))
            {
                currentSkill = (SkillList.Find("skillSlot0") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D2))
            {
                currentSkill = (SkillList.Find("skillSlot1") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D3))
            {
                currentSkill = (SkillList.Find("skillSlot2") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D4))
            {
                currentSkill = (SkillList.Find("skillSlot3") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D5))
            {
                currentSkill = (SkillList.Find("skillSlot4") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D6))
            {
                currentSkill = (SkillList.Find("skillSlot5") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D7))
            {
                currentSkill = (SkillList.Find("skillSlot6") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D8))
            {
                currentSkill = (SkillList.Find("skillSlot7") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D9))
            {
                currentSkill = (SkillList.Find("skillSlot8") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            if (inputHelper.KeyPressed(Keys.D0))
            {
                currentSkill = (SkillList.Find("skillSlot9") as RestrictedItemSlot).SlotItem as Skill;
                ChangedSkillEvent CSK = new ChangedSkillEvent(this, CurrentSkill);
                Server.Send(CSK);
            }

            #endregion

            base.HandleInput(inputHelper);
        }
コード例 #3
0
 public SkillJson SearchSkillID(string id)
 {
     return(SkillList.Find((obj) => obj.id.Equals(id)));
 }
コード例 #4
0
 public SkillData FindSkill(int id)
 {
     return(SkillList.Find(t => (t.ID == id)));
 }