Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 public static Viewer CreateLocalSpectator(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui)
 {
     return(new LocalSpectatorViewer(renderView, audioInterface, previousViewer, gui));
 }
Ejemplo n.º 5
0
 public static Viewer CreateRemoteSpectator(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, bool resticted, Gui gui)
 {
     throw new NotSupportedException("Not supported yet.");
 }
Ejemplo n.º 6
0
 public RemoteSpectatorViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui, bool restricted)
     : this(renderView, audioInterface, previousViewer, gui, restricted ? Type.RestrictedRemoteSpectator : Type.RemoteSpectator)
 {
 }
Ejemplo n.º 7
0
 // 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));
 }
Ejemplo n.º 8
0
        public override void OnEndGame(Game game)
        {
            MainInterface.SetGame(null);

            Gui.SetViewer(Viewer.CreateLocalPlayer(MainInterface.RenderView, MainInterface.AudioInterface, this, Gui));
        }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 public ClientViewer(Render.IRenderView renderView, Audio.IAudioInterface audioInterface, Viewer previousViewer, Gui gui)
     : base(renderView, audioInterface, previousViewer, gui, Type.Client)
 {
 }
Ejemplo n.º 11
0
 // 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.");
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 protected LocalSpectatorViewer(Render.IRenderView renderView, Viewer previousViewer, Gui gui, Type type)
     : base(renderView, gui, type)
 {
 }
Ejemplo n.º 14
0
 protected LocalPlayerViewer(Render.IRenderView renderView, Viewer previousViewer, Gui gui, Type type)
     : base(renderView, previousViewer, gui, type)
 {
 }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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;
        }