示例#1
0
        public Portal(GDGameScreen scrn, PortalBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_PORTAL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            Normal       = FloatMath.DegreesToRadians * blueprint.Normal;
            VecNormal    = Vector2.UnitX.Rotate(Normal);
            Length       = blueprint.Length;
            VecDirection = VecNormal.RotateWithLength(FloatMath.RAD_POS_090, blueprint.Length / 2f);
            Color        = COLORS[blueprint.Group];
            _group       = blueprint.Group;
            _side        = blueprint.Side;

            Position = pos;

            DrawingBoundingBox = new Vector2(Length, 0).Rotate(Normal + FloatMath.RAD_POS_090).ToAbsFSize().AtLeast(WIDTH, WIDTH);

            this.GDOwner().GDBackground.RegisterBlockedLine(pos - Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f), pos + Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f));

            _rectFull     = FRectangle.CreateByCenter(pos, Length, WIDTH);
            _rectHorizon  = FRectangle.CreateByCenter(pos + VecNormal.WithLength(WIDTH / 4f), Length, WIDTH / 2f);
            _rectGradient = FRectangle.CreateByCenter(pos + VecNormal.WithLength(WIDTH / 2f), Length, WIDTH);
            _rectDropTop  = FRectangle.CreateByCenter(pos - VecDirection.WithLength(Length / 2f), 24, 16);
            _rectDropMid  = FRectangle.CreateByCenter(pos, 24, Length - 16);
            _rectDropBot  = FRectangle.CreateByCenter(pos + VecDirection.WithLength(Length / 2f), 24, 16);
        }
示例#2
0
        public TutorialAgent(GDGameScreen scrn) : base(scrn)
        {
            _screen = scrn;

            _cannon1 = scrn.GetEntities <Cannon>().Single(c => c.BlueprintCannonID == 11);
            _cannon2 = scrn.GetEntities <Cannon>().Single(c => c.BlueprintCannonID == 12);
            _cannon3 = scrn.GetEntities <Cannon>().Single(c => c.BlueprintCannonID == 30);
            _cannon4 = scrn.GetEntities <Cannon>().Single(c => c.BlueprintCannonID == 22);
            _cannon5 = scrn.GetEntities <Cannon>().Single(c => c.BlueprintCannonID == 21);

            _controller5 = new TutorialController(_screen, _cannon5);
            _cannon5.ForceSetController(_controller5);

            _fracPlayer   = _cannon1.Fraction;
            _fracNeutral  = _cannon3.Fraction;
            _fracComputer = _cannon5.Fraction;

            _hud = (GDGameHUD)_screen.HUD;

            _screen.GameSpeedMode = GameSpeedModes.SLOW;

#if DEBUG
            _screen.DebugDisp.AddLine(() => $"Tutorial_State = ({(int)_state}) {_state}");
#endif
        }
		protected AbstractFractionController(float interval, GDGameScreen owner, Cannon cannon, Fraction fraction)
		{
			updateInterval = interval;
			Cannon = cannon;
			Fraction = fraction;
			Owner = owner;
		}
示例#4
0
        public LaserRenderer(GDGameScreen scrn, LaserNetwork nw, LevelBlueprint bp) : base(scrn, GDConstants.ORDER_GAME_LASER)
        {
            _network = nw;

            Position           = new FPoint(bp.LevelWidth / 2f, bp.LevelHeight / 2f);
            DrawingBoundingBox = new FSize(bp.LevelWidth, bp.LevelHeight);
        }
示例#5
0
 public TrishotCannon(GDGameScreen scrn, TrishotCannonBlueprint bp, Fraction[] fractions) :
     base(scrn, fractions, bp.Player, bp.X, bp.Y, bp.Diameter, bp.CannonID, bp.Rotation, bp.PrecalculatedPaths)
 {
     Blueprint = bp;
     _screen   = scrn;
     _muted    = scrn.IsPreview;
 }
