void Awake() { Instance = this; LoadNavigationMap(Fishing.Instance.GameID); //SendUserSettings()服务器框架设置玩家准备、更改玩家参数,SendUserReady()捕鱼游戏发场景函数 MobileFishingProtocol.GetInstance().SendUserSettings(); MobileFishingProtocol.GetInstance().SendUserReady(); MobileFishingProtocol.GetInstance().onLoadGameStationSuccessEvent += S_C_GameStation; MobileFishingProtocol.GetInstance().onUserJoinEvent += S_C_UserJoin; MobileFishingProtocol.GetInstance().onReceiveSystemTimeEvent += S_C_TimeSync; MobileFishingProtocol.GetInstance().onUserLeaveEvent += S_C_UserLeave; MobileFishingProtocol.GetInstance().onBuyBulletEvent += S_C_BuyBullet; MobileFishingProtocol.GetInstance().onGunFireEvent += S_C_GunFire; MobileFishingProtocol.GetInstance().onGunPowerUpEvent += S_C_GunPowerUp; //暂时还没使用. // MobileFishingProtocol.GetInstance().onGunMultiEvent += S_C_GunPowerMulti; MobileFishingProtocol.GetInstance().onReceiveGeneratorNPCEvent += S_C_NPC_Generator; MobileFishingProtocol.GetInstance().onNPCKillEvent += S_C_NPC_Kill; MobileFishingProtocol.GetInstance().onWinFromCacheEvent += S_C_WinFromCache; MobileFishingProtocol.GetInstance().onBalanceEvent += S_C_Balance; MobileFishingProtocol.GetInstance().onRobotGunFireNotifyEvent += S_C_RobotGunFireNotify; MobileFishingProtocol.GetInstance().onRobotGunFireEvent += S_C_RobotGunFire; Utility.SetResolutionRatio(); }
void OnDestroy() { // 记得清除factory里的缓存. Factory.Clear(); // GameApp.SceneMgr.SceneLoaded -= MessageHandlerInit; MobileFishingProtocol.GetInstance().onLoadGameStationSuccessEvent -= S_C_GameStation; MobileFishingProtocol.GetInstance().onUserJoinEvent -= S_C_UserJoin; MobileFishingProtocol.GetInstance().onReceiveSystemTimeEvent -= S_C_TimeSync; MobileFishingProtocol.GetInstance().onUserLeaveEvent -= S_C_UserLeave; MobileFishingProtocol.GetInstance().onBuyBulletEvent -= S_C_BuyBullet; MobileFishingProtocol.GetInstance().onGunFireEvent -= S_C_GunFire; MobileFishingProtocol.GetInstance().onGunPowerUpEvent -= S_C_GunPowerUp; //暂时还没使用. // MobileFishingProtocol.GetInstance().onGunMultiEvent -= S_C_GunPowerMulti; MobileFishingProtocol.GetInstance().onReceiveGeneratorNPCEvent -= S_C_NPC_Generator; MobileFishingProtocol.GetInstance().onNPCKillEvent -= S_C_NPC_Kill; MobileFishingProtocol.GetInstance().onWinFromCacheEvent -= S_C_WinFromCache; MobileFishingProtocol.GetInstance().onBalanceEvent -= S_C_Balance; MobileFishingProtocol.GetInstance().onRobotGunFireNotifyEvent -= S_C_RobotGunFireNotify; MobileFishingProtocol.GetInstance().onRobotGunFireEvent -= S_C_RobotGunFire; Instance = null; }
// 购买子弹. public void C_S_BuyBullet(uint _buyScore) { MobileFishingProtocol.GetInstance().UserBuyBullet(_buyScore); }
// 机器人发泡. public void C_S_RobotGunFire(int _robotChair, float _eulerZ, Vector2 _pos, int _serverId, int _bulletCost, uint _serverTime) { MobileFishingProtocol.GetInstance().C_S_RobotGunFire((uint)_robotChair, (uint)_serverId, _eulerZ, _pos.x, _pos.y, (uint)_bulletCost, _serverTime); }
// 机器人子弹击中鱼. public void C_S_RobotBulletAttack(int _robotChair, int _serverID, int _bulletCost, int _bulletPower, int _multi) { MobileFishingProtocol.GetInstance().C_S_RobotBulletAttack((uint)_robotChair, (uint)_serverID, (uint)_bulletCost, (uint)_bulletPower, (uint)_multi); }
// 时间同步. public void C_S_TimeSync() { MobileFishingProtocol.GetInstance().C_S_TimeSync(); }
// 结算. public void C_S_Balance() { MobileFishingProtocol.GetInstance().C_S_Balance(); }
// 索要缓存. public void C_S_WinFromCache(uint _fishServerID, uint _power, uint _multi) { MobileFishingProtocol.GetInstance().C_S_WinFromCache(_fishServerID, _power, _multi); }
// 发泡. public void C_S_GunFire(float _eulerZ, Vector2 _firePos, int _serverId, int _bulletCost, uint _serverTime) { MobileFishingProtocol.GetInstance().C_S_GunFire(_eulerZ, _firePos.x, _firePos.y, (uint)_serverId, (uint)_bulletCost, (uint)_serverTime); }
// 加炮. public void C_S_GunPowerUp(uint _power) { MobileFishingProtocol.GetInstance().C_S_GunPowerUp(_power); }