예제 #1
0
        protected override void OnClick(GameEntityMouseArea area, SAMTime gameTime, InputState istate)
        {
#if DEBUG
            if (DebugSettings.Get("UnlockNode"))
            {
                OnClickUnlocked(); return;
            }

            if (DebugSettings.Get("WorldPreview"))
            {
                MainGame.Inst.Profile.PurchasedWorlds.Clear(); ShowPreview(); return;
            }
#endif

            _ustate = UnlockManager.IsUnlocked(Blueprint, true);

            if (_ustate == WorldUnlockState.Unlocked)
            {
                OnClickUnlocked();
            }
            else if (_ustate == WorldUnlockState.NeedsAction)
            {
                OnClickNeedsAction();
            }
            else if (_ustate == WorldUnlockState.FullyLocked)
            {
                OnClickFullyLocked();
            }
        }
예제 #2
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            root.IsVisible = !DebugSettings.Get("HideHUD");
#endif

            var x = _cornerElements.Max(e => e.RelativeRight);
            var y = _cornerElements.Max(e => e.RelativeBottom);
            _backgroundRect.Size = new FSize(x + 4f, y + 4f);

            if (GDOwner.LevelTime / GDOwner.GameSpeed < COUNTDOWN_TIME * (1 / 3f))
            {
                _countdown.Image    = Textures.TexTitleNumber[3];
                GDOwner.IsCountdown = true;
            }
            else if (GDOwner.LevelTime / GDOwner.GameSpeed < COUNTDOWN_TIME * (2 / 3f))
            {
                _countdown.Image    = Textures.TexTitleNumber[2];
                GDOwner.IsCountdown = true;
            }
            else if (GDOwner.LevelTime / GDOwner.GameSpeed < COUNTDOWN_TIME * (3 / 3f))
            {
                _countdown.Image    = Textures.TexTitleNumber[1];
                GDOwner.IsCountdown = true;
            }
            else
            {
                _countdown.IsVisible = false;
                GDOwner.IsCountdown  = false;
            }
        }
예제 #3
0
        private void OnClick(GameEntityMouseArea sender, SAMTime gameTime, InputState istate)
        {
            if (GDOwner.ZoomState != BistateProgress.Normal && GDOwner.ZoomState != BistateProgress.Expanded)
            {
                return;
            }

#if DEBUG
            if (!NodeEnabled && DebugSettings.Get("UnlockNode"))
            {
                NodeEnabled = true;
            }
#endif
            if (!NodeEnabled)
            {
                MainGame.Inst.GDSound.PlayEffectError();

                if (GDOwner.ZoomState == BistateProgress.Expanded)
                {
                    AddEntityOperation(new ScreenShakeOperation2(this, GDOwner));
                }
                else
                {
                    AddEntityOperation(new ScreenShakeAndCenterOperation2(this, GDOwner));
                }

                Owner.HUD.ShowToast("WN::LOCKED", L10N.T(L10NImpl.STR_GLOB_WORLDLOCK), 40, FlatColors.Pomegranate, FlatColors.Foreground, 1.5f);

                return;
            }

            Owner.AddAgent(new LeaveTransitionGameEndAgent(GDOwner, GDOwner.ZoomState == BistateProgress.Expanded, this));
            MainGame.Inst.GDSound.PlayEffectZoomOut();
        }
예제 #4
0
        public override void TakeDamage(Fraction source, float sourceScale)
        {
#if DEBUG
            if (DebugSettings.Get("ImmortalCannons"))
            {
                return;
            }
#endif

            if (Fraction.IsNeutral && !source.IsNeutral)
            {
                CannonHealth.Set(1);
                SetFraction(source);
            }
            else if (!Fraction.IsNeutral && source != Fraction)
            {
                if (counterAttackingLasersFriends > 0)
                {
                    // ignore
                }
                else
                {
                    CannonHealth.Set(0);
                    SetFraction(Fraction.GetNeutral());
                }
            }
        }
