public override void Update(float seconds) { base.Update(seconds); SyncCasheWriter.SubmitNewStatus(this.MgPath, "Pos", SyncImportant.HighFrequency, Pos); SyncCasheWriter.SubmitNewStatus(this.MgPath, "Vel", SyncImportant.HighFrequency, Vel); SyncCasheWriter.SubmitNewStatus(this.MgPath, "Azi", SyncImportant.HighFrequency, Azi); }
public override void Update(float seconds) { base.Update(seconds); controller.Update(seconds); skin.Update(seconds); SyncCasheWriter.SubmitNewStatus(this.MgPath, "TurnTurretWiseSpeed", SyncImportant.MidFrequency, this.TurnTurretWiseSpeed); SyncCasheWriter.SubmitNewStatus(this.MgPath, "TurnRaderWiseSpeed", SyncImportant.MidFrequency, this.TurnRaderWiseSpeed); SyncCasheWriter.SubmitNewStatus(this.MgPath, "TurretAzi", SyncImportant.MidFrequency, this.TurretAzi); SyncCasheWriter.SubmitNewStatus(this.MgPath, "RaderAzi", SyncImportant.MidFrequency, this.RaderAzi); }
public override void Update(float seconds) { liveTimer += seconds; if (liveTimer > 0) { if (OnOutDate != null) { OnOutDate(this, Firer); } } SyncCasheWriter.SubmitNewStatus(this.MgPath, "Pos", SyncImportant.HighFrequency, this.Pos); SyncCasheWriter.SubmitNewStatus(this.MgPath, "Vel", SyncImportant.HighFrequency, this.Vel); }
private void UpdateTimer(float second) { if (gameTotolTime > 0) { gameTotolTime -= second; } if (gameTotolTime <= 0 && PurviewMgr.IsMainHost) { SyncCasheWriter.SubmitUserDefineInfo("Over", ""); SendOverRankInfo(); isSendOver = true; //GameOver(); } }
private void SyncShipScoreHp(WarShip ship, bool subScore) { if (PurviewMgr.IsMainHost) { if (subScore) { SyncCasheWriter.SubmitUserDefineInfo("Score", "", ship, ship.Score); } else { SyncCasheWriter.SubmitUserDefineInfo("Hp", "", ship, ship.HP); } } }
void WarShip_OnShoot(WarShip firer, Vector2 endPoint, float azi) { if (PurviewMgr.IsMainHost) { WarShipShell shell = new WarShipShell("shell" + shellcount, firer, endPoint, azi); shell.onCollided += new OnCollidedEventHandler(Shell_onCollided); shell.OnOutDate += new WarShipShell.ShellOutDateEventHandler(Shell_OnOutDate); sceneMgr.AddGameObj("shell", shell); SyncCasheWriter.SubmitCreateObjMg("shell", typeof(WarShipShell), "shell" + shellcount, firer, endPoint, azi); shellcount++; } }
void tank_onShoot(Tank sender, Vector2 turretEnd, float azi) { if (PurviewMgr.IsMainHost) { ShellNormal shell = new ShellNormal("shell" + shellSum.ToString(), sender, turretEnd, azi, shellSpeed); sceneMgr.AddGameObj("shell", shell); shell.onCollided += new OnCollidedEventHandler(shell_onCollided); shellSum++; SyncCasheWriter.SubmitCreateObjMg("shell", typeof(ShellNormal), shell.Name, sender, turretEnd, azi, shellSpeed); } Sound.PlayCue("CANNON1"); }
private void BroadcastObjPhiStatus(IGameObj obj, bool collide) { if (obj is IPhisicalObj) { if (collide) { NonInertiasPhiUpdater phiUpdater = (NonInertiasPhiUpdater)((IPhisicalObj)obj).PhisicalUpdater; SyncCasheWriter.SubmitUserDefineInfo("ObjPhiCollide", obj.ObjInfo.ObjClass, obj, phiUpdater.Pos, phiUpdater.Vel, phiUpdater.Azi, phiUpdater.AngVel); } else { NonInertiasPhiUpdater phiUpdater = (NonInertiasPhiUpdater)((IPhisicalObj)obj).PhisicalUpdater; SyncCasheWriter.SubmitUserDefineInfo("ObjPhi", obj.ObjInfo.ObjClass, obj, phiUpdater.Pos, phiUpdater.Vel, phiUpdater.Azi, phiUpdater.AngVel); } } }
private void SetGoldNewPos(Gold Sender) { if (PurviewMgr.IsMainHost) { while (true) { Vector2 pos = RandomHelper.GetRandomVector2(0, 1); pos.X *= mapRect.Width - 200; pos.Y *= mapRect.Height - 200; pos += new Vector2(100, 100); if (CanAddObjAtPos(pos)) { Sender.Born(pos); SyncCasheWriter.SubmitUserDefineInfo("GoldBorn", "", Sender, Sender.Pos); break; } } } }
void Warship_OnDead(WarShip sender) { //sceneMgr.DelGameObj(sender.MgPath); if (PurviewMgr.IsMainHost) { while (true) { Vector2 newPos = RandomHelper.GetRandomVector2(0, 1); newPos.X *= mapRect.Width; newPos.X += mapRect.X; newPos.Y *= mapRect.Height; newPos.Y += mapRect.Y; if (CanAddObjAtPos(newPos)) { (sender as WarShip).Born(newPos); SyncCasheWriter.SubmitUserDefineInfo("WarshipBorn", "", sender, newPos); break; } } } }
private void controller_OnPosAziChanged() { SyncCasheWriter.SubmitNewStatus(this.MgPath, "Pos", SyncImportant.MidFrequency, this.Pos); SyncCasheWriter.SubmitNewStatus(this.MgPath, "Azi", SyncImportant.MidFrequency, this.Azi); }
private void CommitSyncInfo() { SyncCasheWriter.SubmitNewStatus(this.mgPath, "Pos", SyncImportant.HighFrequency, this.Pos); SyncCasheWriter.SubmitNewStatus(this.mgPath, "Vel", SyncImportant.HighFrequency, this.Vel); SyncCasheWriter.SubmitNewStatus(this.mgPath, "Azi", SyncImportant.HighFrequency, this.Azi); }
private void CreateRock() { if (PurviewMgr.IsMainHost) { Vector2 newPos = new Vector2(); while (true) { newPos = RandomHelper.GetRandomVector2(-100, 100); int posType = RandomHelper.GetRandomInt(0, 2); if (posType == 0) { if (newPos.X < 0) { newPos.X -= mapRect.X + AddObjSpace; } else { newPos.X += mapRect.Width + mapRect.X + AddObjSpace; } if (newPos.Y < 0) { newPos.Y -= mapRect.Y + AddObjSpace; } else { newPos.Y += mapRect.Y + mapRect.Height + AddObjSpace; } } else if (posType == 1) { newPos.X *= mapRect.Width / 200; newPos.X += mapRect.Width / 2 + mapRect.X; if (newPos.Y < 0) { newPos.Y -= mapRect.Y + AddObjSpace; } else { newPos.Y += mapRect.Y + mapRect.Height + AddObjSpace; } } else if (posType == 2) { newPos.Y *= mapRect.Height / 200; newPos.Y += mapRect.Y + mapRect.Height / 2; if (newPos.X < 0) { newPos.X -= mapRect.X + AddObjSpace; } else { newPos.X += mapRect.Width + mapRect.X + AddObjSpace; } } if (CanAddObjAtPos(newPos)) { break; } } float speed = RandomHelper.GetRandomFloat(SpaceWarConfig.RockMinSpeed, SpaceWarConfig.RockMaxSpeed); Vector2 way = Vector2.Normalize(MapCenterPos - newPos); Vector2 delta = RandomHelper.GetRandomVector2(-0.7f, 0.7f); Vector2 Vel = Vector2.Normalize(way + delta) * speed; float aziVel = RandomHelper.GetRandomFloat(0, SpaceWarConfig.RockMaxAziSpeed); float scale = RandomHelper.GetRandomFloat(0.4f, 1.4f); int kind = RandomHelper.GetRandomInt(0, ((int)RockTexNo.Max) - 1); Rock newRock = new Rock("Rock" + rockCount, newPos, Vel, aziVel, scale, kind); newRock.OnCollided += new OnCollidedEventHandler(Rock_OnCollided); sceneMgr.AddGameObj("rock", newRock); rocks.Add(newRock); SyncCasheWriter.SubmitCreateObjMg("rock", typeof(Rock), "Rock" + rockCount, newPos, Vel, aziVel, scale, kind); rockCount++; } }