private void BulletIcon_OnClick(EventContext context) { this.m_infoTip.visible = true; this.m_infoTip.GetChild("bg").onClick.Set(() => { this.m_infoTip.visible = false; }); GComponent tip = this.m_infoTip.GetChild("InfoTip").asCom; tip.x = context.inputEvent.x; tip.y = context.inputEvent.y; BulletCfg bulletInfo = ((context.sender as GLoader).parent.data) as BulletCfg; tip.GetChild("n2").asLoader.url = bulletInfo.Icon; tip.GetChild("n4").asTextField.text = bulletInfo.Name(); tip.GetChild("n6").asTextField.text = bulletInfo.Type(); tip.GetChild("n8").asTextField.text = Message.Get(1088); GList attrList = tip.GetChild("n7").asList; attrList.numItems = 3; attrList.GetChildAt(0).asCom.GetChild("n0").asTextField.text = $"{Message.Get(1089)} +{bulletInfo.Attack}"; attrList.GetChildAt(1).asCom.GetChild("n0").asTextField.text = $"{Message.Get(1091)} +{bulletInfo.SunderArmor}"; attrList.GetChildAt(2).asCom.GetChild("n0").asTextField.text = $"{Message.Get(1092)} {bulletInfo.LoadingSpeed}"; attrList.ResizeToFit(3); }
private void BulletItemRender() { IConfig[] configs = Game.Scene.GetComponent <ConfigComponent>().GetAll(typeof(BulletCfg)); this.m_itemList.RemoveChildrenToPool(); for (int i = 0; i < configs.Length; i++) { BulletCfg bulletInfo = configs[i] as BulletCfg; if (bulletInfo.CanBuy == 0) { continue; } GComponent com = this.m_itemList.AddItemFromPool().asCom; com.GetChild("n11").text = bulletInfo.Name(); com.GetChild("n7").text = bulletInfo.Price.ToString(); com.GetChild("n15").asLoader.url = bulletInfo.Icon; com.GetChild("n15").asLoader.onClick.Set(this.BulletIcon_OnClick); com.GetChild("n12").text = Message.Get(1075); com.GetChild("n12").asButton.onClick.Set(() => { Send_C2G_OptGood(GoodType.Bullet, (int)bulletInfo.Id); }); com.data = bulletInfo; } }
protected override void Run(Session session, C2G_OptGood message) { Player player = session.GetComponent <SessionPlayerComponent>().Player; WarehouseComponent warehouse = player.UserDB.GetComponent <WarehouseComponent>(); UserBaseComponent userBase = player.UserDB.GetComponent <UserBaseComponent>(); switch (message.GoodType) { case GoodType.Tank: TankCfg tankInfo = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(TankCfg), message.TableId) as TankCfg; if (message.GoodOpt == GoodOpt.Use && warehouse.UseTankId != message.TableId && warehouse.isExitTank(message.TableId)) { warehouse.UseTankId = message.TableId; Send_G2C_Warehouse(player); player.Send_PopMessage(1083); } if (message.GoodOpt == GoodOpt.Buy) { if (warehouse.isExitTank(message.TableId)) { player.Send_PopMessage(1084); } else if (userBase.Gold < tankInfo.Price) { player.Send_PopMessage(1086); } else { userBase.Gold -= tankInfo.Price; player.Send_PopMessage(1087); warehouse.Tanks.Add(message.TableId); } } break; case GoodType.Bullet: BulletCfg bulletInfo = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(BulletCfg), message.TableId) as BulletCfg; if (message.GoodOpt == GoodOpt.Use && warehouse.UseBulletId != message.TableId && warehouse.isExitBullet(message.TableId)) { warehouse.UseBulletId = message.TableId; Send_G2C_Warehouse(player); player.Send_PopMessage(1085); } if (message.GoodOpt == GoodOpt.Buy) { if (warehouse.isExitBullet(message.TableId)) { player.Send_PopMessage(1084); } else if (userBase.Gold < bulletInfo.Price) { player.Send_PopMessage(1086); } else { userBase.Gold -= bulletInfo.Price; player.Send_PopMessage(1087); warehouse.Bullets.Add(message.TableId); } } break; case GoodType.Prop: Prop propInfo = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(Prop), message.TableId) as Prop; if (message.GoodOpt == GoodOpt.Use && warehouse.GetUnUseProp(message.TableId) != null) { PropItem unUseItem = warehouse.GetUnUseProp(message.TableId); PropItem inUseItem = warehouse.GetInUseProp(message.TableId); if (inUseItem != null) { inUseItem.TotalTimes += unUseItem.TotalTimes; unUseItem.Num -= 1; if (unUseItem.Num <= 0) { warehouse.UnUseProps.Remove(unUseItem); } } else { inUseItem = new PropItem(unUseItem); inUseItem.PropState = PropState.InUser; inUseItem.Num = 1; warehouse.InUseProps.Add(inUseItem); unUseItem.Num -= 1; if (unUseItem.Num <= 0) { warehouse.UnUseProps.Remove(unUseItem); } } Send_G2C_Warehouse(player); player.Send_PopMessage(1085); } if (message.GoodOpt == GoodOpt.Buy) { if (userBase.Gold < propInfo.Price) { player.Send_PopMessage(1086); break; } PropItem propItem = warehouse.GetUnUseProp(message.TableId); if (propItem != null) { propItem.Num += 1; } else { propItem = new PropItem(); propItem.PropState = PropState.WaitUse; propItem.TableId = message.TableId; propItem.BuyTime = TimeHelper.NowSecond(); propItem.Num = 1; propItem.TotalTimes = (Game.Scene.GetComponent <ConfigComponent>().Get(typeof(Prop), message.TableId) as Prop).TotleTimes; warehouse.UnUseProps.Add(propItem); } userBase.Gold -= propInfo.Price; player.Send_PopMessage(1087); Send_G2C_Warehouse(player); } break; default: Log.Error($"不存在的GoodType:{message.GoodType}"); break; } }