示例#6
0
 public LaserKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
     : base(LASER_UPDATE_TIME, owner, cannon, fraction, MIN_LASER_ROT)
 {
     if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_RAYTRACE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreateRaycast("AttackingBullet,", FindTargetAttackingBullet),
             KIMethod.CreateCustom("KeepAttacking", KeepAttackingEnemyCannon),
             KIMethod.CreateCustom("KeepSupporting", KeepSupportingFriendlyCannon),
             KIMethod.CreateRaycast("SupportCannon", FindTargetSupportCannon),
             KIMethod.CreateRaycast("NeutralCannon", FindTargetNeutralCannon),
             KIMethod.CreateRaycast("EnemyCannon", FindTargetEnemyCannon),
             KIMethod.CreateRaycast("FriendlyCannon", FindTargetFriendlyCannon),
             KIMethod.CreateRaycast("BlockedEnemyCannon", FindTargetBlockedEnemyCannon),
             KIMethod.CreateRaycast("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannon),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRECALC)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreateRaycast("AttackingBullet,", FindTargetAttackingBullet),
             KIMethod.CreateCustom("KeepAttacking", KeepAttackingEnemyCannon),
             KIMethod.CreateCustom("KeepSupporting", KeepSupportingFriendlyCannon),
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRESIMULATE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreateRaycast("AttackingBullet,", FindTargetAttackingBullet),
             KIMethod.CreateCustom("KeepAttacking", KeepAttackingEnemyCannon),
             KIMethod.CreateCustom("KeepSupporting", KeepSupportingFriendlyCannon),
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else
     {
         throw new Exception("Unknown KIType: " + owner.Blueprint.KIType);
     }
 }
		public NeutralKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
			: base(NEUTRAL_UPDATE_TIME, owner, cannon, fraction)
		{
			intelligence = new List<Func<GameEntity>>
			{
				FindTargetAttackingBullet
			};
		}
示例#8
0
        public LaserNetwork(World b2dworld, GDGameScreen scrn, GameWrapMode wrap)
        {
            _screen = scrn;
            _world  = b2dworld;

            _rayLength = scrn.Blueprint.LevelWidth + scrn.Blueprint.LevelHeight;
            _wrapMode  = wrap;
        }
示例#9
0
 public NeutralKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
     : base(NEUTRAL_UPDATE_TIME, owner, cannon, fraction, 0f)
 {
     intelligence = new List <KIMethod>
     {
         KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
         KIMethod.CreateRaycast("AttackingBullet", FindTargetAttackingBullet),
     };
 }
示例#10
0
        public Bullet(GDGameScreen scrn, Cannon shooter, FPoint pos, Vector2 velo, float entityScale, Fraction frac) : base(scrn, frac, entityScale)
        {
            BulletPosition  = pos;
            initialVelocity = velo;
            Source          = shooter;
            GDOwner         = scrn;
            BulletID        = scrn.AssignBulletID(this);

            DrawingBoundingBox = new FSize(Scale * BULLET_DIAMETER, Scale * BULLET_DIAMETER);
        }
        public EndGameAutoComputerController(GDGameScreen owner, Cannon cannon, Fraction fraction)
            : base(STANDARD_UPDATE_TIME, owner, cannon, fraction, 0f)
        {
            intelligence = new List <KIMethod>
            {
                KIMethod.CreateCustom("RotCenter", RotCenter),
            };

            last = MonoSAMGame.CurrentTime.TotalElapsedSeconds;
        }
示例#12
0
        public GDCellularBackground(GDGameScreen scrn, LevelBlueprint lvl) : base(scrn)
        {
            tileCountX = FloatMath.Ceiling(lvl.LevelWidth / 64f) + 2 * MAX_EXTENSION_X;
            tileCountY = FloatMath.Ceiling(lvl.LevelHeight / 64f) + 2 * MAX_EXTENSION_Y;
            wrapMode   = scrn.WrapMode;

            _grid = new GridCellMembership[tileCountX, tileCountY];

            Initialize();
        }
示例#13
0
        public EndGameAutoPlayerController(GDGameScreen owner, Cannon cannon, Fraction fraction)
            : base(STANDARD_UPDATE_TIME, owner, cannon, fraction, 0f)
        {
            intelligence = new List <KIMethod>
            {
                KIMethod.CreateGeneric("IdleRotate", IdleRotate),
            };

            last = MonoSAMGame.CurrentTime.TotalElapsedSeconds;
        }
示例#14
0
        public ShieldProjectorCannon(GDGameScreen scrn, ShieldProjectorBlueprint bp, Fraction[] fractions) :
            base(scrn, fractions, bp.Player, bp.X, bp.Y, bp.Diameter, bp.CannonID, bp.Rotation, bp.PrecalculatedPaths)
        {
            Blueprint = bp;
            _screen   = scrn;
            _muted    = scrn.IsPreview;

            LaserSource = scrn.LaserNetwork.AddSource(this);

            _soundeffect          = MainGame.Inst.GDSound.GetEffectLaser(this);
            _soundeffect.IsLooped = true;
        }
示例#15
0
        public MirrorCircle(GDGameScreen scrn, MirrorCircleBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_WALL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            _diameter = blueprint.Diameter;

            Position = pos;

            DrawingBoundingBox = new FSize(_diameter + 2 * MARGIN_TEX, _diameter + 2 * MARGIN_TEX);

            this.GDOwner().GDBackground.RegisterBlockedCircle(new FCircle(pos, _diameter / 2f));
        }
示例#16
0
        public RemoteBullet(GDGameScreen scrn, FPoint pos, Vector2 velo, ushort id, float entityScale, Fraction frac, long seq)
            : base(scrn, frac, entityScale)
        {
            BulletPosition     = pos;
            LastRemotePosition = pos;
            BulletVelocity     = velo;
            GDOwner            = scrn;
            BulletID           = id;
            LastUpdateBigSeq   = seq;

            DrawingBoundingBox = new FSize(Scale * Bullet.BULLET_DIAMETER, Scale * Bullet.BULLET_DIAMETER);
        }
示例#17
0
        public VoidCircle(GDGameScreen scrn, VoidCircleBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_WALL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            _diameter   = blueprint.Diameter;
            _renderRect = FRectangle.CreateByCenter(pos, _diameter + 2 * MARGIN_TEX, _diameter + 2 * MARGIN_TEX);

            Position = pos;

            DrawingBoundingBox = _renderRect.Size;

            this.GDOwner().GDBackground.RegisterBlockedCircle(new FCircle(pos, _diameter / 2f));
        }
示例#18
0
 public RelayKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
     : base(RELAY_UPDATE_TIME, owner, cannon, fraction, 0f)
 {
     if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_RAYTRACE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateRaycast("SupportCannon", FindTargetSupportCannon),
             KIMethod.CreateRaycast("NeutralCannon", FindTargetNeutralCannon),
             KIMethod.CreateRaycast("EnemyCannon", FindTargetEnemyCannon),
             KIMethod.CreateRaycast("RelayChain", FindTargetRelayChain),
             KIMethod.CreateRaycast("FriendlyCannon", FindTargetFriendlyCannon),
             KIMethod.CreateRaycast("BlockedEnemyCannon", FindTargetBlockedEnemyCannon),
             KIMethod.CreateRaycast("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannon),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRECALC)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("RelayChain", FindTargetRelayChainPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRESIMULATE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("RelayChain", FindTargetRelayChainPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else
     {
         throw new Exception("Unknown KIType: " + owner.Blueprint.KIType);
     }
 }
示例#19
0
        public BlackHole(GDGameScreen scrn, BlackHoleBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_BLACKHOLE)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            _diameter = blueprint.Diameter;
            _radius   = _diameter / 2f;
            _power    = blueprint.Power;

            Position = pos;

            DrawingBoundingBox = new FSize(_diameter, _diameter);

            this.GDOwner().GDBackground.RegisterBlockedCircle(new FCircle(pos, _diameter / 2f));
        }
示例#20
0
		public Cannon(GDGameScreen scrn, LPCannon blueprint, Fraction[] fractions) : base(scrn)
		{
			Fraction = fractions[blueprint.Player];

			Center = new Vector2(blueprint.X, blueprint.Y);
			Scale = blueprint.Scale;
			DrawingBoundingBox = new FSize(CANNON_OUTER_DIAMETER, CANNON_OUTER_DIAMETER) * Scale;

			Rotation = new DeltaLimitedModuloFloat(FloatMath.ToRadians(blueprint.Rotation), ROTATION_SPEED, FloatMath.TAU);
			
			CannonHealth.SetForce(Fraction.IsNeutral ? 0f : 1f);

			FindParticleSpawns();
		}
示例#21
0
        public VoidWall(GDGameScreen scrn, VoidWallBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_WALL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            _rotation       = FloatMath.DegreesToRadians * blueprint.Rotation;
            _length         = blueprint.Length;
            _rectsUnrotated = CommonWallRenderer.CreateVoidWallRenderRects(pos, _length, _rotation);

            Position = pos;

            DrawingBoundingBox = new Vector2(_length, 0).Rotate(_rotation).ToAbsFSize().AtLeast(WIDTH, WIDTH);

            this.GDOwner().GDBackground.RegisterBlockedLine(pos - Vector2.UnitX.RotateWithLength(_rotation, _length / 2f), pos + Vector2.UnitX.RotateWithLength(_rotation, _length / 2f));
        }
		public StandardKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
			: base(STANDARD_UPDATE_TIME, owner, cannon, fraction)
		{
			intelligence = new List<Func<GameEntity>>
			{
				FindTargetAttackingBullet,
				FindTargetSupportCannon,
				FindTargetNeutralCannon,
				FindTargetEnemyCannon,
				FindTargetFriendlyCannon,
				FindTargetBlockedEnemyCannon,
				FindTargetBlockedFriendlyCannon,
				FindNearestEnemyCannon
			};
		}
        protected AbstractFractionController(float interval, GDGameScreen owner, Cannon cannon, Fraction fraction, bool singleUpdatePerCycle)
        {
            updateInterval   = interval;
            onlySingleUpdate = singleUpdatePerCycle;
            Cannon           = cannon;
            Fraction         = fraction;
            Owner            = owner;

            if (fraction.IsPlayer)
            {
                timeSinceLastUpdate = 0f;
            }

            innerBoundings = new FCircle(Cannon.Position, Cannon.Scale * Cannon.CANNON_OUTER_DIAMETER / 2);
        }
示例#24
0
        public LaserCannon(GDGameScreen scrn, LaserCannonBlueprint bp, Fraction[] fractions) :
            base(scrn, fractions, bp.Player, bp.X, bp.Y, bp.Diameter, bp.CannonID, bp.Rotation, bp.PrecalculatedPaths)
        {
            Blueprint = bp;
            _screen   = scrn;
            _muted    = scrn.IsPreview;

            LaserSource = scrn.LaserNetwork.AddSource(this);

            coreImage    = FloatMath.GetRangedIntRandom(0, Textures.CANNONCORE_COUNT);
            coreRotation = FloatMath.GetRangedRandom(FloatMath.RAD_POS_000, FloatMath.RAD_POS_360);

            _soundeffect          = MainGame.Inst.GDSound.GetEffectLaser(this);
            _soundeffect.IsLooped = true;
        }
示例#25
0
        public MirrorBlock(GDGameScreen scrn, MirrorBlockBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_WALL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            _width    = blueprint.Width;
            _height   = blueprint.Height;
            _rotation = FloatMath.ToRadians(blueprint.Rotation);

            _bounds = new FRotatedRectangle(pos, _width, _height, _rotation);

            Position = pos;

            DrawingBoundingBox = _bounds.OuterSize;

            this.GDOwner().GDBackground.RegisterBlockedBlock(_bounds.WithNoRotation(), _rotation);
        }
示例#26
0
        public BackgroundText(GDGameScreen scrn, BackgroundTextBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_BACKGROUNDTEXT)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            Blueprint = blueprint;

            _rotation = FloatMath.ToRadians(blueprint.Rotation);
            _bounds   = new FRotatedRectangle(pos, blueprint.Width, blueprint.Height, _rotation);

            Position = pos;

            DrawingBoundingBox = _bounds.OuterSize;

            _text  = FontRenderHelper.MakeTextSafe(Textures.LevelBackgroundFont, L10N.T(blueprint.L10NText), '_');
            _scale = FontRenderHelper.GetFontScale(Textures.LevelBackgroundFont, _text, _bounds.Size);

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_SHAKE) == BackgroundTextBlueprint.CONFIG_SHAKE)
            {
                AddOperation(new ShakeTextOperation());
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_ONLYD1) == BackgroundTextBlueprint.CONFIG_ONLYD1)
            {
                if (scrn.Difficulty != FractionDifficulty.DIFF_0)
                {
                    Alive = false;
                }
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_ONLY_UNCLEARED) == BackgroundTextBlueprint.CONFIG_ONLY_UNCLEARED)
            {
                if (MainGame.Inst.Profile.GetLevelData(scrn.Blueprint).HasCompletedOrBetter(scrn.Difficulty))
                {
                    Alive = false;
                }
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_REDFLASH) == BackgroundTextBlueprint.CONFIG_REDFLASH)
            {
                AddOperation(new RedFlashTextOperation());
            }

            if (scrn.IsPreview)
            {
                Alive = false;
            }
        }
