Example #1
0
# -*- coding: utf-8 -*-
#
import client.extraClientApi as clientApi

ClientSystem = clientApi.GetClientSystemCls()

class LobbyGoodDemoClient(ClientSystem):
	def __init__(self, namespace, systemName):
		ClientSystem.__init__(self, namespace, systemName)
		self.DefineEvent('RequestbbParticle')
		self.ListenForEvent('LobbyGoodDemo', 'LobbyGoodDemoServer', 'DeliverbbParticle', self, self.OnDeliverbbParticle)
		self.ListenForEvent(clientApi.GetEngineNamespace(), clientApi.GetEngineSystemName(), "AddPlayerEvent",
		                    self, self.RequestbbParticle)


	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)
		# 播放
Example #2
0
class Cli(clientApi.GetClientSystemCls()):
    def Update(self):
        self._update()

    def Destroy(self):
        self.UnListenForEvent(clientApi.GetEngineNamespace(), clientApi.GetEngineSystemName(), 'UiInitFinished', self,
                              self.initialize)
        self.UnListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_SRV_NAME, 'G_DEBUT', self, self.debut)
        self.UnListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_SRV_NAME, 'G_COURT', self, self.catch_up)

        self._destroy()

    @property
    def info(self):
        return self._info

    @info.setter
    def info(self, info):
        self._info = info
        if self._g:
            self._g.real = info

    def __init__(self, *args):
        super(Cli, self).__init__(*args)
        self.ListenForEvent(clientApi.GetEngineNamespace(), clientApi.GetEngineSystemName(), 'UiInitFinished', self,
                            self.initialize)
        self.ListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_SRV_NAME, 'G_DEBUT', self, self.debut)
        self.ListenForEvent(cfg.MOD_NAMESPACE, cfg.MOD_SRV_NAME, 'G_COURT', self, self.catch_up)

        self._info = None
        self.cache = None
        self._g = None  # type: GUI
        self._debut = False

    def _update(self):
        pass

    def _destroy(self):
        pass

    def initialize(self, *args):
        clientApi.RegisterUI(cfg.MOD_NAMESPACE, cfg.UI_NAMESPACE, cfg.UI_CLASS, cfg.UI_MAIN)
        self._g = clientApi.CreateUI(cfg.MOD_NAMESPACE, cfg.UI_NAMESPACE, {"isHud": 0})  # type: GUI
        self._g._cli = self
        if self._debut:
            self._g.duel = self.cache
            if self.info:
                self._g.real = self.info
        else:
            self._g.standby()
            self.NotifyToServer('G_DEBUT', {
                'pid': clientApi.GetLocalPlayerId(),
            })

    def debut(self, data):
        if self.info is None:
            self.info = data['info']
        if not self._debut:
            self._debut = True
            args = data.get('args')
            if self._g:
                self._g.duel = args
            else:
                self.cache = args

    def catch_up(self, data):
        args = data['args']
        if self._g:
            self._g.duel = args
        else:
            self.cache = args
        if not self._debut:
            self._debut = True