def skip(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: self._cli.NotifyToServer('G_COURT', { 'pid': clientApi.GetLocalPlayerId(), 'name': 'play', 'args': [{}] })
def OnDeliverbbParticle(self, args): eid = args['eid'] # 获取位置 并检查是否存在 posComp = self.CreateComponent(eid, "Minecraft", "pos") if not posComp.pos: return # 创建粒子 tempEntityEffect = self.CreateTempEntity() typeComp = self.CreateComponent(tempEntityEffect.mId, 'Minecraft', 'type') typeComp.type = clientApi.GetMinecraftEnum().EntityConst.TYPE_PARTICLE pathComp = self.CreateComponent(tempEntityEffect.mId, 'Minecraft', 'path') pathComp.path = "effects/bb.json" transComp = self.CreateComponent(tempEntityEffect.mId, 'Minecraft', 'particleTrans') transComp.pos = posComp.pos particleEntityId = self.CreateEntity(tempEntityEffect) # 播放 ctrlComp = self.CreateComponent(particleEntityId, 'Minecraft', 'particleControl') ctrlComp.open = True self.NeedsUpdate(ctrlComp) #绑定粒子 bindComp = self.CreateComponent(particleEntityId, "Minecraft", "particleEntityBind") bindComp.bindEntityId = eid bindComp.offset = (0.0, 0.0, 0.0) bindComp.rot = (0.0, 0.0, 0.0) self.NeedsUpdate(bindComp)
def match(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: if self._court is not None: self._cli.NotifyToServer('G_MATCH', { 'pid': clientApi.GetLocalPlayerId(), 'court': self._court })
def fightover(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: self._cli.NotifyToServer('G_COURT', { 'pid': clientApi.GetLocalPlayerId(), 'name': 'choose', 'args': [1] })
def OnBulletFlyFrame(self, data): logger.info("OnBulletFlyFrame: %s", data) bindId = data.get("bindId", "-1") # 同服务端的解释,tempEntity保存来自各个Component的数据 tempEntity = self.CreateTempEntity() typeComp = self.CreateComponent(tempEntity.mId, modConfig.Minecraft, modConfig.ScriptTypeCompClient) typeComp.type = clientApi.GetMinecraftEnum().EntityConst.TYPE_SFX pathComp = self.CreateComponent(tempEntity.mId, modConfig.Minecraft, modConfig.PathComponent) pathComp.path = modConfig.BulletFlyFrameSfx # 创建真正的特效SFX实体绑定在子弹上 frameEntityId = self.CreateEntity(tempEntity) entityBindComp = self.CreateComponent(frameEntityId, modConfig.Minecraft, modConfig.FrameAniBindComponent) entityBindComp.bindEntityId = bindId entityBindComp.offset = (-1, 0, 0) entityBindComp.rot = (0, 0, 0) self.NeedsUpdate(entityBindComp) playerPosComp = self.GetComponent(self.mPlayerId, modConfig.Minecraft, modConfig.PosComponent) transComp = self.CreateComponent(frameEntityId, modConfig.Minecraft, modConfig.FrameAniTransComponent) transComp.pos = playerPosComp.pos self.NeedsUpdate(transComp) ctrlComp = self.CreateComponent(frameEntityId, modConfig.Minecraft, modConfig.FrameAniCtrlComponent) ctrlComp.open = True ctrlComp.loop = True ctrlComp.faceCamera = True self.NeedsUpdate(ctrlComp) # 将特效实体Id保存在self.mHitDestroyIdList中,后续更新中会清除 bindList = self.mHitDestroyIdList.setdefault(bindId, []) bindList.append(frameEntityId)
def select(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchMoveIn: if self.duel: i = int(kws['ButtonPath'][::-1].split('/', 1)[0][:-1][::-1]) if i in self.duel.gamblers[self.duel.uid].cards: x, y = self.origins[i] if i in self.selected: self.selected.discard(i) self.SetPosition(kws['ButtonPath'], (x, y)) else: self.selected.add(i) self.SetPosition(kws['ButtonPath'], (x, y - 14.0))
def rookie(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: if self.retreat: pass elif self._court is None: self._court = 0 self.SetText(self.fee, '996') self.SetText(self.utmost, '4396万') self.SetVisible(self.top, False) self.SetVisible(self.flip, False) self.SetVisible(self.toolbar, False) self.SetVisible(self.infobar, True) self.SetVisible(self.room, True)
def propose(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: if self.duel and self.duel.chain: phase = self.duel.chain.phase track = self.duel.chain.track if phase.turn == self.duel.uid and phase.name == 'MainPhase': if self.proposals is None: self.last_proposal = None cards = {} for card in self.duel.gamblers[self.duel.uid].cards.itervalues(): cards.setdefault(card[0], []).append(card) duo = list(track[-2:]) duo.extend(None for _ in xrange(2 - len(track))) if duo == [None, None]: combo = None else: try: duo.remove(None) except ValueError: pass combo = duo[-1] self.proposals = Combo.propose(cards, combo) if not self.proposals: self.SetVisible(self.notice, True) proposals = self.proposals # type: list if proposals: if len(proposals) != 1 or self.last_proposal != self.selected: self.SetVisible(self.notice, False) proposals.append(proposals.pop(0)) proposal = proposals[-1][-1].copy() cards = self.duel.gamblers[self.duel.uid].cards for i in xrange(max(cards), min(cards) - 1, -1): x, y = self.origins[i] h = self.mh + '/m{}'.format(i) if cards[i][0] in proposal: k = cards[i][0] proposal[k] -= 1 if not proposal[k]: del proposal[k] self.selected.add(i) self.SetPosition(h, (x, y - 14.0)) else: self.selected.discard(i) self.SetPosition(h, (x, y)) if not self.last_proposal and len(proposals) == 1: self.last_proposal = self.selected.copy()
def play(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: if self.duel and self.duel.chain: phase = self.duel.chain.phase if self.selected and phase.turn == self.duel.uid and phase.name == 'MainPhase': if self.last_result[0] != self.selected: cards = {} gambler = self.duel.gamblers[self.duel.uid] for i in self.selected: card = gambler.cards[i] cards.setdefault(card[0], []).append(card) valid = Combo.fromcards(cards, None) self.last_result = self.selected.copy(), valid and cards if not valid: self.SetVisible(self.notice, True) cards = self.last_result[1] if cards: self._cli.NotifyToServer('G_COURT', { 'pid': clientApi.GetLocalPlayerId(), 'name': 'play', 'args': [cards] })
def OnBulletHit(self, data): logger.info("OnBulletHit %s", data) bulletId = data.get("bulletId", "-1") targetId = data.get("targetId", "-1") hitFace = data.get("hitFace", -1) pos = data.get("pos", (0, 0, 0)) pos = tuple(pos) # 添加播放声音的Component audioComp = self.CreateComponent(self.mPlayerId, modConfig.Minecraft, modConfig.AudioComponent) audioComp.name = modConfig.BulletHitSound audioComp.pos = pos audioComp.volume = 1.0 audioComp.pitch = 1.0 audioComp.needPlay = True self.NeedsUpdate(audioComp) # 添加击中后在原地产生的爆炸粒子特效 tempEntity = self.CreateTempEntity() typeComp = self.CreateComponent(tempEntity.mId, modConfig.Minecraft, modConfig.ScriptTypeCompClient) typeComp.type = clientApi.GetMinecraftEnum().EntityConst.TYPE_PARTICLE pathComp = self.CreateComponent(tempEntity.mId, modConfig.Minecraft, modConfig.PathComponent) pathComp.path = modConfig.BulletHitEffect transComp = self.CreateComponent(tempEntity.mId, modConfig.Minecraft, modConfig.ParticleTransComponent) transComp.pos = pos particleEntityId = self.CreateEntity(tempEntity) ctrlComp = self.CreateComponent(particleEntityId, modConfig.Minecraft, modConfig.ParticleControlComponent) ctrlComp.open = True self.NeedsUpdate(ctrlComp) # 爆炸的粒子特效延迟销毁 CoroutineMgr.StartCoroutine(self.DelayCloseParticleControl(ctrlComp)) # 在每次射中后删除绑定在子弹上的特效 destroyList = self.mHitDestroyIdList.get(bulletId, None) if destroyList: for entityId in destroyList: self.DestroyEntity(entityId)
def classical(self, kws): if kws["TouchEvent"] == clientApi.GetMinecraftEnum().TouchEvent.TouchUp: self.SetVisible(self.c, False) self.SetVisible(self.cc, True)