예제 #5
0
        private void DrawScreenDebug(IBatchRenderer sbatch)
        {
            if (DebugSettings.Get("DebugBackground"))
            {
                DebugRenderHelper.DrawCrossedCircle(sbatch, Color.Red, MapViewportCenter, 8, 2);
                DebugRenderHelper.DrawHalfCrossedCircle(sbatch, Color.Red, MapOffset.Negate(), 8, 2);

                var rTop = new FRectangle(CompleteMapViewport.X, CompleteMapViewport.Y, CompleteMapViewport.Width, GuaranteedMapViewport.Y - CompleteMapViewport.Y);
                var rBot = new FRectangle(CompleteMapViewport.X, GuaranteedMapViewport.Bottom, CompleteMapViewport.Width, CompleteMapViewport.Bottom - GuaranteedMapViewport.Bottom);
                var rLef = new FRectangle(CompleteMapViewport.X, CompleteMapViewport.Y, GuaranteedMapViewport.X - CompleteMapViewport.X, CompleteMapViewport.Height);
                var rRig = new FRectangle(GuaranteedMapViewport.Right, CompleteMapViewport.Y, CompleteMapViewport.Right - GuaranteedMapViewport.Right, CompleteMapViewport.Height);

                if (rTop.Area > 0.001f)
                {
                    sbatch.FillRectangle(rTop, Color.DarkRed * 0.35f);
                }
                if (rBot.Area > 0.001f)
                {
                    sbatch.FillRectangle(rBot, Color.DarkRed * 0.35f);
                }
                if (rLef.Area > 0.001f)
                {
                    sbatch.FillRectangle(rLef, Color.DarkRed * 0.35f);
                }
                if (rRig.Area > 0.001f)
                {
                    sbatch.FillRectangle(rRig, Color.DarkRed * 0.35f);
                }

                sbatch.DrawRectangle(GuaranteedMapViewport, Color.Red * 0.8f, 1f);
            }
        }
예제 #6
0
        private TReturn Query <TReturn>(string apiEndPoint, RestParameterSet parameter, int maxTries)
        {
            var para = parameter.CreateParamString(secret);


            string url = serverbasepath + "/" + apiEndPoint + ".php" + para.Item1;

#if DEBUG
            if (DebugSettings.Get("DebugNetwork"))
            {
                SAMLog.Debug($"QueryAsync('{apiEndPoint}', '{url}', {maxTries})");
            }
#endif

            for (;;)
            {
                try
                {
                    HttpResponseMessage response;
                    if (para.Item2 != null)
                    {
                        response = http.PostAsync(url, para.Item2).Result;
                    }
                    else
                    {
                        response = http.GetAsync(url).Result;
                    }

                    response.EnsureSuccessStatusCode();
                    var content = response.Content.ReadAsStringAsync().Result;
#if DEBUG
                    if (DebugSettings.Get("DebugNetwork"))
                    {
                        var json   = CompactJsonFormatter.CompressJson(content, 1);
                        var jlines = json.Replace("\r\n", "\n").Split('\n');
                        if (jlines.Length > 7)
                        {
                            json = string.Join("\n", jlines.Take(3).Concat(new[] { "..." }).Concat(jlines.Reverse().Take(3).Reverse()));
                        }
                        SAMLog.Debug($"Query '{apiEndPoint}' returned \r\n" + json);
                    }
#endif
                    return(JsonConvert.DeserializeObject <TReturn>(content));
                }
                catch (Exception e)
                {
                    if (maxTries > 0)
                    {
                        maxTries--;
                        SAMLog.Info("QueryAsync", $"Retry query '{url}'. {maxTries}remaining", e.Message);
                        MonoSAMGame.CurrentInst.Bridge.Sleep(RETRY_SLEEP_TIME);
                        continue;
                    }
                    else
                    {
                        throw new RestConnectionException(e);                         // return to sender
                    }
                }
            }
        }
예제 #7
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;

            //if (MonoSAMGame.IsDesktop())
            //{
            //	if (istate.IsKeyExclusiveJustDown(SKeys.R))
            //	{
            //		var xcfg = XConfigFile.LoadFromString(System.IO.File.ReadAllText(@"F:\Symlinks\GridDominance\Data\presets\green_gas.xconf"));
            //		var pcfg = ParticleEmitterConfig.ParticleEmitterConfigBuilder.LoadFromXConfig(xcfg);
            //		_banner.CreateEntities(pcfg);
            //	}
            //}
