public void ResetGame() { gameTickTimer.Stop(); HP = Max_HP; currentOwner = CommandColors.NOBODY; elapsedTime = gameTimeInterval; }
public virtual void DrawCommandButton(NodeCommandPartRendererEventArgs info) { bool mouseOver = (info.Node.MouseOverNodePart == eMouseOverNodePart.Command); CommandColors c=new CommandColors(); if(mouseOver) { c.BackColor = info.MouseOverBackColor; c.BackColor2 = info.MouseOverBackColor2; c.BackColorGradientAngle = info.MouseOverBackColorGradientAngle; c.ForeColor = info.MouseOverForeColor; } else { c.BackColor = info.BackColor; c.BackColor2 = info.BackColor2; c.BackColorGradientAngle = info.BackColorGradientAngle; c.ForeColor = info.ForeColor; } Rectangle fillBounds = info.CommandPartBounds; fillBounds.Width--; fillBounds.Height--; Region oldRegion = info.Graphics.Clip.Clone() as Region; info.Graphics.SetClip(fillBounds,CombineMode.Intersect); if(c.BackColor2.IsEmpty) { if(!c.BackColor.IsEmpty) { using(SolidBrush brush=new SolidBrush(c.BackColor)) info.Graphics.FillRectangle(brush,fillBounds); } } else { using(LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(info.CommandPartBounds, c.BackColor, c.BackColor2, c.BackColorGradientAngle)) info.Graphics.FillRectangle(brush,fillBounds); } if(c.ForeColor.IsEmpty) return; int width=6; int height=3; GraphicsPath path=new GraphicsPath(); Point p=new Point(info.CommandPartBounds.X+(info.CommandPartBounds.Width-width)/2,info.CommandPartBounds.Y+(info.CommandPartBounds.Height-height)/2); path.AddLine(p.X, p.Y, p.X+width,p.Y); path.AddLine(p.X+width,p.Y,p.X+width/2,p.Y+height); path.AddLine(p.X, p.Y,p.X+width/2,p.Y+height); path.CloseAllFigures(); using(SolidBrush brush=new SolidBrush(c.ForeColor)) info.Graphics.FillPath(brush,path); path.Dispose(); info.Graphics.Clip = oldRegion; }
public GameLogic(int max_hp, int gameTime) { gameTickTimer = new Timer(1000); gameTickTimer.Elapsed += Timer_Elapsed; bleDataLayer = new BluetoothDataLayer(); beaconFilter = new BeaconFilter(bleDataLayer); players = new Dictionary <CommandColors, int>(); players.TryAdd(CommandColors.RED, 0); players.TryAdd(CommandColors.GREEN, 0); players.TryAdd(CommandColors.BLUE, 0); players.TryAdd(CommandColors.YELLOW, 0); winPoints.TryAdd(CommandColors.RED, 0); winPoints.TryAdd(CommandColors.GREEN, 0); winPoints.TryAdd(CommandColors.BLUE, 0); winPoints.TryAdd(CommandColors.YELLOW, 0); pointState = PointState.NEUTRAL; Max_HP = max_hp; HP = Max_HP; currentOwner = CommandColors.NOBODY; elapsedTime = gameTime; gameTimeInterval = gameTime; }
public override EffectLayer Render(IGameState state) { GameState_EliteDangerous gameState = state as GameState_EliteDangerous; GSI.Nodes.Controls controls = (state as GameState_EliteDangerous).Controls; EffectLayer keyBindsLayer = new EffectLayer("Elite: Dangerous - Key Binds"); HashSet <DeviceKeys> leftoverBlendStates = new HashSet <DeviceKeys>(keyBlendStates.Keys); long currentTime = Utils.Time.GetMillisecondsSinceEpoch(); if (gameState.Journal.fsdWaitingCooldown && gameState.Status.IsFlagSet(Flag.FSD_COOLDOWN)) { gameState.Journal.fsdWaitingCooldown = false; } if (gameState.Journal.fsdWaitingSupercruise && gameState.Status.IsFlagSet(Flag.SUPERCRUISE)) { gameState.Journal.fsdWaitingSupercruise = false; } Color newKeyColor; Dictionary <DeviceKeys, Color> smoothColorSets = new Dictionary <DeviceKeys, Color>(); foreach (ControlGroupSet controlGroupSet in controlGroupSets) { if (!controlGroupSet.IsSatisfied(gameState)) { continue; } foreach (ControlGroup controlGroup in controlGroupSet.controlGroups) { if (!controlGroup.IsSatisfied(gameState)) { continue; } foreach (string command in controlGroup.commands) { if (!controls.commandToBind.ContainsKey(command)) { continue; } bool keyWithEffect = KeyPresets.KEY_EFFECTS.ContainsKey(command); foreach (Bind.Mapping mapping in controls.commandToBind[command].mappings) { bool allModifiersPressed = true; foreach (DeviceKeys modifierKey in mapping.modifiers) { SetKey(keyBindsLayer, modifierKey, Properties.ShipStuffColor); leftoverBlendStates.Remove(modifierKey); if (Array.IndexOf( Global.InputEvents.PressedKeys, KeyUtils.GetFormsKey(modifierKey) ) == -1) { allModifiersPressed = false; break; } } if (!allModifiersPressed) { continue; } newKeyColor = Properties.GetColorByGroupName( controlGroup.colorGroupName ?? CommandColors.GetColorGroupForCommand(command) ); if (keyWithEffect) { SetKey(keyBindsLayer, mapping.key, KeyPresets.KEY_EFFECTS[command](newKeyColor, gameState, currentTime)); } else { smoothColorSets[mapping.key] = newKeyColor; } leftoverBlendStates.Remove(mapping.key); } } } } //Apply smooth transitions for keys foreach (KeyValuePair <DeviceKeys, Color> smoothKey in smoothColorSets) { SetKeySmooth(keyBindsLayer, smoothKey.Key, smoothKey.Value); } //Fade out inactive keys foreach (DeviceKeys key in leftoverBlendStates) { SetKeySmooth(keyBindsLayer, key, Color.Empty); } return(keyBindsLayer); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { int _redPlayers = 0; int _greenPlayers = 0; int _bluePlayers = 0; int _yellowPlayers = 0; bool commandIsChanged = false; elapsedTime--; if (elapsedTime == 0) { StopGame(); } List <Beacon> beacons = beaconFilter.GetActiveBeeacons(); foreach (var b in beacons) { switch (b.beaconType) { case Beacon.BeaconType.ARTIFACT: // Need think about it break; case Beacon.BeaconType.COMMAND_BLUE: _bluePlayers++; break; case Beacon.BeaconType.COMMAND_RED: _redPlayers++; break; case Beacon.BeaconType.COMMAND_YELLOW: _yellowPlayers++; break; case Beacon.BeaconType.COMMAND_GREEN: _greenPlayers++; break; } } players[CommandColors.BLUE] = _bluePlayers; players[CommandColors.GREEN] = _greenPlayers; players[CommandColors.RED] = _redPlayers; players[CommandColors.YELLOW] = _yellowPlayers; if (players.Max().Value != players.Min().Value) { if (players.Max().Key != CommandInAttcak) { commandIsChanged = true; } CommandInAttcak = players.Max().Key; } else { CommandInAttcak = CommandColors.NOBODY; } if (CommandInAttcak != currentOwner) { ; } switch (pointState) { case PointState.NEUTRAL: { if (CommandInAttcak != CommandColors.NOBODY) { pointState = PointState.ATTACKED; } break; } case PointState.ATTACKED: { winPoints[currentOwner]++; HP--; if (HP == 0) { currentOwner = CommandInAttcak; pointState = PointState.IS_OWNED; HP = Max_HP; } break; } case PointState.IS_OWNED: winPoints[currentOwner]++; if (commandIsChanged) { pointState = PointState.ATTACKED; } break; default: break; } }