protected override Asset Read(BinaryReader reader) { Scheme scheme = new Scheme(); scheme.name = reader.ReadString(); scheme.brickDensity = reader.ReadInt32(); int width = reader.ReadInt32(); int height = reader.ReadInt32(); scheme.fieldData = new FieldData(width, height); FieldBlocks[] blocks = scheme.fieldData.GetDataArray(); for (int i = 0; i < blocks.Length; ++i) { blocks[i] = (FieldBlocks)reader.ReadInt32(); } int playersCount = reader.ReadInt32(); PlayerLocationInfo[] playerLocations = new PlayerLocationInfo[playersCount]; for (int i = 0; i < playerLocations.Length; ++i) { int x = reader.ReadInt32(); int y = reader.ReadInt32(); int team = reader.ReadInt32(); playerLocations[i] = new PlayerLocationInfo(i, x, y, team); } scheme.playerLocations = playerLocations; int powerupsCount = reader.ReadInt32(); PowerupInfo[] powerupInfo = new PowerupInfo[powerupsCount]; for (int i = 0; i < powerupInfo.Length; ++i) { powerupInfo[i].powerupIndex = reader.ReadInt32(); powerupInfo[i].bornWith = reader.ReadBoolean(); powerupInfo[i].hasOverride = reader.ReadBoolean(); powerupInfo[i].overrideValue = reader.ReadInt32(); powerupInfo[i].forbidden = reader.ReadBoolean(); } scheme.powerupInfo = powerupInfo; return scheme; }
public SchemeView(Scheme scheme, Style style) { FieldData data = scheme.GetFieldData(); Font nameFont; float dvy = 0.0f; FieldDataView.Style dataStyle; if (style == Style.Small) { SetSize(153, 143); AddView(new RectView(0, 0, width, height, COLOR_BACK, Color.Black)); nameFont = Helper.fontSystem; dvy = 13.0f; dataStyle.width = 127; dataStyle.height = 86; dataStyle.iw = 119; dataStyle.ih = 79; } else if (style == Style.Large) { SetSize(215, 176); nameFont = Helper.fontSystem; dataStyle.width = 215; dataStyle.height = 145; dataStyle.iw = 201; dataStyle.ih = 132; } else { throw new ArgumentException("Unknown style: " + style); } FieldDataView dataView = new FieldDataView(data, dataStyle); dataView.x = 0.5f * width; dataView.y = dvy; dataView.alignX = View.ALIGN_CENTER; AddView(dataView); TextView nameView = new TextView(nameFont, scheme.GetName(), (int)width); nameView.x = 0.5f * width; nameView.y = 0.5f * (height + (dataView.y + dataView.height)); nameView.alignX = nameView.alignY = View.ALIGN_CENTER; AddView(nameView); }
public SchemeSelectionView(Scheme schemes) { }
private void InitInputTypes(Scheme scheme) { int maxPlayers = scheme.GetMaxPlayersCount(); inputTypes = new InputType[maxPlayers]; for (int i = 0; i < inputTypes.Length; ++i) { inputTypes[i] = InputType.None; } inputStates = new InputState[(int)InputType.Count]; SetInputState(InputType.None, InputState.Available); SetInputState(InputType.Keyboard1, InputState.Available); SetInputState(InputType.Keyboard2, InputState.Available); SetInputState(InputType.Keyboard3, InputState.Available); SetInputState(InputType.Keyboard4, InputState.Available); SetInputState(InputType.Keyboard5, InputState.Available); SetInputState(InputType.Keyboard6, InputState.Available); InputManager im = Input(); SetInputState(InputType.GamePad1, im.IsGamePadConnected(0) ? InputState.Available : InputState.Disabled); SetInputState(InputType.GamePad2, im.IsGamePadConnected(1) ? InputState.Available : InputState.Disabled); SetInputState(InputType.GamePad3, im.IsGamePadConnected(2) ? InputState.Available : InputState.Disabled); SetInputState(InputType.GamePad4, im.IsGamePadConnected(3) ? InputState.Available : InputState.Disabled); SetInputState(InputType.Network, InputState.Disabled); SetInputState(InputType.Bot, InputState.Disabled); SetInputType(0, InputType.Keyboard1); SetInputType(1, InputType.Keyboard2); }
protected override void OnStart() { selectedScheme = Assets().GetScheme(A.maps_x); InitInputTypes(selectedScheme); StartScreen(new PlayersScreen(selectedScheme, inputTypes, InputTypeSelectDelegate, PlayersScreenButtonDelegate)); }
internal static ServerInfo ReadServerInfo(NetIncomingMessage message) { // name String name = message.ReadString(); // scheme Scheme scheme = new Scheme(); // scheme: name scheme.name = message.ReadString(); // scheme: field data int fieldWidth = message.ReadInt32(); int fieldHeight = message.ReadInt32(); FieldBlocks[] fieldDataArray = new FieldBlocks[fieldWidth * fieldHeight]; for (int i = 0; i < fieldDataArray.Length; ++i) { fieldDataArray[i] = (FieldBlocks)message.ReadByte(); } scheme.fieldData = new FieldData(fieldWidth, fieldHeight, fieldDataArray); // scheme: player locations int locationsCount = message.ReadByte(); PlayerLocationInfo[] playerLocations = new PlayerLocationInfo[locationsCount]; for (int i = 0; i < locationsCount; ++i) { int x = message.ReadByte(); int y = message.ReadByte(); int team = message.ReadByte(); playerLocations[i] = new PlayerLocationInfo(i, x, y, team); } scheme.playerLocations = playerLocations; ServerInfo info = new ServerInfo(name, message.SenderEndPoint); info.scheme = scheme; return info; }
public void Setup(Scheme scheme) { SetupField(scheme.GetFieldData()); }
public void Restart(Scheme scheme) { Reset(); Load(scheme); // TODO: reuse objects }
public void Load(Scheme scheme) { SetupField(scheme.GetFieldData(), scheme.GetBrickDensity()); SetupPlayers(players, scheme.GetPlayerLocations()); SetupPowerups(scheme.GetPowerupInfo()); }
/* Loads field from scheme: setups ONLY bricks */ public void SetupField(Scheme scheme) { m_currentScheme = scheme; m_field.Setup(scheme); }
/* Loads field from scheme: setups bricks, powerups and players */ public void LoadField(Scheme scheme) { m_currentScheme = scheme; m_field.Load(scheme); }
public GameSettings(Scheme scheme) { Debug.CheckArgumentNotNull("scheme", scheme); this.scheme = scheme; }
protected void SetupField(Scheme scheme) { game.SetupField(scheme); }
protected void LoadField(Scheme scheme) { game.LoadField(scheme); }
public PlayersScreen(Scheme scheme, InputType[] inputTypes, InputTypeSelectDelegate selectDelegate, ButtonDelegate buttonDelegate) { View contentView = new View(64, 48, 521, 363); // scheme view contentView.AddView(new SchemeView(scheme, SchemeView.Style.Large)); // input type selector int maxPlayers = inputTypes.Length; View inputTypeContainer = new View(226, 0, 286, 0); Font font = Helper.fontButton; for (int i = 0; i < maxPlayers; ++i) { InputTypeView typeView = new InputTypeView(i, inputTypes[i], font, inputTypeContainer.width, font.FontHeight()); typeView.selectDelegate = selectDelegate; inputTypeContainer.AddView(typeView); } inputTypeContainer.LayoutVer(0); inputTypeContainer.ResizeToFitViewsHor(); contentView.AddView(inputTypeContainer); AddView(contentView); // buttons View buttons = new View(0.5f * width, contentView.y + contentView.height, 0, 0); buttons.alignX = View.ALIGN_CENTER; Button button = new TempButton("BACK"); button.id = (int)ButtonId.Back; button.buttonDelegate = buttonDelegate; SetCancelButton(button); buttons.AddView(button); button = new TempButton("START!"); button.id = (int)ButtonId.Start; button.buttonDelegate = buttonDelegate; FocusView(button); SetConfirmButton(button); buttons.AddView(button); buttons.LayoutHor(20); buttons.ResizeToFitViews(); AddView(buttons); }