#endif

            if (!MainGame.IsShaderless())
            {
                if (_effectsEnabledCache != MainGame.Inst.Profile.EffectsEnabled)
                {
                    _effectsEnabledCache = MainGame.Inst.Profile.EffectsEnabled;

                    if (MainGame.Inst.Profile.EffectsEnabled)
                    {
                        _banner.CreateEntities(ParticlePresets.GetConfigLetterGreenGas());
                    }
                    else
                    {
                        _banner.RemoveEntities();
                    }
                }
            }
        }
예제 #8
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;
#endif

            if (ZoomState == BistateProgress.Expanded && istate.IsRealJustDown && PreventZoomInCtr != MonoSAMGame.GameCycleCounter && istate.SwallowConsumer != InputConsumer.HUDElement)
            {
                var zoompos = istate.GamePointerPositionOnMap;


                foreach (var n in GetEntities <LevelNode>())
                {
                    if (n.NodeEnabled && n.StateSum == BistateProgress.Closed && n.CenterContains(istate.GamePointerPositionOnMap))
                    {
                        n.OpenNode();
                        zoompos = n.Position;
                        break;
                    }
                }

                ZoomIn(zoompos);
            }

            if (ZoomState == BistateProgress.Normal && istate.IsGesturePinchComplete && istate.LastPinchPower < -10)
            {
                ZoomOut();
            }

            if (ZoomState == BistateProgress.Expanded && istate.IsGesturePinchComplete && istate.LastPinchPower > +10)
            {
                ZoomIn(istate.GamePointerPositionOnMap);
            }

            bool trigger = false;
            if (istate.IsKeyExclusiveJustDown(SKeys.AndroidBack))
            {
                istate.SwallowKey(SKeys.AndroidBack, InputConsumer.ScreenAgent);
                trigger = true;
            }
            else if (istate.IsKeyExclusiveJustDown(SKeys.Backspace))
            {
                istate.SwallowKey(SKeys.Backspace, InputConsumer.ScreenAgent);
                trigger = true;
            }

            if (trigger)
            {
                MainGame.Inst.SetOverworldScreen();
            }

#if DEBUG
            if (DebugSettings.Get("LeaveScreen"))
            {
                MainGame.Inst.SetOverworldScreen();
            }
#endif
        }
예제 #9
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            ScoreDispMan.Update();

#if DEBUG
            root.IsVisible = !DebugSettings.Get("HideHUD");
#endif
        }
예제 #10
0
        public void Update(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            if (DebugSettings.Get("ContinoousLasers"))
            {
                Dirty = true;
            }
#endif


#if DEBUG
            DebugUtils.TIMING_LASER.Start();
#endif
            if (SemiDirty && !Dirty)
            {
                TestSemiDirty();
                SemiDirty = false;
            }

            if (Dirty)
            {
                foreach (LaserSource src in Sources)
                {
                    src.Lasers.Clear();
                }
                foreach (LaserSource src in Sources)
                {
                    RecalcSource(src);
                }
            }

            for (int i = 0; i < MAX_BACKTRACE; i++)
            {
                if (_faultRays.Any())
                {
                    var r = _faultRays.ToList();
                    _faultRays.Clear();
                    foreach (var tup in r)
                    {
                        var src = tup.Item2;
                        var ray = tup.Item1;

                        if (src.Lasers.Contains(ray))
                        {
                            src.Lasers.Remove(ray);
                            RecalcFromRay(src, ray.Start, ray.Start + (ray.End - ray.Start).WithLength(_rayLength), ray.Depth, ray.InGlass, ray.StartIgnoreObj, ray.Source, ray.SourceDistance, i + 1 >= MAX_BACKTRACE);
                        }
                    }
                }
            }

            Dirty     = false;
            SemiDirty = false;
#if DEBUG
            DebugUtils.TIMING_LASER.Stop();
#endif
        }