示例#27
0
        protected Cannon(GDGameScreen scrn, Fraction[] fractions, int player, float px, float py, float diam, byte cid, float rotdeg, BulletPathBlueprint[] paths) : base(scrn, GDConstants.ORDER_GAME_CANNON)
        {
            Fraction = fractions[player];
            GDOwner  = scrn;

            Position             = new FPoint(px, py);
            Scale                = diam / CANNON_DIAMETER;
            DrawingBoundingBox   = new FSize(CANNON_OUTER_DIAMETER, CANNON_OUTER_DIAMETER) * Scale;
            BlueprintCannonID    = cid;
            bulletPathBlueprints = paths;

            Rotation = new DeltaLimitedModuloFloat(FloatMath.ToRadians(rotdeg), ROTATION_SPEED, FloatMath.TAU);

            CannonHealth.SetForce(Fraction.IsNeutral ? 0f : 1f);

            FindParticleSpawns();
        }
示例#28
0
        public GDEntityManager(GDGameScreen scrn) : base(scrn)
        {
            PhysicsWorld = new World(Vector2.Zero);

#if DEBUG
            debugView = new DebugViewXNA(PhysicsWorld);
            debugView.LoadContent(GDOwner.Graphics.GraphicsDevice, GDOwner.Game.Content, Textures.DebugFont);
            debugView.AppendFlags(DebugViewFlags.Shape);
            debugView.AppendFlags(DebugViewFlags.DebugPanel);
            debugView.AppendFlags(DebugViewFlags.PerformanceGraph);
            debugView.AppendFlags(DebugViewFlags.ContactPoints);
            debugView.AppendFlags(DebugViewFlags.ContactNormals);
            debugView.AppendFlags(DebugViewFlags.Controllers);
            debugView.TextColor = Color.Black;
            debugView.Enabled   = false;
#endif
        }
