public void LaunchBullet(NetCmdPack pack) { NetCmdBullet cmd = (NetCmdBullet)pack.cmd; byte clientSeat, id; SceneRuntime.BuuletIDToSeat(cmd.BulletID, out clientSeat, out id); if (GetPlayer(clientSeat) == null) { return; } ScenePlayer sp = GetPlayer(clientSeat); if (sp.Launcher.LauncherType != cmd.LauncherType) { sp.Launcher.ChangeLauncher(cmd.LauncherType, true); } if (sp == null) { LogMgr.Log("不存在的玩家座位:" + clientSeat); return; } float elapsedTime = (Utility.GetTickCount() - pack.tick) * 0.001f + SceneRuntime.NetDelayTime; short degree = SceneRuntime.AngleInversion(cmd.Degree); SceneRuntime.BulletMgr.LaunchBullet(cmd.BulletID, sp.Launcher.LauncherType, sp.RateIndex, degree, elapsedTime, cmd.ReboundCount, cmd.LockFishID); sp.Launcher.LauncherBullet(cmd.Energy); // SceneRuntime.SceneModel.LaunchBullet(clientSeat, sp.Launcher.LauncherType, sp.RateIndex); int gold = LauncherSetting.LauncherDataList[sp.Launcher.LauncherType].Consume * BulletSetting.BulletRate[sp.RateIndex]; ConsumeGold(clientSeat, gold, sp); }
public void LaunchBullet(ushort bulletID, byte launcherType, byte rateIndex, short angle, float time, byte reboundCount, ushort lockfishid /*, byte collidCount = 0, float pauseTime = 0, float speedScaling = 0*/) { byte clientSeat, id; SceneRuntime.BuuletIDToSeat(bulletID, out clientSeat, out id); Bullet bullet = new Bullet(); Vector3 startpos; Vector3 dir; float volume = 1; float curtime = Time.time; byte[] type = { 9, 9, 10, 11, 12 }; if (SceneRuntime.PlayerMgr.GetPlayer(clientSeat) == null) { return; } if (SceneRuntime.PlayerMgr.GetPlayer(clientSeat) == SceneRuntime.PlayerMgr.MySelf) { volume = 1; lastTime = curtime; //AudioManager.Instance.PlayOrdianryMusic((Audio.OrdianryMusic) type[launcherType], false, false, volume); } else { volume = 0.30f; if ((lastTime + 0.1f) < curtime) { /*AudioManager.Instance.PlayOrdianryMusic((Audio.OrdianryMusic) type[launcherType], false, false, * volume);*/ } } SceneRuntime.GetBulletPosAndDir(clientSeat, angle, out dir, out startpos); SceneRuntime.PlayerMgr.ChangeLauncherAngle(dir, clientSeat); //改变炮台角度 bullet.Init(clientSeat, id, launcherType, rateIndex, startpos, dir, reboundCount, lockfishid); bullet.InitAngle(Utility.ShortToFlaot(angle)); //bullet.SetCollidData(collidCount, pauseTime, speedScaling); PlayerBullets pb = m_PlayerBullets[clientSeat]; if (pb != null) { Bullet findBullet; if (pb.BulletList.TryGetValue(id, out findBullet)) { Debug.Log("相同的子弹ID:" + id); findBullet.Destroy(); pb.BulletList.Remove(id); } if (time > 0) { bullet.Update(time); } pb.BulletList.Add(id, bullet); } }
public void OnLaunchBullet(IEvent iEvent) { NetCmdPack pack = iEvent.parameter as NetCmdPack; if (pack != null) { NetCmdBullet cmd = (NetCmdBullet)pack.cmd; byte clientSeat, id; SceneRuntime.BuuletIDToSeat(cmd.BulletID, out clientSeat, out id); if (clientSeat == SceneRuntime.MyClientSeat) { /*uint time = Utility.GetTickCount() - bulletTick; * SceneMain.Instance.bulletTime.AddTime(time);*/ } m_PlayerMgr.LaunchBullet(pack); } }
public void LaunchSyncBullet(NetCmdPack pack) { NetCmdSyncBullet cmd = (NetCmdSyncBullet)pack.cmd; float elapsedTime = (Utility.GetTickCount() - pack.tick) * 0.001f + SceneRuntime.NetDelayTime; for (int i = 0; i < cmd.Bullets.Length; ++i) { SyncBulletData data = cmd.Bullets[i]; byte clientSeat, id; SceneRuntime.BuuletIDToSeat(data.BulletID, out clientSeat, out id); ScenePlayer sp = GetPlayer(clientSeat); if (sp == null) { //LogMgr.Log("不存在的玩家座位:" + clientSeat); return; } short degree = SceneRuntime.AngleInversion(data.Degree); SceneRuntime.BulletMgr.LaunchBullet(data.BulletID, data.BulletType, data.RateIdx, degree, data.Time * 0.001f + elapsedTime, data.ReboundCount, data.LockFishID /*, data.CollideCount, data.PauseTime * 0.001f, data.SpeedScaling * 0.001f*/); //int gold = LauncherSetting.LauncherDataList[data.BulletType].Consume * BulletSetting.BulletRate[data.RateIdx]; //ConsumeGold(clientSeat, gold, sp); } }
public void FishCatched(NetCmdPack pack) { Debug.Log("FishCatched"); NetCmdCatched cmd = (NetCmdCatched)pack.cmd; byte clientSeat; byte id; SceneRuntime.BuuletIDToSeat(cmd.BulletID, out clientSeat, out id); CatchBulletData cbd = SceneRuntime.BulletMgr.GetBullet(clientSeat, id); if (cbd.IsValid() == false) { return; } if (SceneRuntime.PlayerMgr.GetPlayer(clientSeat) == null) { return; } bool bNotDelay = Utility.GetTickCount() - pack.tick < ConstValue.FISH_OVER_TIME; CatchedData cd = new CatchedData(); cd.CatchType = (byte)CatchedType.CATCHED_BULLET; cd.ClientSeat = clientSeat; cd.FishList = new List <CatchFishData>(); ushort lockfishid = 0; if (cbd.BulletObj != null) { if (cbd.BulletObj.LauncherType == 4) { lockfishid = cbd.BulletObj.LockedFishID; } cd.SubType = cbd.BulletObj.LauncherType; cd.RateIndex = cbd.BulletObj.RateIndex; } else { cd.SubType = cbd.LauncherType; cd.RateIndex = cbd.RateIndex; } if (bNotDelay == false) { ProcessDelayOver(cmd.Fishs, cd); return; } CatchLithingList cll = null; BlendData bd = new BlendData(Color.red, 0.6f, 0, 0, 0.4f); if (cmd.Fishs != null) { for (int i = 0; i < cmd.Fishs.Length; ++i) { NetFishCatched nfc = cmd.Fishs[i]; CatchFishData cfd = SceneRuntime.FishMgr.FindFish(nfc.FishID); if (cfd.IsValidFishType() == false) { continue; } Fish fish = cfd.FishObj; if (fish != null && fish.FishID == lockfishid) { cbd.BulletObj.ClearLockFishID();//只有穿透子弹才需要清空锁定,其他子弹发生碰撞就销毁了。 } switch ((FishCatchEventType)nfc.CatchEvent) { case FishCatchEventType.CATCH_EVENT_EFFECT: if (fish == null || fish.Catched) { continue; } if (fish.HasOpt == false) { FishOptReduction ff = new FishOptReduction(1.0f, new ReductionData(1.0f, 0, 0, 0.5f), 0, bd); fish.AddOpt(ff); } break; case FishCatchEventType.CATCH_EVENT_ATTACK: if (fish == null || fish.Catched) { continue; } FishOptReduction ff1 = new FishOptReduction(0.5f, new ReductionData(0.5f, 0, 0, 0.5f), 0, bd); fish.AddOpt(ff1); if (FishResManager.Instance.GetFishData(fish.FishType).ClipLength[(int)FishClipType.CLIP_GONGJI] != 0) { FishOptAction foa = new FishOptAction(FishClipType.CLIP_GONGJI, 1.5f); fish.AddOpt(foa); } break; case FishCatchEventType.CATCH_EVENT_CATCHED: if (fish != null) { FishOptReduction deadRed = new FishOptReduction(1.0f, new ReductionData(0, 0, 1.0f, 0), 0, bd); FishOptAction fod = new FishOptAction(FishClipType.CLIP_SIWANG, 1.0f); fod.SetDeadData(0, false, cd); fish.ClearOpt(); fish.AddOpt(fod); fish.AddOpt(deadRed); fish.SetCatched(clientSeat); fish.SetDropReward(nfc.nReward); } else { SceneRuntime.PlayerMgr.UpdatePlayerGold(clientSeat, SceneRuntime.GetFishGold(cfd.FishType, cd.RateIndex)); } cd.FishList.Add(cfd); break; case FishCatchEventType.CATCH_EVENT_CATCHED_LIGHTING_MAIN: if (fish != null) { FishOptReduction deadRed = new FishOptReduction(1.0f, new ReductionData(0, 0, 2.0f, 0), 0, null); FishOptAction fod = new FishOptAction(FishClipType.CLIP_SIWANG, 1.0f); fod.SetDeadData(1, false, cd); fish.ClearOpt(); fish.AddOpt(fod); fish.AddOpt(deadRed); fish.SetCatched(clientSeat); fish.SetDropReward(nfc.nReward); if (cll == null) { cll = new CatchLithingList(); } cll.AddMainFish(fish); } else { SceneRuntime.PlayerMgr.UpdatePlayerGold(clientSeat, SceneRuntime.GetFishGold(cfd.FishType, cd.RateIndex)); } cd.FishList.Add(cfd); break; case FishCatchEventType.CATCH_EVENT_CATCHED_LIGHTING: if (fish != null) { FishOptReduction deadRed = new FishOptReduction(1.0f, new ReductionData(0, 0, 2.0f, 0), 0, null); FishOptAction fod = new FishOptAction(FishClipType.CLIP_SIWANG, 1.0f); fod.SetDeadData(1, false, cd); fish.ClearOpt(); fish.AddOpt(fod); fish.AddOpt(deadRed); fish.SetCatched(clientSeat); fish.SetDropReward(nfc.nReward); CatchFishData cfd2 = SceneRuntime.FishMgr.FindFish(nfc.LightingFishID); if (cfd2.IsValidFishType()) { if (cll == null) { cll = new CatchLithingList(); } cll.AddSubFish(cfd2.FishObj, fish); } } else { SceneRuntime.PlayerMgr.UpdatePlayerGold(clientSeat, SceneRuntime.GetFishGold(cfd.FishType, cd.RateIndex)); } cd.FishList.Add(cfd); break; } } } if (cd.FishList.Count > 0) { SceneRuntime.ComputeGoldNum(cd); SceneRuntime.SceneModel.CatchFish(cd); } SceneRuntime.PlayerMgr.FishCatch(clientSeat, cmd.Combo); if (cbd.BulletObj != null) { cbd.BulletObj.GoldNum += cd.GoldNum; SceneRuntime.EffectMgr.PlayFishNet(cbd.BulletObj.Position, cd.SubType); } if (cd.SubType != 4) { SceneRuntime.BulletMgr.RemoveBullet(clientSeat, id); } if (cll != null) { ProcessLightingData(cll); } //SceneRuntime.PlayerMgr.UpdatePlayerGold(clientSeat, cd.GoldNum); //if (clientSeat == SceneRuntime.MyClientSeat) //{ // if (cd.GoldNum != cmd.GoldNum) // { // LogMgr.Log("子弹:金币不相等:" + cd.GoldNum + "," + cmd.GoldNum); // } // else if (PlayerRole.Instance.RoleInfo.RoleMe.GetGlobel() != cmd.TotalNum) // { // LogMgr.Log("子弹:总金币不相等:" + (PlayerRole.Instance.RoleInfo.RoleMe.GetGlobel()) + "," + cmd.TotalNum); // } //} }