예제 #11
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;
#endif

            //
        }
예제 #12
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            controller.Update(gameTime, istate);

            bool change = Rotation.CUpdate(gameTime);

            if (change)
            {
                _screen.LaserNetwork.SemiDirty = true; ChargeTime = 0;
            }

            CrosshairSize.Update(gameTime);

            UpdatePhysicBodies();
            UpdateHealth(gameTime);
            UpdateBoost(gameTime);
            UpdateNetwork(gameTime);
            UpdateCore(gameTime);
            UpdateDamage(gameTime);
            UpdateShield(gameTime);

#if DEBUG
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("AssimilateCannon"))
            {
                var bckp = DebugSettings.Get("ImmortalCannons");
                DebugSettings.SetManual("ImmortalCannons", false);

                while (Fraction.Type != FractionType.PlayerFraction)
                {
                    TakeDamage(this.GDOwner().GetPlayerFraction(), 1);
                }

                DebugSettings.SetManual("ImmortalCannons", bckp);

                CannonHealth.SetForce(1f);
            }
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("LooseCannon"))
            {
                var bckp = DebugSettings.Get("ImmortalCannons");
                DebugSettings.SetManual("ImmortalCannons", false);

                while (Fraction.Type != FractionType.ComputerFraction)
                {
                    TakeDamage(this.GDOwner().GetComputerFraction(), 1);
                }

                DebugSettings.SetManual("ImmortalCannons", bckp);

                CannonHealth.SetForce(1f);
            }
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("AbandonCannon"))
            {
                CannonHealth.SetForce(0f);
                SetFraction(Fraction.GetNeutral());
            }
#endif
        }
예제 #13
0
        public virtual void TakeLaserDamage(Fraction source, LaserRay ray, float dmg)
        {
#if DEBUG
            if (DebugSettings.Get("ImmortalCannons"))
            {
                _attackingRaysCollector.Add(ray); return;
            }
#endif

            if (source.IsNeutral)
            {
                if (dmg > 0f)
                {
                    ResetChargeAndBooster();
                }
            }
            else if (Fraction.IsNeutral)
            {
                if (dmg > 0f)
                {
                    counterAttackingLasersFriends++;

                    _attackingRaysCollector.Add(ray);

                    SetFraction(source);
                    CannonHealth.Set(dmg / Scale);
                    CannonHealth.Limit(0f, 1f);
                }
            }
            else
            {
                if (dmg > 0)
                {
                    counterAttackingLasersEnemy++;
                }

                _attackingRaysCollector.Add(ray);

                CannonHealth.Dec(dmg / Scale);

                if (FloatMath.IsZero(CannonHealth.TargetValue))
                {
                    // Never tell me the odds

                    SetFraction(Fraction.GetNeutral());
                }
                else if (CannonHealth.TargetValue < 0)
                {
                    SetFraction(source);
                    CannonHealth.Set(FloatMath.Abs(CannonHealth.TargetValue));
                }

                CannonHealth.Limit(0f, 1f);
            }
        }
예제 #14
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            DrawNetwork(sbatch);

#if DEBUG
            if (DebugSettings.Get("DebugLaserNetwork"))
            {
                DrawNetworkDebug(sbatch);
            }
#endif
        }
예제 #15
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            CommonObstacleRenderer.DrawPortal(sbatch, _renderRects, Color, Normal);

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                sbatch.FillCircle(Position, 4, 16, Color.Turquoise);
                sbatch.DrawLine(Position, Position + Vector2.UnitX.RotateWithLength(Normal, 32), Color.Turquoise, 2);
            }
#endif
        }
예제 #16
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;
#endif
            if (!IsPaused && !HasFinished)
            {
                LevelTime += gameTime.RealtimeElapsedSeconds;
            }

            TestForGameEndingCondition();
        }
예제 #17
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            CommonWallRenderer.DrawVoidWall_BG(sbatch, _length, _rotation, _rectsUnrotated);

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                foreach (var r in _rectsUnrotated)
                {
                    sbatch.DrawRectangleRot(r, Color.Cyan, _rotation);
                }
            }
#endif
        }