示例#29
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            base.Update(gameTime, istate);

            if (Mode == ServerMode.CreatingNewGame)
            {
                Screen = null;
            }
            if (Mode == ServerMode.BeforeNewGame)
            {
                Screen = null;
            }

            if (ConnType == MultiplayerConnectionType.P2P)
            {
                var btm = (BluetoothNetworkMedium)_medium;

                if (btm.Events.Count > 0)
                {
                    var evt = btm.Events.Dequeue();

                    var param = FontRenderHelper.MakeTextSafe(Textures.HUDFontRegular, evt.Param, '?');

                    switch (evt.Type)
                    {
                    case BluetoothMediumEvent.BTEvent.TryConnection:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_TRY, param), 40, FlatColors.Silver, FlatColors.Foreground, 2f);
                        break;

                    case BluetoothMediumEvent.BTEvent.ConnectionFailed:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_FAIL, param), 40, FlatColors.Orange, FlatColors.Foreground, 2f);
                        break;

                    case BluetoothMediumEvent.BTEvent.ConnectionSucceeded:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_SUCC, param), 40, FlatColors.Emerald, FlatColors.Foreground, 2f);
                        break;

                    default:
                        SAMLog.Error("GDMPC::Update_Evt", "type = " + evt.Type);
                        break;
                    }
                }
            }
        }
