示例#1
0
        /// <summary>
        /// 选择装备物品
        /// </summary>
        /// <param name="goods"></param>
        private void EquipSelected(BaseGoods goods)
        {
            var canUseCharacters = _combatUI.PlayerCharacters.Where(m => goods.CanPlayerUse(m.Index)).ToArray();

            if (canUseCharacters.Length == 0)
            {
                // 没人能装备
                Context.ShowMessage("不能装备!", 1000);
            }
            else if (canUseCharacters.Length == 1)
            {
                // 一个人能装备
                if (canUseCharacters[0].HasEquipt(goods.Type, goods.Index))
                {
                    Context.ShowMessage("已装备!", 1000);
                }
                else
                {
                    Context.PushScreen(new ScreenChangeEquipment(Context, canUseCharacters[0], (GoodsEquipment)goods));
                }
            }
            else
            {
                // 多人可装备
                Context.PushScreen(new EquipSelectedScreen(Context, canUseCharacters, goods));
            }
        }
示例#2
0
        public EquipSelectedScreen(SimulatorContext context, IList <PlayerCharacter> _list, BaseGoods goods) : base(context)
        {
            _goods    = goods;
            list      = _list;
            bg        = Context.Util.GetFrameBitmap(16 * 5 + 6, 6 + 16 * list.Count);
            itemsText = ExtensionFunction.DyadicArrayByte(list.Count, 11);//new byte[list.Count][11];

            for (int i = 0; i < itemsText.Length; i++)
            {
                itemsText[i] = new byte[11];
            }

            for (int i = 0; i < itemsText.Length; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    itemsText[i][j] = (byte)' ';
                }
                try
                {
                    byte[] tmp = list[i].Name.GetBytes();
                    Array.Copy(tmp, 0, itemsText[i], 0, tmp.Length);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
        /// <summary>
        /// 多人装备选择界面
        /// </summary>
        /// <param name="context"></param>
        /// <param name="characters">角色列表</param>
        /// <param name="goods">当前选择进行装备的装备</param>
        public MutilCharacterEquipScreen(SimulatorContext context, List <PlayerCharacter> characters, BaseGoods goods) : base(context)
        {
            //HACK 此处需要测试是否正常运行
            _characters = characters;
            _goods      = goods;

            _background = Context.Util.GetFrameBitmap(16 * 5 + 6, 6 + 16 * _characters.Count);
            _names      = ExtensionFunction.DyadicArrayByte(_characters.Count, 11);//new byte[list.Count][11];
            for (int i = 0; i < _names.Length; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    _names[i][j] = (byte)' ';
                }
                try
                {
                    byte[] tmp = _characters[i].Name.GetBytes();
                    Array.Copy(tmp, 0, _names[i], 0, tmp.Length);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
 /// <summary>
 /// 返回true所有内容显示完毕
 /// </summary>
 /// <param name="delta"></param>
 /// <returns></returns>
 public bool Update(long delta)
 {
     _timeCount += delta;
     if (_timeCount > 1000 || _isAnyKeyPressed)
     {
         _timeCount       = 0;
         _isAnyKeyPressed = false;
         if (_gainGoods.Count == 0)
         {
             if (_levelUpScreens.Count == 0)
             {
                 return(true);
             }
             else
             {
                 _msgScreens.Add(_levelUpScreens[0]);
                 _levelUpScreens.RemoveAt(0);
             }
         }
         else
         {
             BaseGoods goods = _gainGoods[0];
             _gainGoods.RemoveAt(0);
             _msgScreens.Add(new MsgScreen(Context, "得到 " + goods.Name + " x" + goods.GoodsNum));
         }
     }
     return(false);
 }
        /// <summary>
        /// 选择使用
        /// </summary>
        /// <param name="goods"></param>
        private void GoodsSelected(BaseGoods goods)
        {
            switch (goods.Type)
            {
            case 8:     // 暗器
            case 12:    // 兴奋剂
                Context.ShowMessage("战斗中才能使用!", 1000);
                break;

            case 13:     // 土遁
                         // TODO 迷宫中的用法,调用脚本
                Context.ScriptProcess.TriggerEvent(255);
                while (!(Context.GetCurrentScreen() is ScreenMainGame))
                {
                    Context.PopScreen();
                }
                break;

            case 14:     // 剧情类
                         // TODO 剧情类物品用法
                Context.ShowMessage("当前无法使用!", 1000);
                break;

            case 9:     // 药物
            case 10:    // 灵药
            case 11:    // 仙药
                Context.PushScreen(new ScreenTakeMedicine(Context, goods));
                break;
            }
        }
 /// <summary>
 /// 吃药界面
 /// </summary>
 /// <param name="context"></param>
 /// <param name="goods"></param>
 public ScreenTakeMedicine(SimulatorContext context, BaseGoods goods) : base(context)
 {
     _medicine = goods;
     if (Context.PlayContext.PlayerCharacters.Count > 0)
     {
         _characterIndex = 0;
     }
 }
示例#7
0
 /// <summary>转为 Entity货物</summary>
 public tg_goods_item ConvertBaseGood(BaseGoods good, int tingid, Int64 userid)
 {
     return(new tg_goods_item
     {
         user_id = userid,
         ting_id = tingid,
         goods_id = good.id,
         number = good.sum,
         number_max = good.sum,
     });
 }
示例#8
0
        /// <summary>
        /// 怪物掉落的物品
        /// </summary>
        public BaseGoods GetDropGoods()
        {
            if (_dropGoods[0] == 0 || _dropGoods[1] == 0 || _dropGoods[2] == 0)
            {
                return(null);
            }

            BaseGoods goods = Context.LibData.GetGoods(_dropGoods[0], _dropGoods[1]);

            goods.GoodsNum = _dropGoods[2];
            return(goods);
        }
示例#9
0
            public CommandGainGoodsOperate(ArraySegment <byte> data, SimulatorContext context) : base(context)
            {
                var start = data.Offset;
                var code  = data.Array;

                _goods   = Context.LibData.GetGoods(code.Get2BytesUInt(start), code.Get2BytesUInt(start + 2));
                _message = $"获得:{_goods.Name}";

                _goods.GoodsNum = 1;
                Context.GoodsManage.AddGoods(_goods.Type, _goods.Index);
                _showTime        = 0;
                _isAnyKeyPressed = false;
            }
示例#10
0
        /// <summary>
        /// 获取物品
        /// </summary>
        /// <param name="type"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private BaseGoods InternalGetGoods(int type, int index)
        {
            if (type >= 1 && type <= 5)
            {
                return(new GoodsEquipment(Context));
            }
            BaseGoods rtn = null;

            switch (type)
            {
            case 6:
                rtn = new GoodsDecorations(Context);
                break;

            case 7:
                rtn = new GoodsWeapon(Context);
                break;

            case 8:
                rtn = new GoodsHiddenWeapon(Context);
                break;

            case 9:
                rtn = new GoodsMedicine(Context);
                break;

            case 10:
                rtn = new GoodsLifeMedicine(Context);
                break;

            case 11:
                rtn = new GoodsAttributesMedicine(Context);
                break;

            case 12:
                rtn = new GoodsStimulant(Context);
                break;

            case 13:
                rtn = new GoodsTudun(Context);
                break;

            case 14:
                rtn = new GoodsDrama(Context);
                break;
            }
            return(rtn);
        }
示例#11
0
            public CommandBuyOperate(ArraySegment <byte> data, SimulatorContext context) : base(context)
            {
                var start = data.Offset;
                var code  = data.Array;

                _goodsList.Clear();
                var i = start;

                while (code[i] != 0)
                {
                    BaseGoods goods = Context.GoodsManage.GetGoods((int)code[i + 1] & 0xff, (int)code[i] & 0xff);

                    if (goods == null)
                    {
                        goods          = Context.LibData.GetGoods((int)code[i + 1] & 0xff, (int)code[i] & 0xff);
                        goods.GoodsNum = 0;
                    }

                    _goodsList.Add(goods);
                    i += 2;
                }

                _buyScreen = new ScreenBuyGoods(Context);

                Context.PushScreen(new ScreenGoodsList(Context, _goodsList, (goods) =>
                {
                    if (Context.PlayContext.Money < goods.BuyPrice)
                    {
                        Context.ShowMessage("金钱不足!", 1000);
                    }
                    else
                    {
                        _buyScreen.Init(goods);
                        Context.PushScreen(_buyScreen);
                    }
                }, GoodsOperateMode.Buy));
            }
        /// <summary>
        /// 选择装备
        /// </summary>
        /// <param name="goods"></param>
        private void EquipSelected(BaseGoods goods)
        {
            List <PlayerCharacter> characters = new List <PlayerCharacter>();

            for (int i = 0; i < Context.PlayContext.PlayerCharacters.Count; i++)
            {
                PlayerCharacter character = Context.PlayContext.PlayerCharacters[i];
                if (goods.CanPlayerUse(character.Index))
                {
                    characters.Add(character);
                }
            }

            if (characters.Count == 0)
            {
                // 没人能装备
                Context.ShowMessage("不能装备!", 1000);
            }
            else if (characters.Count == 1)
            {
                // 一个人能装备
                if (characters[0].HasEquipt(goods.Type, goods.Index))
                {
                    Context.ShowMessage("已装备!", 1000);
                }
                else
                {
                    Context.PushScreen(new ScreenChangeEquipment(Context, characters[0], (GoodsEquipment)goods));
                }
            }
            else
            {
                // 多人可装备
                Context.PushScreen(new MutilCharacterEquipScreen(Context, characters, goods));
            }
        }
 /// <summary>
 /// 使用单体物品
 /// </summary>
 /// <param name="context"></param>
 /// <param name="attacker"></param>
 /// <param name="target"></param>
 /// <param name="goods"></param>
 public ActionUseItemOne(SimulatorContext context, FightingCharacter attacker, FightingCharacter target, BaseGoods goods) : base(context, attacker, target)
 {
     _goods = goods;
 }
 /// <summary>
 /// 使用群体物品
 /// </summary>
 /// <param name="context"></param>
 /// <param name="attacker"></param>
 /// <param name="targets"></param>
 /// <param name="goods"></param>
 public ActionUseItemAll(SimulatorContext context, FightingCharacter attacker, List <FightingCharacter> targets, BaseGoods goods) : base(context, attacker, targets)
 {
     _goods = goods;
 }
示例#15
0
 /// <summary>
 /// 初始化出售的物品
 /// </summary>
 /// <param name="goods"></param>
 public void Init(BaseGoods goods)
 {
     _goods     = goods;
     _saleCount = 0;
     _money     = Context.PlayContext.Money;
 }