Ejemplo n.º 1
0
        protected void UpdateBoost(SAMTime gameTime)
        {
            for (int i = _laserBoosts.Count - 1; i >= 0; i--)
            {
                if ((_laserBoosts[i].RemainingTime -= gameTime.ElapsedSeconds) < 0)
                {
                    _laserBoosts.RemoveAt(i);
                }
            }

            AttackingRays.Clear();
            if (_attackingRaysCollector.Count > 0)
            {
                AttackingRays.AddRange(_attackingRaysCollector);
                _attackingRaysCollector.Clear();
            }
        }
Ejemplo n.º 2
0
        public bool Update(TEntity entity, SAMTime gameTime, InputState istate)
        {
            if (_selfdestruct)
            {
                return(false);
            }

            time += gameTime.ElapsedSeconds;

            if (length.HasValue && time >= length)
            {
                return(false);
            }

            OnProgress(entity, Progress, gameTime, istate);
            return(true);
        }
Ejemplo n.º 3
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            _gdScreen.IsDragging = _isDragging;

            if (_gdScreen.ZoomState != BistateProgress.Normal)
            {
                if (_isDragging)
                {
                    EndDrag(gameTime, istate);
                }
                _restDragSpeed = Vector2.Zero;
                return;
            }

            if (_isDragging)
            {
                if (istate.IsRealDown)
                {
                    UpdateDrag(gameTime, istate);

                    _gdScreen.IsBackgroundPressed = true;
                }
                else
                {
                    EndDrag(gameTime, istate);

                    _gdScreen.IsBackgroundPressed = false;
                }
            }
            else
            {
                if (istate.IsExclusiveJustDown)
                {
                    istate.Swallow(InputConsumer.GameBackground);
                    StartDrag(istate);

                    _gdScreen.IsBackgroundPressed = true;
                }
                else if (!_restDragSpeed.IsZero() || !_outOfBoundsForce.IsZero())
                {
                    UpdateRestDrag(gameTime);

                    _gdScreen.IsBackgroundPressed = false;
                }
            }
        }
Ejemplo n.º 4
0
        public void Update(SAMTime gameTime, InputState istate)
        {
            timeSinceUpdate += gameTime.ElapsedSeconds;

            for (int i = 0; timeSinceUpdate > (1 / CalculationUPS); i++)
            {
                if (i >= MAX_UPDATE_PER_CALL)
                {
                    timeSinceUpdate = 0; break;
                }

                RealUpdate();
                timeSinceUpdate -= (1 / CalculationUPS);
            }

            Value = LastValue + (NextValue - LastValue) * timeSinceUpdate * CalculationUPS;
        }
Ejemplo n.º 5
0
        private void UpdateBarrel(SAMTime gameTime)
        {
            if ((CannonHealth.TargetValue >= 1 || Fraction.IsNeutral))
            {
                if (controller.DoBarrelRecharge())
                {
                    float chargeDelta = BARREL_CHARGE_SPEED_TRISHOT * Fraction.BulletMultiplicator * RealBoost * gameTime.ElapsedSeconds;
                    if (Scale > 2.5f)
                    {
                        chargeDelta /= Scale;
                    }

                    BarrelCharge += chargeDelta;

                    if (BarrelCharge >= 1f)
                    {
                        BarrelCharge -= 1f;

                        Shoot();
                    }
                }
                else if (controller.SimulateBarrelRecharge())
                {
                    float chargeDelta = BARREL_CHARGE_SPEED_TRISHOT * Fraction.BulletMultiplicator * RealBoost * gameTime.ElapsedSeconds;
                    if (Scale > 2.5f)
                    {
                        chargeDelta /= Scale;
                    }

                    BarrelCharge += chargeDelta;

                    if (BarrelCharge >= 1f)
                    {
                        BarrelCharge -= 1f;

                        barrelRecoil = 0f;
                    }
                }
            }

            if (barrelRecoil < 1)
            {
                barrelRecoil = FloatMath.LimitedInc(barrelRecoil, BARREL_RECOIL_SPEED * Fraction.BulletMultiplicator * RealBoost * gameTime.ElapsedSeconds, 1f);
            }
        }