示例#30
0
        public Portal(GDGameScreen scrn, PortalBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_PORTAL)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            Normal       = FloatMath.DegreesToRadians * blueprint.Normal;
            VecNormal    = Vector2.UnitX.Rotate(Normal);
            Length       = blueprint.Length;
            VecDirection = VecNormal.RotateWithLength(FloatMath.RAD_POS_090, blueprint.Length / 2f);
            Color        = COLORS[blueprint.Group];
            _group       = blueprint.Group;
            _side        = blueprint.Side;

            Position = pos;

            DrawingBoundingBox = new Vector2(Length, 0).Rotate(Normal + FloatMath.RAD_POS_090).ToAbsFSize().AtLeast(WIDTH, WIDTH);

            this.GDOwner().GDBackground.RegisterBlockedLine(pos - Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f), pos + Vector2.UnitX.RotateWithLength(Normal + FloatMath.RAD_POS_090, Length / 2f));

            _renderRects = CommonObstacleRenderer.CreatePortalRenderRects(pos, VecNormal, VecDirection, Length);
        }
示例#31
0
		public AbstractFractionController CreateController(GDGameScreen owner, Cannon cannon)
		{
			switch (Type)
			{
				case FractionType.PlayerFraction:
					if (owner.HasFinished)
						return new EndGameAutoPlayerController(owner, cannon, this);
					else
						return new PlayerController(owner, cannon, this);

				case FractionType.ComputerFraction:
					return new StandardKIController(owner, cannon, this);

				case FractionType.NeutralFraction:
					return new NeutralKIController(owner, cannon, this);

				default:
					throw new ArgumentOutOfRangeException();
			}
		}
 public ShieldProjectorKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
     : base(LASER_UPDATE_TIME, owner, cannon, fraction, MIN_LASER_ROT)
 {
     if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_RAYTRACE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreateRaycast("ShieldCannon", FindTargetShieldCannon),
             KIMethod.CreateRaycast("FriendlyCannon", FindTargetFriendlyCannon),
             KIMethod.CreateRaycast("SupportCannon", FindTargetSupportCannon),
             KIMethod.CreateRaycast("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRECALC)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreatePrecalc("ShieldCannon", FindTargetShieldCannonPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRESIMULATE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateDefense("AttackingLaser", FindTargetAttackingLaser),
             KIMethod.CreatePrecalc("ShieldCannon", FindTargetShieldCannonPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
         };
     }
     else
     {
         throw new Exception("Unknown KIType: " + owner.Blueprint.KIType);
     }
 }
