private bool ProcessForwardBulletCannons(ref int p, byte[] d, long bseq, float sendertime) { int count = d[p]; p++; for (int i = 0; i < count; i++) { var id = NetworkDataTools.GetByte(d[p + 0]); var ifrac = NetworkDataTools.GetHighBits(d[p + 1], 3); var boost = NetworkDataTools.GetLowBits(d[p + 1], 5); var rotA = NetworkDataTools.ConvertToRadians(NetworkDataTools.GetByte(d[p + 2]), 8); var rotT = NetworkDataTools.ConvertToRadians(NetworkDataTools.GetByte(d[p + 3]), 8); var hp = NetworkDataTools.GetByte(d[p + 4]) / 255f; var chrg = NetworkDataTools.GetByte(d[p + 5]) / 255f; var shield = NetworkDataTools.GetByteFloorRange(d[p + 6], 0, Cannon.MAX_SHIELD_TIME); var frac = Screen.GetFractionByID(ifrac, out bool gfbiError); if (gfbiError) { SAMLog.Error("SNS-COMMON::PFBC_GFBI", "GetFractionByID returned error: Unknown Fraction " + ifrac + "\nData:\n" + ByteUtils.CompressBytesForStorage(d)); return(false); } Cannon c; if (Screen.CannonMap.TryGetValue(id, out c)) { BulletCannon bc = c as BulletCannon; if (bc != null && ShouldRecieveData(frac, bc)) { if (ShouldRecieveRotationData(frac, bc)) { bc.RemoteRotationUpdate(rotA, rotT, sendertime); } if (ShouldRecieveStateData(frac, bc)) { bc.RemoteUpdate(frac, hp, boost, chrg, shield, sendertime); } } } p += PLEN_BULLETCANNON; } return(true); }
//We receive an IBullet by passing a BulletType enum value (We can't see the specific types of IBullet, cause they're nested and private!) public static IBullet Get(BulletType type) { IBullet toReturn = null; switch (type) { case BulletType.Cannon: toReturn = new BulletCannon(10f); break; case BulletType.Gatling: toReturn = new BulletGatling(1000f); break; default: break; } return(toReturn); }
private void ProcessForwardBulletCannons(ref int p, byte[] d, long bseq, float sendertime) { int count = d[p]; p++; for (int i = 0; i < count; i++) { var id = NetworkDataTools.GetByte(d[p + 0]); var frac = Screen.GetFractionByID(NetworkDataTools.GetHighBits(d[p + 1], 3)); var boost = NetworkDataTools.GetLowBits(d[p + 1], 5); var rotA = NetworkDataTools.ConvertToRadians(NetworkDataTools.GetByte(d[p + 2]), 8); var rotT = NetworkDataTools.ConvertToRadians(NetworkDataTools.GetByte(d[p + 3]), 8); var hp = NetworkDataTools.GetByte(d[p + 4]) / 255f; var chrg = NetworkDataTools.GetByte(d[p + 5]) / 255f; var shield = NetworkDataTools.GetByteFloorRange(d[p + 6], 0, Cannon.MAX_SHIELD_TIME); Cannon c; if (Screen.CannonMap.TryGetValue(id, out c)) { BulletCannon bc = c as BulletCannon; if (bc != null && ShouldRecieveData(frac, bc)) { if (ShouldRecieveRotationData(frac, bc)) { bc.RemoteRotationUpdate(rotA, rotT, sendertime); } if (ShouldRecieveStateData(frac, bc)) { bc.RemoteUpdate(frac, hp, boost, chrg, shield, sendertime); } } } p += PLEN_BULLETCANNON; } }
private void LoadLevelFromBlueprint() { Fraction[] fracList = { fractionNeutral, fractionPlayer, fractionComputer1, fractionComputer2, fractionComputer3 }; //---------------------------------------------------------------- MapFullBounds = new FRectangle(0, 0, Blueprint.LevelWidth, Blueprint.LevelHeight); MapViewportCenterX = Blueprint.LevelViewX; MapViewportCenterY = Blueprint.LevelViewY; WrapMode = (GameWrapMode)Blueprint.WrapMode; if (WrapMode == GameWrapMode.Donut || WrapMode == GameWrapMode.Reflect) { VAdapterGame.ChangeVirtualSize(GDConstants.VIEW_WIDTH + GDConstants.TILE_WIDTH, GDConstants.VIEW_HEIGHT + GDConstants.TILE_WIDTH); MapViewportCenterX = Blueprint.LevelViewX; MapViewportCenterY = Blueprint.LevelViewY; } if (MainGame.Inst.Profile.EffectsEnabled && WrapMode == GameWrapMode.Donut) { Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.NN)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.EE)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.SS)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.WW)); } if (MainGame.Inst.Profile.EffectsEnabled) { Background = new GDCellularBackground(this, Blueprint); } else { Background = new GDStaticGridBackground(this, WrapMode); } //---------------------------------------------------------------- var cannonList = new List <Cannon>(); var portalList = new List <Portal>(); var fractionList = new List <Fraction>(); var laserworld = false; fractionList.Add(fractionNeutral); foreach (var bPrint in Blueprint.BlueprintCannons) { var e = new BulletCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintMinigun) { var e = new MinigunCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintRelayCannon) { var e = new RelayCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintTrishotCannon) { var e = new TrishotCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintVoidWalls) { var e = new VoidWall(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintVoidCircles) { var e = new VoidCircle(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintGlassBlocks) { var e = new GlassBlock(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintBlackHoles) { var e = new BlackHole(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintPortals) { var e = new Portal(this, bPrint); Entities.AddEntity(e); portalList.Add(e); } foreach (var bPrint in Blueprint.BlueprintLaserCannons) { var e = new LaserCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); laserworld = true; if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintShieldProjector) { var e = new ShieldProjectorCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); laserworld = true; if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintMirrorBlocks) { var e = new MirrorBlock(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintMirrorCircles) { var e = new MirrorCircle(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintBackgroundText) { var e = new BackgroundText(this, bPrint); Entities.AddEntity(e); } //---------------------------------------------------------------- if (laserworld) { Entities.AddEntity(new LaserRenderer(this, LaserNetwork, Blueprint)); } AddEdgeMarker(); //---------------------------------------------------------------- foreach (var cannon in cannonList) { cannon.OnAfterLevelLoad(); } foreach (var portal in portalList) { portal.OnAfterLevelLoad(portalList); } CannonMap = cannonList.ToDictionary(p => p.BlueprintCannonID, p => p); foreach (var f in fracList) { if (!fractionList.Contains(f)) { fractionList.Add(f); } } fractionIDList = fractionList.ToArray(); //---------------------------------------------------------------- if (!IsPreview && (Blueprint.LevelWidth > GDConstants.VIEW_WIDTH || Blueprint.LevelHeight > GDConstants.VIEW_HEIGHT)) { AddAgent(new GameDragAgent(this)); } }