Ejemplo n.º 6
0
        protected override void OnCycleProgress(HUDContainer entity, float progress, SAMTime gameTime, InputState istate)
        {
            for (int i = 0; i < _controls.Length; i++)
            {
                var cp = i * 1f / (_controls.Length - 1);

                var pos = 3 - progress * 4 + cp;

                if (pos < 0 || pos > 2)
                {
                    _controls[i].RelativePosition = _originalCoords[i];
                }
                else
                {
                    _controls[i].RelativePosition = _originalCoords[i] + new Vector2(0, FloatMath.Sin(pos * FloatMath.TAU) * OFFSET);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (!_initElement.Alive)
            {
                Remove();
            }

            Lifetime += gameTime.ElapsedSeconds;

            if (_removeOnBackKey && istate.IsKeyExclusiveJustDown(SKeys.AndroidBack))
            {
                istate.SwallowKey(SKeys.AndroidBack, InputConsumer.HUDElement); Remove();
            }
            if (_removeOnBackKey && istate.IsKeyExclusiveJustDown(SKeys.Backspace))
            {
                istate.SwallowKey(SKeys.Backspace, InputConsumer.HUDElement); Remove();
            }
        }
Ejemplo n.º 8
0
        private void UpdateToasts(SAMTime gameTime)
        {
            for (int i = _toasts.Count - 1; i >= 0; i--)
            {
                if (!_toasts[i].Alive)
                {
                    _toasts.RemoveAt(i);
                }
            }

            float px = HUDToast.PAD_BOTTOM;

            foreach (var xtoast in _toasts)
            {
                xtoast.PositionY.Set(px);
                px += xtoast.Height + HUDToast.PAD_VERT;
            }
        }
Ejemplo n.º 9
0
        private void UpdateNetwork(SAMTime gameTime)
        {
            bool active = CannonHealth.TargetValue >= FULL_LASER_HEALTH;

            LaserSource.SetState(active, Fraction, Rotation.ActualValue, ChargeTime > LASER_CHARGE_COOLDOWN);

            if (!_muted && MainGame.Inst.Profile.EffectsEnabled)
            {
                if (LaserSource.LaserPowered && !_soundeffect.IsPlaying)
                {
                    _soundeffect.Play();
                }
                if (!LaserSource.LaserPowered && _soundeffect.IsPlaying)
                {
                    _soundeffect.Stop();
                }
            }
        }
Ejemplo n.º 10
0
        private void OnClickCenter(GameEntityMouseArea owner, SAMTime dateTime, InputState istate)
        {
            if (GDOwner.ZoomState != BistateProgress.Normal)
            {
                return;
            }

            var stat = StateSum;

            if (stat == BistateProgress.Closed || stat == BistateProgress.Closing)
            {
                OpenNode();
            }
            else if (stat == BistateProgress.Open || stat == BistateProgress.Opening || stat == BistateProgress.Undefined)
            {
                CloseNode();
            }
        }
Ejemplo n.º 11
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;
                    }
                }
            }
        }
        protected override void OnProgress(HUDScorePanel element, float progress, SAMTime gameTime, InputState istate)
        {
            if (progress < 0.5f)
            {
                var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2;
                element.LabelTime1.Alpha = p;
                element.LabelTime2.Alpha = p;
            }
            else
            {
                var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2;

                element.LabelTime1.L10NText = _txt1;
                element.LabelTime2.Text     = _txt2;

                element.LabelTime1.Alpha = p;
                element.LabelTime2.Alpha = p;
            }
        }
Ejemplo n.º 13
0
 protected override void DoUpdate(SAMTime gameTime, InputState istate)
 {
     if (ToggleState == false && FloatMath.IsNotZero(_knobPosition))
     {
         _knobPosition -= gameTime.ElapsedSeconds / TRANSITION_TIME;
         if (_knobPosition <= 0f)
         {
             _knobPosition = 0f;
         }
     }
     else if (ToggleState == true && FloatMath.IsNotOne(_knobPosition))
     {
         _knobPosition += gameTime.ElapsedSeconds / TRANSITION_TIME;
         if (_knobPosition >= 1f)
         {
             _knobPosition = 1f;
         }
     }
 }
