public ClientViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) : base(renderView, audioInterface, previousViewer, gui, Type.Client) { Log.Verbose.Write(ErrorSystemType.Application, "Creating client viewer."); client = previousViewer.MainInterface.Client; client.Disconnected += Client_Disconnected; }
internal Game Instantiate(Render.IRenderView renderView, Audio.IAudioInterface audioInterface) { var game = new Game(renderView, audioInterface); if (!game.Init(MapSize, RandomBase)) { return(null); } uint playerIndex = 0u; // Initialize player and build initial castle foreach (var playerInfo in players) { if (playerInfo != null) { var player = game.InsertPlayer(playerIndex, playerInfo.Intelligence, playerInfo.Supplies, playerInfo.Reproduction); if (!playerInfo.Face.IsHuman()) // not you or your partner { if (intro) { player.AI = new IntroAI(player, playerInfo); } else { player.AI = new AI(player, playerInfo); } } player.InitView(playerInfo.Color, playerInfo.Face); var castlePos = playerInfo.CastlePosition; if (castlePos.Column > -1 && castlePos.Row > -1) { var position = game.Map.Position((MapPos)castlePos.Column, (MapPos)castlePos.Row); game.BuildCastle(position, player); } } ++playerIndex; if (playerIndex == Game.MAX_PLAYER_COUNT) { break; } } game.InitKnights(); return(game); }
public ServerViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) : base(renderView, previousViewer, gui, Type.Server) { // Note: It is ok if the only clients are spectators, but running a server without any connected client makes no sense. // Note: All clients must be setup at game start. Clients can not join during the game. // Note: There may be more than 3 clients because of spectators! server = Network.Network.DefaultServerFactory.CreateLocal(previousViewer.MainInterface.ServerGameName, previousViewer.MainInterface.ServerGameInfo); Init(); MainInterface = new ServerInterface(renderView, audioInterface, this, server); }
public ServerViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) : base(renderView, previousViewer, gui, Type.Server) { Log.Verbose.Write(ErrorSystemType.Application, "Creating server viewer."); // Note: It is ok if the only clients are spectators, but running a server without any connected client makes no sense. // Note: All clients must be setup at game start. Clients can not join during the game. // Note: There may be more than 3 clients because of spectators! server = previousViewer.MainInterface.Server; server.NetworkDataReceiver = previousViewer.MainInterface.NetworkDataHandler.NetworkDataReceiver; Init(); MainInterface = new ServerInterface(renderView, audioInterface, this, previousViewer.MainInterface); }
public bool StartGame(GameInfo gameInfo, Render.IRenderView renderView, Audio.IAudioInterface audioInterface) { var newGame = gameInfo.Instantiate(renderView, audioInterface); if (newGame == null) { return(false); } lastSaveTime = DateTime.MinValue; currentGameSaveFile = null; SetCurrentGame(newGame); return(true); }
public Interface(IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer viewer) : base(renderView, audioInterface) { RenderView = renderView; AudioInterface = audioInterface; Viewer = viewer; TextRenderer = new TextRenderer(renderView); displayed = true; config = UserConfig.Game.Options; mapCursorSprites[0] = new SpriteLocation { Sprite = 31 }; mapCursorSprites[1] = new SpriteLocation { Sprite = 32 }; mapCursorSprites[2] = new SpriteLocation { Sprite = 32 }; mapCursorSprites[3] = new SpriteLocation { Sprite = 32 }; mapCursorSprites[4] = new SpriteLocation { Sprite = 32 }; mapCursorSprites[5] = new SpriteLocation { Sprite = 32 }; mapCursorSprites[6] = new SpriteLocation { Sprite = 32 }; cursorSprite = renderView.SpriteFactory.Create(16, 16, 0, 0, false, false, 255); cursorSprite.Layer = renderView.GetLayer(Freeserf.Layer.Cursor); cursorSprite.Visible = true; SetSize(640, 480); // original size Viewport = null; PanelBar = new PanelBar(this); AddChild(PanelBar, 0, 0, false); Layout(); }
public Game Instantiate(Render.IRenderView renderView, Audio.IAudioInterface audioInterface) { var game = new Game(renderView, audioInterface); if (!game.Init(MapSize, RandomBase)) { return(null); } // Initialize player and build initial castle foreach (var playerInfo in players) { var index = game.AddPlayer(playerInfo.Intelligence, playerInfo.Supplies, playerInfo.Reproduction); var player = game.GetPlayer(index); if (!playerInfo.Face.IsHuman()) // not you or your partner { if (intro) { player.AI = new IntroAI(player, playerInfo); } else { player.AI = new AI(player, playerInfo); } } player.InitView(playerInfo.Color, playerInfo.Face); var castlePos = playerInfo.CastlePosition; if (castlePos.Column > -1 && castlePos.Row > -1) { var position = game.Map.Position((MapPos)castlePos.Column, (MapPos)castlePos.Row); game.BuildCastle(position, player); } } return(game); }
public bool LoadGame(string path, Render.IRenderView renderView, Audio.IAudioInterface audioInterface, ref Viewer viewer) { CloseGame(); if (!GameStore.Instance.Load(path, () => new Game(renderView, audioInterface), out Game newGame)) { return(false); } if (newGame.GetPlayer(0).IsAI) { viewer = viewer.ChangeTo(Viewer.Type.LocalSpectator); } lastSaveTime = DateTime.Now; currentGameSaveFile = path; SetCurrentGame(newGame); newGame.TogglePause(); return(true); }
public LocalSpectatorViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) : this(renderView, previousViewer, gui, Type.LocalSpectator) { if (previousViewer == null) { Init(); MainInterface = new Interface(renderView, audioInterface, gui, this); MainInterface.OpenGameInit(); } else { if (previousViewer.MainInterface.GetType() != typeof(Interface)) { MainInterface = new Interface(renderView, audioInterface, gui, this); } else { MainInterface = previousViewer.MainInterface; } MainInterface.Viewer = this; } }
public static Viewer Create(Type type, Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) { switch (type) { default: case Type.LocalPlayer: return(CreateLocalPlayer(renderView, audioInterface, previousViewer, gui)); case Type.LocalSpectator: return(CreateLocalSpectator(renderView, audioInterface, previousViewer, gui)); case Type.Server: return(CreateServerPlayer(renderView, audioInterface, previousViewer, gui)); case Type.Client: return(CreateClientPlayer(renderView, audioInterface, previousViewer, gui)); case Type.RemoteSpectator: return(CreateRemoteSpectator(renderView, audioInterface, previousViewer, false, gui)); case Type.RestrictedRemoteSpectator: return(CreateRemoteSpectator(renderView, audioInterface, previousViewer, true, gui)); } }
public RemoteInterface(IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer viewer) : base(renderView, audioInterface, viewer) { }
public ClientViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) : base(renderView, audioInterface, previousViewer, gui, Type.Client) { }
public ServerInterface(IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer viewer, Network.ILocalServer server) : base(renderView, audioInterface, viewer) { this.server = server; }
public Game PrepareMultiplayerGame(GameInfo gameInfo, Render.IRenderView renderView, Audio.IAudioInterface audioInterface) { var newGame = gameInfo.Instantiate(renderView, audioInterface); if (newGame == null) { return(null); } // Multiplayer games start paused. newGame.TogglePause(); return(newGame); }
// Client must also receive events from server (with the other clients player index) public static Viewer CreateClientPlayer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) { throw new NotSupportedException("Not supported yet."); }
public bool StartRandomGame(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, bool aiPlayersOnly) { return(StartGame(new GameInfo(new Random(), aiPlayersOnly), renderView, audioInterface)); }
protected RemoteSpectatorViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui, Type type) : base(renderView, gui, type) { Init(); MainInterface = new RemoteInterface(renderView, audioInterface, this, previousViewer.MainInterface); }
public RemoteSpectatorViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui, bool restricted) : this(renderView, audioInterface, previousViewer, gui, restricted ? Type.RestrictedRemoteSpectator : Type.RemoteSpectator) { }
// Client must also receive events from server (with the other clients player index) public static Viewer CreateClientPlayer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) { return(new ClientViewer(renderView, audioInterface, previousViewer, gui)); }
public Game PrepareMultiplayerGame(GameInfo gameInfo, Render.IRenderView renderView, Audio.IAudioInterface audioInterface) { var newGame = gameInfo.Instantiate(renderView, audioInterface); if (newGame == null) { return(null); } return(newGame); }
public static Viewer CreateRemoteSpectator(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, bool resticted, Gui gui) { throw new NotSupportedException("Not supported yet."); }
public static Viewer CreateLocalSpectator(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui) { return(new LocalSpectatorViewer(renderView, audioInterface, previousViewer, gui)); }