예제 #18
0
        private void OpenNode()
        {
            AbortAllOperations(p => p.Name == "LevelNode::Center");
            AbortAllOperations(p => p.Name == "LevelNode::CenterShake");

#if DEBUG
            if (!NodeEnabled && DebugSettings.Get("UnlockNode"))
            {
                NodeEnabled = true;
            }
#endif
            if (!NodeEnabled)
            {
                MainGame.Inst.GDSound.PlayEffectError();

                AddEntityOperation(new ScreenShakeAndCenterOperation(this, GDOwner));

                Owner.HUD.ShowToast("LN::LOCKED", L10N.T(L10NImpl.STR_GLOB_LEVELLOCK), 40, FlatColors.Pomegranate, FlatColors.Foreground, 1.5f);

                return;
            }

            ((GDWorldHUD)Owner.HUD).SelectNode(this);

            var progress = FindFirstOperationProgress(p => p.Name == "LevelNode::Close::root");
            AbortAllOperations(p => p.Name == "LevelNode::Close::root");
            var o = AddEntityOperation(new SimpleGameEntityOperation <LevelNode>("LevelNode::Open::root", TOTAL_EXPANSION_TIME, (n, p) => RootExpansionProgress = p));
            if (progress != null)
            {
                o.ForceSetProgress(1 - progress.Value);
            }

            if (Blueprint.UniqueID == Levels.LEVELID_1_1 && !LevelData.HasCompletedOrBetter(FractionDifficulty.DIFF_0))
            {
                OpenExtender(FractionDifficulty.DIFF_0);
            }
            else
            {
                OpenExtender(FractionDifficulty.DIFF_0);
                OpenExtender(FractionDifficulty.DIFF_1);
                OpenExtender(FractionDifficulty.DIFF_2);
                OpenExtender(FractionDifficulty.DIFF_3);
            }


            AddEntityOperation(new CenterNodeOperation(GDOwner));

            MainGame.Inst.GDSound.PlayEffectOpen();
        }
예제 #19
0
        public void Draw(IBatchRenderer sbatch)
        {
            OnDraw(sbatch);

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                using (sbatch.BeginDebugDraw()) DrawDebugBorders(sbatch);
            }
            if (DebugSettings.Get("DebugEntityMouseAreas"))
            {
                using (sbatch.BeginDebugDraw()) DrawDebugAreas(sbatch);
            }
#endif
        }
예제 #20
0
        protected override void OnDrawGame(IBatchRenderer sbatch)
        {
            if (!MainGame.Inst.Profile.EffectsEnabled)
            {
                var hh = 4.5f * GDConstants.TILE_WIDTH;
                sbatch.DrawCentered(Textures.TexLogo, _banner.TargetRect.Center, hh * Textures.TexLogo.Width / Textures.TexLogo.Height, hh, Color.White);
            }

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                sbatch.DrawRectangle(_banner.TargetRect, Color.DodgerBlue, 3f);
            }
#endif
        }
예제 #21
0
        protected override void OnDrawGame(IBatchRenderer sbatch)
        {
#if DEBUG
            if (DebugSettings.Get("DebugBackground"))
            {
                sbatch.DrawRectangle(Graph.BoundingRect, Color.OrangeRed, 3f);
                sbatch.DrawRectangle(Graph.BoundingViewport, Color.Purple, 3f);
            }
#endif

            if (ColorOverdraw > 0)
            {
                sbatch.FillRectangle(CompleteMapViewport, FlatColors.Background * ColorOverdraw);
            }
        }
예제 #22
0
        protected override void OnBeforeUpdate(SAMTime gameTime, InputState state)
        {
#if DEBUG
            debugView.DebugPanelPosition     = new Vector2(55, Owner.VAdapterGame.RealTotalHeight - 180);
            debugView.PerformancePanelBounds = new Rectangle(450, (int)(Owner.VAdapterGame.RealTotalHeight - 180), 200, 100);

            debugView.Enabled = DebugSettings.Get("PhysicsDebugView");
#endif
#if DEBUG
            DebugUtils.TIMING_PHYSICS.Start();
            PhysicsWorld.Step(gameTime.ElapsedSeconds);
            DebugUtils.TIMING_PHYSICS.Stop();
#else
            PhysicsWorld.Step(gameTime.ElapsedSeconds);
#endif
        }