Ejemplo n.º 14
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            base.Update(gameTime, istate);

            if (suppressClick && !IsPointerDownOnElement)
            {
                suppressClick = false;
            }

            if (multiClickCounter > 0)
            {
                UpdateMultiClick(istate, gameTime.TotalElapsedSeconds - lastClickTime);
            }

            if (IsPointerDownOnElement && IsInstantHoldClickMode)
            {
                UpdateInstantHold(istate);
            }
        }
Ejemplo n.º 15
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            base.OnUpdate(gameTime, istate);

#if DEBUG
            DebugUtils.TIMING_NETWORK.Start();
            _server.Update(gameTime, istate);
            DebugUtils.TIMING_NETWORK.Stop();
#else
            _server.Update(gameTime, istate);
#endif

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                HUD.ShowToast("SCRNSC::ERR", L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);

                MainGame.Inst.SetOverworldScreen();
            }
        }
Ejemplo n.º 16
0
        protected override void OnClick(GameEntityMouseArea area, SAMTime gameTime, InputState istate)
        {
            var ownr = ((GDOverworldScreen)Owner);

            if (ownr.IsTransitioning)
            {
                return;
            }

            if (MainGame.Inst.Profile.AccountType == AccountType.Local)
            {
                MainGame.Inst.ShowToast(null, L10N.T(L10NImpl.STR_MP_CONNECTING), 40, FlatColors.Emerald, FlatColors.Foreground, 2f);
                MainGame.Inst.Backend.CreateUser(MainGame.Inst.Profile).RunAsync();
                return;
            }

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

            var ustate = UnlockManager.IsUnlocked(Levels.WORLD_ID_ONLINE, true);

            switch (ustate)
            {
            case WorldUnlockState.OpenAndUnlocked:
                Owner.HUD.AddModal(new SCCMMainPanel(), true, 0.5f, 1f);
                break;

            case WorldUnlockState.ReachableButMustBePreviewed:
            case WorldUnlockState.UnreachableButCanBePreviewed:
                Owner.HUD.AddModal(new SCCMPreviewPanel(), true, 0.5f, 1f);
                break;

            case WorldUnlockState.UnreachableAndFullyLocked:
                Owner.HUD.ShowToast("ONSCCM::LOCKED(MULTI)", L10N.T(L10NImpl.STR_GLOB_WORLDLOCK), 40, FlatColors.Pomegranate, FlatColors.Foreground, 1.5f);
                MainGame.Inst.GDSound.PlayEffectError();

                AddOperation(new ShakeNodeOperation());
                break;

            default:
                SAMLog.Error("ONSCCM::EnumSwitch_OC", "ustate: " + ustate);
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 17
0
 private void RemoteUpdateSim(SAMTime gameTime)
 {
     if (LastAttackingShieldLaser > 0)
     {
         ShieldTime += (SHIELD_CHARGE_SPEED)*gameTime.ElapsedSeconds;
         if (ShieldTime > MAX_SHIELD_TIME)
         {
             ShieldTime = MAX_SHIELD_TIME;
         }
     }
     else
     {
         ShieldTime -= (SHIELD_DISCHARGE_SPEED)*gameTime.ElapsedSeconds;
         if (ShieldTime < 0)
         {
             ShieldTime = 0;
         }
     }
 }
Ejemplo n.º 18
0
        public void Update(SAMTime gameTime, InputState istate)
        {
            float sec = gameTime.TotalElapsedSeconds;

            if (collCount0 != GC.CollectionCount(0))
            {
                collCount0 = GC.CollectionCount(0); LastGC0 = sec; freq.Inc(sec);
            }
            if (collCount1 != GC.CollectionCount(1))
            {
                collCount1 = GC.CollectionCount(1); LastGC1 = sec; freq.Inc(sec);
            }
            if (collCount2 != GC.CollectionCount(2))
            {
                collCount2 = GC.CollectionCount(2); LastGC2 = sec; freq.Inc(sec);
            }

            TotalMemory = GC.GetTotalMemory(false) / (1024f * 1024f);
        }
Ejemplo n.º 19
0
        private void UpdateDrag(SAMTime gameTime, InputState istate)
        {
            if (istate.AllGamePointerPositions.Length > 1)
            {
                return;
            }

            var delta = istate.GamePointerPosition - mouseStartPos;

            Screen.MapOffsetX = startOffset.X + delta.X;
            Screen.MapOffsetY = startOffset.Y + delta.Y;

            CalculateOOB();

            if (gameTime.TotalElapsedSeconds - _lastMousePosTime > DRAGSPEED_RESOLUTION_TIME)
            {
                CalcRestDragSpeed(gameTime, istate);
            }
        }
Ejemplo n.º 20
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (orientation == SSBOrientation.V)
            {
                var px = master.RelativeCenter.X - DIAMETER / 2;
                var py = master.RelativeCenter.Y + SettingsButton.DIAMETER / 2 - DIAMETER;

                py += MARGIN_FIRST;
                py += (position + 1) * (DIAMETER + DIST_Y) * OffsetProgress;

                RelativePosition = new FPoint(px, py);

                Slave.RelativePosition = new FPoint(CenterX + SIZE_ICON, CenterY);
            }
            else if (orientation == SSBOrientation.H)
            {
                Slave.RelativePosition = new FPoint(CenterX, CenterY + SIZE_ICON);
            }
        }
Ejemplo n.º 21
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;
            }

            if (UnlockManager.IsUnlocked(Blueprint.TargetWorld, true) == WorldUnlockState.OpenAndUnlocked)
            {
                Owner.AddAgent(new LeaveTransitionWorldMapAgent(GDOwner, GDOwner.ZoomState == BistateProgress.Expanded, this, Target));
                MainGame.Inst.GDSound.PlayEffectZoomOut();
            }
            else
            {
                Owner.AddAgent(new LeaveTransitionOverworldAgent(GDOwner, GDOwner.ZoomState == BistateProgress.Expanded));
                MainGame.Inst.GDSound.PlayEffectZoomOut();
            }
        }
