Ejemplo n.º 1
0
        public LaserSource AddSource(ShieldProjectorCannon e)
        {
            var src = new LaserSource(this, e.Position, _screen.GetNeutralFraction(), e, RayType.Shield);

            Sources.Add(src);
            return(src);
        }
Ejemplo n.º 2
0
        private bool ProcessForwardShieldProjectors(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.GetSingle(d[p + 2], d[p + 3], d[p + 4], d[p + 5]);
                var rotT  = NetworkDataTools.GetSingle(d[p + 6], d[p + 7], d[p + 8], d[p + 9]);
                var hp    = NetworkDataTools.GetByte(d[p + 10]) / 255f;
                var ct    = (NetworkDataTools.GetByte(d[p + 11]) / 255f) * Cannon.SHIELDLASER_CHARGE_COOLDOWN_MAX;

                var frac = Screen.GetFractionByID(ifrac, out bool gfbiError);
                if (gfbiError)
                {
                    SAMLog.Error("SNS-COMMON::PFSP_GFBI", "GetFractionByID returned error: Unknown Fraction " + ifrac + "\nData:\n" + ByteUtils.CompressBytesForStorage(d));
                    return(false);
                }

                Cannon c;
                if (Screen.CannonMap.TryGetValue(id, out c))
                {
                    ShieldProjectorCannon sc = c as ShieldProjectorCannon;
                    if (sc != null && ShouldRecieveData(frac, sc))
                    {
                        if (ShouldRecieveRotationData(frac, sc))
                        {
                            sc.RemoteRotationUpdate(rotA, rotT, sendertime);
                        }

                        if (ShouldRecieveStateData(frac, sc))
                        {
                            sc.RemoteUpdate(frac, hp, boost, ct, sendertime);
                        }
                    }
                }

                p += PLEN_SHIELDPROJECTOR;
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void ProcessForwardShieldProjectors(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.GetSingle(d[p + 2], d[p + 3], d[p + 4], d[p + 5]);
                var rotT  = NetworkDataTools.GetSingle(d[p + 6], d[p + 7], d[p + 8], d[p + 9]);
                var hp    = NetworkDataTools.GetByte(d[p + 10]) / 255f;
                var ct    = (NetworkDataTools.GetByte(d[p + 11]) / 255f) * Cannon.SHIELDLASER_CHARGE_COOLDOWN_MAX;

                Cannon c;
                if (Screen.CannonMap.TryGetValue(id, out c))
                {
                    ShieldProjectorCannon sc = c as ShieldProjectorCannon;
                    if (sc != null && ShouldRecieveData(frac, sc))
                    {
                        if (ShouldRecieveRotationData(frac, sc))
                        {
                            sc.RemoteRotationUpdate(rotA, rotT, sendertime);
                        }

                        if (ShouldRecieveStateData(frac, sc))
                        {
                            sc.RemoteUpdate(frac, hp, boost, ct, sendertime);
                        }
                    }
                }

                p += PLEN_SHIELDPROJECTOR;
            }
        }
Ejemplo n.º 4
0
        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));
            }
        }