예제 #23
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;
#endif

            //

#if DEBUG
            if (DebugSettings.Get("LeaveScreen"))
            {
                MainGame.Inst.SetOverworldScreen();
            }
#endif
        }
예제 #24
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            sbatch.DrawCentered(
                Textures.TexBullet,
                BulletPosition,
                Scale * BulletExtraScale * BULLET_DIAMETER,
                Scale * BulletExtraScale * BULLET_DIAMETER,
                Fraction.Color * BulletAlpha, BulletRotation);

#if DEBUG
            if (DebugSettings.Get("DebugMultiplayer"))
            {
                sbatch.DrawCircle(LastRemotePosition, Scale * BulletExtraScale * BULLET_DIAMETER / 2f, 6, ClientPredictionMiss ? Color.Crimson : Color.DeepSkyBlue, 2 * Owner.PixelWidth);
                sbatch.DrawLine(LastRemotePosition, BulletPosition, Color.DeepSkyBlue, Owner.PixelWidth);
            }
#endif
        }
예제 #25
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            sbatch.DrawStretched(Textures.TexPortalDropEnd1, _rectDropTop, Color.White, Normal);
            sbatch.DrawStretched(Textures.TexPortalDropMid, _rectDropMid, Color.White, Normal);
            sbatch.DrawStretched(Textures.TexPortalDropEnd2, _rectDropBot, Color.White, Normal);

            sbatch.DrawStretched(Textures.TexGradient, _rectGradient, Color, Normal - FloatMath.RAD_POS_090);
            sbatch.DrawStretched(Textures.TexPixel, _rectFull, FlatColors.Clouds, Normal - FloatMath.RAD_POS_090);
            sbatch.DrawStretched(Textures.TexPixel, _rectHorizon, Color, Normal - FloatMath.RAD_POS_090);

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                sbatch.FillCircle(Position, 4, 16, Color.Turquoise);
                sbatch.DrawLine(Position, Position + Vector2.UnitX.RotateWithLength(Normal, 32), Color.Turquoise, 2);
            }
#endif
        }