示例#33
0
        public DonutParticleEmitter(GDGameScreen scrn, LevelBlueprint bp, FlatAlign4 a)
            : base(scrn, CreateConfig(bp, a), GDConstants.ORDER_GAME_PORTALPARTICLE)
        {
            Position = new FPoint(bp.LevelWidth / 2f, bp.LevelHeight / 2f);

            switch (a)
            {
            case FlatAlign4.TOP:
                _start     = new FPoint(0, 0);
                _direction = new Vector2(bp.LevelWidth, 0);
                _normal    = new Vector2(0, 1);
                break;

            case FlatAlign4.RIGHT:
                _start     = new FPoint(bp.LevelWidth, 0);
                _direction = new Vector2(0, bp.LevelHeight);
                _normal    = new Vector2(-1, 0);
                break;

            case FlatAlign4.BOTTOM:
                _start     = new FPoint(bp.LevelWidth, bp.LevelHeight);
                _direction = new Vector2(-bp.LevelWidth, 0);
                _normal    = new Vector2(0, -1);
                break;

            case FlatAlign4.LEFT:
                _start     = new FPoint(0, bp.LevelHeight);
                _direction = new Vector2(0, -bp.LevelHeight);
                _normal    = new Vector2(1, 0);
                break;

            default:
                SAMLog.Error("PPE::EnumSwitch_DPE", "value = " + a);
                break;
            }

            DrawingBoundingBox = new FSize(bp.LevelWidth, bp.LevelHeight);
        }
示例#34
0
 public override KIController CreateKIController(GDGameScreen screen, Fraction fraction)
 {
     return(new BulletKIController(screen, this, fraction));
 }
示例#35
0
		public EmptyController(GDGameScreen owner, Cannon cannon, Fraction fraction) 
			: base(0, owner, cannon, fraction)
		{
		}
示例#36
0
		public PlayerController(GDGameScreen owner, Cannon cannon, Fraction fraction) 
			: base(0f, owner, cannon, fraction)
		{
			innerBoundings = new CircleF(Cannon.Center, Cannon.Scale * Cannon.CANNON_OUTER_DIAMETER / 2);
		}
示例#37
0
		protected KIController(float interval, GDGameScreen owner, Cannon cannon, Fraction fraction) 
			: base(interval, owner, cannon, fraction)
		{
			crng = new ConstantRandom(cannon);
		}
示例#38
0
 protected BaseBullet(GDGameScreen scrn, Fraction f, float s) : base(scrn, GDConstants.ORDER_GAME_BULLETS)
 {
     Fraction = f;
     Scale    = s;
 }
示例#39
0
		public GDGameHUD(GDGameScreen scrn) : base(scrn, Textures.HUDFontRegular)
		{
			AddElement(btnPause = new HUDPauseButton());
			AddElement(btnSpeed = new HUDSpeedBaseButton());
		}