Ejemplo n.º 22
0
        private void UpdateDamage(SAMTime gameTime)
        {
            if (!LaserSource.LaserActive)
            {
                return;
            }

            bool hit = false;

            foreach (var ray in LaserSource.Lasers)
            {
                if (ray.Terminator != LaserRayTerminator.Target)
                {
                    continue;
                }

                if (ray.TargetCannon == null)
                {
                    continue;
                }

                if (ray.TargetCannon.Fraction == Fraction)
                {
                    if (ray.TargetCannon == this)
                    {
                        continue;                                               // stop touching yourself
                    }
                    hit = true;

                    if (!LaserSource.LaserPowered)
                    {
                        continue;
                    }
                    ray.TargetCannon.ApplyShield(gameTime);
                }
            }

            if (!hit)
            {
                ChargeTime = 0f;
            }
        }
Ejemplo n.º 23
0
        protected void UpdateHealth(SAMTime gameTime)
        {
            LastAttackingLasersEnemy      = counterAttackingLasersEnemy;
            LastAttackingLasersFriends    = counterAttackingLasersFriends;
            LastAttackingShieldLaser      = counterAttackingShieldLaser;
            counterAttackingLasersEnemy   = 0;
            counterAttackingLasersFriends = 0;

            CannonHealth.Update(gameTime);

            if (CannonHealth.TargetValue < 1 && CannonHealth.TargetValue > MIN_REGEN_HEALTH && (LastAttackingLasersEnemy <= LastAttackingLasersFriends))
            {
                var bonus = START_HEALTH_REGEN + (END_HEALTH_REGEN - START_HEALTH_REGEN) * CannonHealth.TargetValue;

                bonus /= Scale;

                CannonHealth.Inc(bonus * gameTime.ElapsedSeconds);
                CannonHealth.Limit(0f, 1f);
            }
        }