예제 #26
0
        public override AbstractFractionController CreateController(Fraction f, Cannon cannon)
        {
            if (HasFinished)
            {
                if (PlayerWon)
                {
                    return(new EndGameAutoPlayerController(this, cannon, f));
                }
                else
                {
                    return(new EndGameAutoComputerController(this, cannon, f));
                }
            }

            switch (f.Type)
            {
            case FractionType.PlayerFraction:
                return(new PlayerController(this, cannon, f));

            case FractionType.ComputerFraction:
#if DEBUG
                if (DebugSettings.Get("ControlEnemies"))
                {
                    return(new PlayerController(this, cannon, f));
                }
#endif
                return(cannon.CreateKIController(this, f));

            case FractionType.NeutralFraction:
#if DEBUG
                if (DebugSettings.Get("ControlEnemies"))
                {
                    return(new PlayerController(this, cannon, f));
                }
#endif
                return(cannon.CreateNeutralController(this, f));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #27
0
        protected override void OnClick(GameEntityMouseArea area, SAMTime gameTime, InputState istate)
        {
#if DEBUG
            if (DebugSettings.Get("UnlockNode"))
            {
                OnClick_OpenAndUnlocked(); return;
            }

            if (DebugSettings.Get("WorldPreview"))
            {
                MainGame.Inst.Profile.PurchasedWorlds.Clear(); ShowPreview(); return;
            }
#endif

            _ustate = UnlockManager.IsUnlocked(Blueprint, true);

            //MainGame.Inst.GDBridge.IAB.SynchronizePurchases(GDConstants.IABList);

            switch (_ustate)
            {
            case WorldUnlockState.OpenAndUnlocked:
                OnClick_OpenAndUnlocked();
                break;

            case WorldUnlockState.ReachableButMustBePreviewed:
                OnClick_ReachableButMustBeBought();
                break;

            case WorldUnlockState.UnreachableButCanBePreviewed:
                OnClick_UnreachableButCanBeBought();
                break;

            case WorldUnlockState.UnreachableAndFullyLocked:
                OnClick_UnreachableAndFullyLocked();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #28
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            _lifetime += gameTime.ElapsedSeconds;

#if DEBUG
            DebugDisp.IsEnabled = DebugSettings.Get("DebugTextDisplay");
            DebugDisp.Scale     = 0.75f;
#endif

#if (DEBUG && __DESKTOP__)
            if (istate.IsKeyExclusiveJustDown(SKeys.R))
            {
                _banner1.AnimationStartDelay = 0;
                _banner2.AnimationStartDelay = 0;

                var xcfg = XConfigFile.LoadFromString(System.IO.File.ReadAllText(@"F:\Symlinks\GridDominance\Data\presets\auto.xconf"));
                var pcfg = ParticleEmitterConfig.ParticleEmitterConfigBuilder.LoadFromXConfig(xcfg);
                _banner1.CreateEntities(pcfg);
                _banner2.CreateEntities(pcfg);
            }
#endif

            bool trigger = false;
            if (istate.IsKeyExclusiveJustDown(SKeys.AndroidBack))
            {
                istate.SwallowKey(SKeys.AndroidBack, InputConsumer.ScreenAgent);
                trigger = true;
            }
            else if (istate.IsKeyExclusiveJustDown(SKeys.Backspace))
            {
                istate.SwallowKey(SKeys.Backspace, InputConsumer.ScreenAgent);
                trigger = true;
            }

            if (trigger)
            {
                LeaveScreen();
            }
        }
예제 #29
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            if (_renderPartCount <= 1)
            {
                sbatch.DrawStretched(Textures.TexVoidWall_BG_L1, _rectsUnrotated[0], Color.White, _rotation);
            }
            else if (_renderPartCount == 2)
            {
                sbatch.DrawStretched(Textures.TexVoidWall_BG_L2, _rectsUnrotated[0], Color.White, _rotation);
            }
            else
            {
                for (int i = 0; i < _renderPartCount; i++)
                {
                    if (i == 0)
                    {
                        sbatch.DrawStretched(Textures.TexVoidWall_BG_End, _rectsUnrotated[i], Color.White, _rotation + FloatMath.RAD_POS_180);
                    }
                    else if (i + 1 < _renderPartCount)
                    {
                        sbatch.DrawStretched(Textures.TexVoidWall_BG_Middle, _rectsUnrotated[i], Color.White, _rotation);
                    }
                    else
                    {
                        sbatch.DrawStretched(Textures.TexVoidWall_BG_End, _rectsUnrotated[i], Color.White, _rotation);
                    }
                }
            }

#if DEBUG
            if (DebugSettings.Get("DebugEntityBoundaries"))
            {
                foreach (var r in _rectsUnrotated)
                {
                    sbatch.DrawRectangleRot(r, Color.Cyan, _rotation);
                }
            }
#endif
        }
예제 #30
0
        public virtual void TakeDamage(Fraction source, float sourceScale)
        {
#if DEBUG
            if (DebugSettings.Get("ImmortalCannons"))
            {
                return;
            }
#endif

            if (source.IsNeutral)
            {
                ResetChargeAndBooster();
            }
            else if (Fraction.IsNeutral)
            {
                SetFraction(source);
                CannonHealth.Set((sourceScale * HEALTH_HIT_GEN) / Scale);
                CannonHealth.Limit(0f, 1f);
            }
            else
            {
                CannonHealth.Dec((sourceScale * HEALTH_HIT_DROP) / Scale);

                if (FloatMath.IsZero(CannonHealth.TargetValue))
                {
                    // Never tell me the odds

                    SetFraction(Fraction.GetNeutral());
                }
                else if (CannonHealth.TargetValue < 0)
                {
                    SetFraction(source);
                    CannonHealth.Set(FloatMath.Abs(CannonHealth.TargetValue));
                }

                CannonHealth.Limit(0f, 1f);
            }
        }