Ejemplo n.º 24
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            base.DoUpdate(gameTime, istate);

            if (!Alive)
            {
                return;
            }

            if (_ustate != WorldUnlockState.OpenAndUnlocked)
            {
                _ustate = UnlockManager.IsUnlocked(Levels.WORLD_ID_MULTIPLAYER, false);

                if (_ustate == WorldUnlockState.OpenAndUnlocked)
                {
                    Remove();
                    Owner.HUD.AddModal(new MultiplayerMainPanel(), true, 0.5f);
                }
            }
        }
        protected override void OnProgress(TEntity entity, float progress, SAMTime gameTime, InputState istate)
        {
            _timeSinceLastCycle += gameTime.ElapsedSeconds;

            if (_timeSinceLastCycle > _cyleTime)
            {
                _cmd(entity, _cycleCounter);

                if (_reliable)
                {
                    _timeSinceLastCycle -= _cyleTime;
                }
                else
                {
                    _timeSinceLastCycle = 0;
                }

                _cycleCounter++;
            }
        }
Ejemplo n.º 26
0
 public void Update(SAMTime gameTime)
 {
     // ReSharper disable once CompareOfFloatsByEqualityOperator
     if (ActualValue < TargetValue)
     {
         ActualValue += _deltaSpeed * gameTime.ElapsedSeconds;
         if (ActualValue > TargetValue)
         {
             ActualValue = TargetValue;
         }
     }
     else if (ActualValue > TargetValue)
     {
         ActualValue -= _deltaSpeed * gameTime.ElapsedSeconds;
         if (ActualValue < TargetValue)
         {
             ActualValue = TargetValue;
         }
     }
 }
Ejemplo n.º 27
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            _server.Update(gameTime, istate);

            if (skipUpdate)
            {
                return;
            }

            if (_server.LevelID != null && _server.LevelID.Value != _lastLevelID)
            {
                _lastLevelID = _server.LevelID.Value;

                LevelBlueprint bp;
                if (Levels.LEVELS.TryGetValue(_server.LevelID.Value, out bp))
                {
                    var d = GetFractionColorByID(bp, _server.SessionUserID + 1);
                    fracName = d.Item1;
                    _lblFraction.TextColor = d.Item2;
                }
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Remove();

                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
                skipUpdate = true;
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InGame)
            {
                MainGame.Inst.SetMultiplayerClientLevelScreen(Levels.LEVELS[_server.LevelID.Value], _server.Speed.Value, _server.MusicIndex.Value, _server);
                skipUpdate = true;
            }
        }
Ejemplo n.º 28
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            Rotation += RotationSpeed * gameTime.ElapsedSeconds;
            internalImage.Rotation = Rotation;

            if (internalLabel.InnerLabelSize != innerSizeCache)
            {
                innerSizeCache = internalLabel.InnerLabelSize;

                float sw = IconPadding.Width + IconSize.Width + TextPadding.Width + innerSizeCache.Width + TextPadding.Width;
                float sh = FloatMath.Max(IconSize.Height + 2 * IconPadding.Height, innerSizeCache.Height + 2 * TextPadding.Height);
                Size = new FSize(sw, sh);

                internalLabel.Size             = innerSizeCache;
                internalLabel.RelativePosition = new FPoint(IconPadding.Width + IconSize.Width + TextPadding.Width, 0);

                internalImage.RelativePosition = new FPoint(IconPadding.Width, 0);

                internalLabel.MaxWidth = Owner.Width - TextPadding.Width * 2 - Margin.Width * 2;
            }
        }
Ejemplo n.º 29
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (_scrollbar != null)
            {
                _scrollbar.ScrollPosition = Offset;
            }
            if (_scrollbar != null)
            {
                _scrollbar.ScrollMax = ChildrenCount;
            }
            if (_scrollbar != null)
            {
                _scrollbar.ScrollPageSize = _entryCount;
            }


            if (relayout)
            {
                RelayoutEntries();
            }
        }
Ejemplo n.º 30
0
        private void UpdateRestDrag(SAMTime gameTime)
        {
            float rowHeight = FontSize + 2 * LineWidth;

            ScrollPosition -= dragSpeed / rowHeight * gameTime.ElapsedSeconds;
            if (ScrollPosition < 0)
            {
                ScrollPosition = 0;
            }
            if (ScrollPosition > _maxScrollPosition)
            {
                ScrollPosition = _maxScrollPosition;
            }

            dragSpeed -= dragSpeed * FRICTION * gameTime.ElapsedSeconds;

            if (dragSpeed < SPEED_MIN)
            {
                dragSpeed = 0;
            }
        }