Example #1
0
        public void Startup(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            _logger = serviceProvider.GetRequiredService <ILogger>();

            _engine = serviceProvider.GetRequiredService <IClientEngine>();

            _networking = serviceProvider.GetRequiredService <ClientNetworking>();

            _entities = serviceProvider.GetRequiredService <ClientEntities>();

            _clientUI = new ImGuiInterface(_logger, _engine, this);

            _renderer = new Renderer.Renderer(
                _engine.GameWindow,
                _logger,
                _engine.FileSystem,
                _engine.CommandContext,
                _engine.UserInterface.WindowManager.InputSystem,
                _engine.Time,
                this,
                Framework.Path.EnvironmentMaps,
                Framework.Path.Shaders);

            _engine.GameWindow.Resized += _renderer.WindowResized;

            _entities.Startup(_renderer);
        }
Example #2
0
        //private List<Player> players;
        //private readonly int modifier = 20;

        public Client(IClientEngine clientEngine)
        {
            _clientEngine = clientEngine;

            InitializeComponent();
            ExecuteClient();
        }
Example #3
0
        public ImGuiInterface(ILogger logger, IClientEngine engine, GameClient gameClient)
        {
            _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
            _engine     = engine ?? throw new ArgumentNullException(nameof(engine));
            _gameClient = gameClient ?? throw new ArgumentNullException(nameof(gameClient));

            _engine.LogListener = this;
        }
 public EntityContext(IClientEngine clientEngine, ITime time, IEngineModels engineModels, IRenderer renderer, BaseEntityList <BaseEntity> entityList)
 {
     ClientEngine = clientEngine ?? throw new ArgumentNullException(nameof(clientEngine));
     Time         = time ?? throw new ArgumentNullException(nameof(time));
     EngineModels = engineModels ?? throw new ArgumentNullException(nameof(engineModels));
     Renderer     = renderer ?? throw new ArgumentNullException(nameof(renderer));
     Random       = new Random();
     EntityList   = entityList ?? throw new ArgumentNullException(nameof(entityList));
 }
Example #5
0
        public Server()
        {
            antiGCList  = new List <object>();
            IRCCommands = new IRCCommandList();

            BaseIRCLib.Database.SetDatabase(this);
            BaseIRCLib.Server.SetServer(this);

            Steamworks.Load();
            steamClient  = Steamworks.CreateInterface <ISteamClient009>("SteamClient009");
            clientEngine = Steamworks.CreateInterface <IClientEngine>("CLIENTENGINE_INTERFACE_VERSION001");

            pipe = steamClient.CreateSteamPipe();
            user = steamClient.ConnectToGlobalUser(pipe);

            clientFriends = Steamworks.CastInterface <IClientFriends>(clientEngine.GetIClientFriends(user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001"));
            clientUser    = Steamworks.CastInterface <ISteamUser014>(steamClient.GetISteamUser(user, pipe, "SteamUser014"));
            //clientUser = Steamworks.CastInterface<IClientUser>(clientEngine.GetIClientUser(user, pipe, "CLIENTUSER_INTERFACE_VERSION001"));

            Callback <PersonaStateChange_t>    stateChange   = new Callback <PersonaStateChange_t>(StateChange, PersonaStateChange_t.k_iCallback);
            Callback <FriendChatMsg_t>         friendMessage = new Callback <FriendChatMsg_t>(FriendMessage, FriendChatMsg_t.k_iCallback);
            Callback <ChatRoomMsg_t>           chatMessage   = new Callback <ChatRoomMsg_t>(ChatMessage, ChatRoomMsg_t.k_iCallback);
            Callback <ChatMemberStateChange_t> chatResult    = new Callback <ChatMemberStateChange_t>(ChatResult, ChatMemberStateChange_t.k_iCallback);
            Callback <ChatRoomInvite_t>        chatInvite    = new Callback <ChatRoomInvite_t>(ChatInvite, ChatRoomInvite_t.k_iCallback);

            if (File.Exists("clients.list"))
            {
                clientList = ClientList.LoadClients("clients.list");
            }
            else
            {
                clientList = new ClientList();
                clientList.Save("clients.list");
            }

            foreach (string f in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Commands"), "*.dll"))
            {
                Assembly fA = Assembly.LoadFile(f);
                foreach (Type m in fA.GetTypes())
                {
                    object a = fA.CreateInstance(m.FullName);
                    if (a == null)
                    {
                        Console.WriteLine("Skipping implementation of {0}", m.Name);
                        continue;
                    }

                    antiGCList.Add(a);

                    RegisterCommands(a);
                }
            }
        }
Example #6
0
        public Lobby(IClientEngine ClientEngine)
        {
            clientEngine = ClientEngine;

            clientEngine.OnRoomsStatChanged += SetRoomList;
            clientEngine.OnError            += ErrorHandler;
            clientEngine.OnRoomConnect      += RoomConnect;


            onRoomListRecieved = onRoomListRecievedProc;
            onRoomConnect      = onRoomConnectProc;

            InitializeComponent();
            Name_tb.Text             = "Vasya";
            Create_Room_btn.TabIndex = 0;
        }
Example #7
0
        public bool GetSteamClient()
        {
            if ( !Steamworks.Load() )
                return false;

            steamClient = Steamworks.CreateInterface<ISteamClient008>( "SteamClient008" );
            clientEngine = Steamworks.CreateInterface<IClientEngine>( "CLIENTENGINE_INTERFACE_VERSION001" );

            if ( steamClient == null )
                return false;

            if ( clientEngine == null )
                return false;

            return true;
        }
Example #8
0
        public bool GetSteamClient()
        {
            if ( !Steamworks.Load() )
                return false;

            steamClient = Steamworks.CreateInterface<ISteamClient008>( "SteamClient008" );
            clientEngine = Steamworks.CreateInterface<IClientEngine>( "CLIENTENGINE_INTERFACE_VERSION002" );

            if ( steamClient == null )
                return false;

            if ( clientEngine == null )
                return false;

            return true;
        }
Example #9
0
        /// <summary>
        ///     开始
        /// </summary>
        /// <param name="engine"></param>
        public static void Start(this IClientEngine engine)
        {
            if (Global.Profile)
            {
                engine.Goto(InterfaceType.Start);
            }
            else
            {
                engine.SignUp(Global.DevelopName, Global.DevelopPwd.Md532());
                engine.SignIn(Global.DevelopName, Global.DevelopPwd.Md532());
                if (!engine.LoadProfile(Global.DevelopProfileId))
                {
                    engine.CreateProfile(Global.DevelopProfileId);
                }

                engine.Goto(InterfaceType.Main);
            }
        }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="engine"></param>
 public static void Start(this IClientEngine engine)
 {
     if (Environment.Profile)
     {
         engine.Goto(InterfaceType.Start);
     }
     else
     {
         engine.SignUp(Environment.DevelopName, Environment.DevelopPwd.Md532());
         engine.SignIn(Environment.DevelopName, Environment.DevelopPwd.Md532());
         if (!engine.LoadProfile(Environment.DevelopProfileId))
         {
             engine.SaveProfile();
             engine.LoadProfile(Environment.DevelopProfileId);
         }
         engine.Goto(InterfaceType.Main);
     }
 }
Example #11
0
        private static bool ConnectToSteam()
        {
            var    steamError = new TSteamError();
            string errorText  = "";

            if (!Steamworks.Load(true))
            {
                errorText = "Steamworks failed to load.";
                Console.WriteLine(errorText);
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                errorText = "Steam startup failed. Is Steam running?";
                Console.WriteLine(errorText);
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                errorText = "Failed to create user pipe.";
                Console.WriteLine(errorText);
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                errorText = "Failed to connect to global user.";
                Console.WriteLine(errorText);
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Example #12
0
        private void GameForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            timer.Stop();

            ClientEngine.StopGame();
            ClientEngine.OnMapChanged -= OnMapChangeHandler;
            ClientEngine.OnTankDeath  -= OnTankDeath;
            ClientEngine.OnError      -= ErrorHandler;

            onMapChanged   -= onMapChangedProc;
            DeathAnimation -= onDeathAnimation;


            ClientEngine.onGameStart -= OnGameStart;
            ClientEngine.onDeath     -= onDeath;
            ClientEngine.onEndGame   -= OnEndGame;

            ClientEngine = null;
            Map          = null;
        }
Example #13
0
        public bool GetSteamClient()
        {
            if (!Steamworks.Load())
            {
                return(false);
            }

            steamClient  = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");
            clientEngine = Steamworks.CreateInterface <IClientEngine>("CLIENTENGINE_INTERFACE_VERSION001");

            if (steamClient == null)
            {
                return(false);
            }

            if (clientEngine == null)
            {
                return(false);
            }

            return(true);
        }
Example #14
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                lblError.Text = "Steamworks failed to load.";
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                lblError.Text = "Пожалуйста, включите программу Steam.";
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                lblError.Text = "Failed to create user pipe.";
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                lblError.Text = "Failed to connect to global user.";
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Example #15
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                throw new SteamException("Steamworks failed to load.");
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                throw new SteamException("Steam startup failed.");
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                throw new SteamException("Failed to create a pipe.");
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                throw new SteamException("Failed to connect to global user.");
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            return(true);
        }
Example #16
0
        public static int Main()
        {
            //Environment.SetEnvironmentVariable("SteamAppId", "730");

            Console.Write("Loading Steam2 and Steam3... ");

            if (Steamworks.Load(true))
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed");
                return(-1);
            }

            Console.WriteLine("\nSteam2 tests:");

            ISteam006 steam006 = Steamworks.CreateSteamInterface <ISteam006>();

            if (steam006 == null)
            {
                Console.WriteLine("steam006 is null !");
                return(-1);
            }


            TSteamError steamError = new TSteamError();


            Console.Write("GetVersion: ");
            StringBuilder version = new StringBuilder();

            if (steam006.GetVersion(version) != 0)
            {
                Console.WriteLine("Ok (" + version.ToString() + ")");
            }
            else
            {
                Console.WriteLine("Failed");
                return(-1);
            }

            steam006.ClearError(ref steamError);

            Console.Write("Startup: ");
            if (steam006.Startup(0, ref steamError) != 0)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed (" + steamError.szDesc + ")");
                return(-1);
            }

            Console.Write("OpenTmpFile: ");
            uint hFile = 0;

            if ((hFile = steam006.OpenTmpFile(ref steamError)) != 0)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed (" + steamError.szDesc + ")");
                return(-1);
            }

            Console.Write("WriteFile: ");
            byte[] fileContent = System.Text.UTF8Encoding.UTF8.GetBytes("test");
            if (steam006.WriteFile(fileContent, (uint)fileContent.Length, hFile, ref steamError) == fileContent.Length)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed (" + steamError.szDesc + ")");
                return(-1);
            }

            Console.Write("CloseFile: ");
            if (steam006.CloseFile(hFile, ref steamError) == 0)
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed (" + steamError.szDesc + ")");
                return(-1);
            }

            Console.WriteLine("\nSteam3 tests:");

            ISteamClient012 steamclient  = Steamworks.CreateInterface <ISteamClient012>();
            ISteamClient009 steamclient9 = Steamworks.CreateInterface <ISteamClient009>();

            if (steamclient == null)
            {
                Console.WriteLine("steamclient is null !");
                return(-1);
            }

            IClientEngine clientengine = Steamworks.CreateInterface <IClientEngine>();

            if (clientengine == null)
            {
                Console.WriteLine("clientengine is null !");
                return(-1);
            }

            Console.ReadKey();

            int pipe = steamclient.CreateSteamPipe();

            if (pipe == 0)
            {
                Console.WriteLine("Failed to create a pipe");
                return(-1);
            }

            int user = steamclient.ConnectToGlobalUser(pipe);

            if (user == 0 || user == -1)
            {
                Console.WriteLine("Failed to connect to global user");
                return(-1);
            }

            ISteamUser016 steamuser = steamclient.GetISteamUser <ISteamUser016>(user, pipe);

            if (steamuser == null)
            {
                Console.WriteLine("steamuser is null !");
                return(-1);
            }
            ISteamUtils005 steamutils = steamclient.GetISteamUtils <ISteamUtils005>(pipe);

            if (steamutils == null)
            {
                Console.WriteLine("steamutils is null !");
                return(-1);
            }
            ISteamUserStats002 userstats002 = steamclient.GetISteamUserStats <ISteamUserStats002>(user, pipe);

            if (userstats002 == null)
            {
                Console.WriteLine("userstats002 is null !");
                return(-1);
            }
            ISteamUserStats010 userstats010 = steamclient.GetISteamUserStats <ISteamUserStats010>(user, pipe);

            if (userstats010 == null)
            {
                Console.WriteLine("userstats010 is null !");
                return(-1);
            }
            IClientUser clientuser = clientengine.GetIClientUser <IClientUser>(user, pipe);

            if (clientuser == null)
            {
                Console.WriteLine("clientuser is null !");
                return(-1);
            }
            IClientFriends clientfriends = clientengine.GetIClientFriends <IClientFriends>(user, pipe);

            if (clientfriends == null)
            {
                Console.WriteLine("clientfriends is null !");
                return(-1);
            }

            //Console.Write("RequestCurrentStats: ");
            //if (userstats002.RequestCurrentStats(steamutils.GetAppID()))
            //{
            //    Console.WriteLine("Ok");
            //}
            //else
            //{
            //    Console.WriteLine("Failed");
            //    return -1;
            //}

            uint a = steam006.RequestAccountsByEmailAddressEmail("*****@*****.**", ref steamError);

            //Console.WriteLine(steamError.nDetailedErrorCode);
            //Console.ReadLine();

            Console.Write("Waiting for stats... ");

            CallbackMsg_t callbackMsg   = new CallbackMsg_t();
            bool          statsReceived = false;

            while (!statsReceived)
            {
                while (Steamworks.GetCallback(pipe, ref callbackMsg) && !statsReceived)
                {
                    Console.WriteLine(callbackMsg.m_iCallback);
                    if (callbackMsg.m_iCallback == UserStatsReceived_t.k_iCallback)
                    {
                        UserStatsReceived_t userStatsReceived = (UserStatsReceived_t)Marshal.PtrToStructure(callbackMsg.m_pubParam, typeof(UserStatsReceived_t));
                        if (userStatsReceived.m_steamIDUser == steamuser.GetSteamID() && userStatsReceived.m_nGameID == steamutils.GetAppID())
                        {
                            if (userStatsReceived.m_eResult == EResult.k_EResultOK)
                            {
                                Console.WriteLine("Ok");
                                statsReceived = true;
                            }
                            else
                            {
                                Console.WriteLine("Failed (" + userStatsReceived.m_eResult + ")");
                                return(-1);
                            }
                        }
                    }
                    Steamworks.FreeLastCallback(pipe);
                }
                System.Threading.Thread.Sleep(100);
            }

            Console.WriteLine("Stats for the current game :");
            uint numStats = userstats002.GetNumStats(steamutils.GetAppID());

            for (uint i = 0; i < numStats; i++)
            {
                string             statName = userstats002.GetStatName(steamutils.GetAppID(), i);
                ESteamUserStatType statType = userstats002.GetStatType(steamutils.GetAppID(), statName);
                switch (statType)
                {
                case ESteamUserStatType.k_ESteamUserStatTypeINT:
                {
                    int value = 0;
                    Console.Write("\t" + statName + " ");
                    if (userstats002.GetStat(steamutils.GetAppID(), statName, ref value))
                    {
                        Console.WriteLine(value);
                    }
                    else
                    {
                        Console.WriteLine("Failed");
                        return(-1);
                    }

                    break;
                }

                case ESteamUserStatType.k_ESteamUserStatTypeFLOAT:
                {
                    float value = 0;
                    Console.Write("\t" + statName + " ");
                    if (userstats002.GetStat(steamutils.GetAppID(), statName, ref value))
                    {
                        Console.WriteLine(value);
                    }
                    else
                    {
                        Console.WriteLine("Failed");
                        return(-1);
                    }
                    break;
                }
                }
            }

            Console.Write("GetNumberOfCurrentPlayers: ");
            ulong getNumberOfCurrentPlayersCall = userstats010.GetNumberOfCurrentPlayers();
            bool  failed = false;

            while (!steamutils.IsAPICallCompleted(getNumberOfCurrentPlayersCall, ref failed) && !failed)
            {
                System.Threading.Thread.Sleep(100);
            }

            if (failed)
            {
                Console.WriteLine("Failed (IsAPICallCompleted failure)");
                return(-1);
            }

            IntPtr pData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NumberOfCurrentPlayers_t)));

            if (!Steamworks.GetAPICallResult(pipe, getNumberOfCurrentPlayersCall, pData, Marshal.SizeOf(typeof(NumberOfCurrentPlayers_t)), NumberOfCurrentPlayers_t.k_iCallback, ref failed))
            {
                Console.WriteLine("Failed (GetAPICallResult failure: " + steamutils.GetAPICallFailureReason(getNumberOfCurrentPlayersCall) + ")");
                return(-1);
            }

            NumberOfCurrentPlayers_t numberOfCurrentPlayers = (NumberOfCurrentPlayers_t)Marshal.PtrToStructure(pData, typeof(NumberOfCurrentPlayers_t));

            if (!System.Convert.ToBoolean(numberOfCurrentPlayers.m_bSuccess))
            {
                Console.WriteLine("Failed (numberOfCurrentPlayers.m_bSuccess is false)");
                return(-1);
            }
            Console.WriteLine("Ok (" + numberOfCurrentPlayers.m_cPlayers + ")");

            Marshal.FreeHGlobal(pData);


            //Console.Write("Games running: ");
            //for(int i = 0; i < clientuser.NumGamesRunning(); i++)
            //{
            //    CGameID gameID = clientuser.GetRunningGameID(i);
            //    Console.Write(gameID);
            //    if(i + 1 < clientuser.NumGamesRunning())
            //        Console.Write(", ");
            //    else
            //        Console.Write("\n");
            //}

            Console.WriteLine("Current user SteamID: " + steamuser.GetSteamID());

            FriendSessionStateInfo_t sessionStateInfo = clientfriends.GetFriendSessionStateInfo(clientuser.GetSteamID());

            clientfriends.SetPersonaState(EPersonaState.k_EPersonaStateAway);

            Console.WriteLine("m_uiOnlineSessionInstances: " + sessionStateInfo.m_uiOnlineSessionInstances);
            Console.WriteLine("m_uiPublishedToFriendsSessionInstance: " + sessionStateInfo.m_uiPublishedToFriendsSessionInstance);

            Console.Write("RequestFriendProfileInfo: ");
            ulong requestFriendProfileInfoCall = clientfriends.RequestFriendProfileInfo(steamuser.GetSteamID());

            while (!steamutils.IsAPICallCompleted(requestFriendProfileInfoCall, ref failed) && !failed)
            {
                System.Threading.Thread.Sleep(100);
            }

            if (failed)
            {
                Console.WriteLine("Failed (IsAPICallCompleted failure)");
                return(-1);
            }

            pData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FriendProfileInfoResponse_t)));

            if (!Steamworks.GetAPICallResult(pipe, requestFriendProfileInfoCall, pData, Marshal.SizeOf(typeof(FriendProfileInfoResponse_t)), FriendProfileInfoResponse_t.k_iCallback, ref failed))
            {
                Console.WriteLine("Failed (GetAPICallResult failure: " + steamutils.GetAPICallFailureReason(requestFriendProfileInfoCall) + ")");
                return(-1);
            }

            FriendProfileInfoResponse_t friendProfileInfoResponse = (FriendProfileInfoResponse_t)Marshal.PtrToStructure(pData, typeof(FriendProfileInfoResponse_t));

            if (friendProfileInfoResponse.m_eResult != EResult.k_EResultOK)
            {
                Console.WriteLine("Failed (friendProfileInfoResponse.m_eResult = " + friendProfileInfoResponse.m_eResult + ")");
                return(-1);
            }
            if (friendProfileInfoResponse.m_steamIDFriend == clientuser.GetSteamID())
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed (SteamIDs doesn't match)");
            }

            Marshal.FreeHGlobal(pData);

            return(0);
        }
Example #17
0
        public bool GetSteamClient()
        {
            if ( !Steamworks.Load () )
                return false;

            steamClient = Steamworks.CreateInterface<ISteamClient008> ( "SteamClient008" );
            clientEngine = Steamworks.CreateInterface<IClientEngine> ( "CLIENTENGINE_INTERFACE_VERSION002" );

            // This is a one minute timer so the !commands can't be spammed in chat
            sixtysec = DateTime.Now;

            Program.parsetoChewie ( "Chewiebot started at: " + sixtysec.ToString() );
            if ( steamClient == null )
                return false;

            if ( clientEngine == null )
                return false;

            return true;
        }
Example #18
0
 /// <summary>
 ///     停止
 /// </summary>
 /// <param name="engine"></param>
 public static void Stop(this IClientEngine engine)
 {
 }
Example #19
0
        public GameForm(IClientEngine clientEngine, Size size)
        {
            ClientEngine = clientEngine;

            ClientEngine.OnMapChanged += OnMapChangeHandler;
            ClientEngine.OnTankDeath  += OnTankDeath;
            ClientEngine.OnError      += ErrorHandler;
            //добавились из мастера
            ClientEngine.onGameStart += OnGameStart;
            ClientEngine.onDeath     += onDeath;
            ClientEngine.onEndGame   += OnEndGame;


            Endgame        += _EndGame;
            Ondeath        += _onDeath;
            GameStart      += _GameStart;
            onMapChanged   += onMapChangedProc;
            DeathAnimation += onDeathAnimation;

            Enemies = new Dictionary <Direction, Bitmap>()
            {
                { Direction.Down, Resources.enemy_down },
                { Direction.Left, Resources.enemy_left },
                { Direction.Right, Resources.enemy_right },
                { Direction.Up, Resources.enemy_up },
            };

            Player = new Dictionary <Direction, Bitmap>()
            {
                { Direction.Down, Resources.player_down },
                { Direction.Left, Resources.player_left },
                { Direction.Right, Resources.player_right },
                { Direction.Up, Resources.player_up },
            };

            Blocks = new Dictionary <BlockType, Bitmap>
            {
                { BlockType.Brick, Resources.wall2 },
                { BlockType.Brick2, Resources.wall1 },
                { BlockType.Concrete, Resources.wall3 },
                { BlockType.Tree, Resources.tree },
                { BlockType.Health, Resources.life2 },
                { BlockType.Mine, Resources.Mine },
            };

            ExplImages = new List <Bitmap>()
            {
                Resources.explosion1,
                Resources.explosion2,
                Resources.explosion3,
                Resources.explosion4,
                Resources.explosion5,
                Resources.explosion6,
                Resources.explosion7,
                Resources.explosion8,
                Resources.explosion9,
                Resources.explosion10,
                Resources.explosion11,
                Resources.explosion12,
                Resources.explosion13,
                Resources.explosion14
            };


            InitializeComponent();

            this.ClientSize = size;
            this.BackColor  = Color.Black;

            //KeysDown = new Queue<KeyEventArgs>();
            CanSoot        = true;
            locker         = true;
            timer          = new Timer();
            timer.Tick    += (i, s) => { lock (locker) CanSoot = true; };
            timer.Interval = 1000;
            timer.Enabled  = true;

            Message.Text     = "Wating for other players..";
            Message.Location = new Point(
                ClientSize.Width / 2 - Message.Size.Width / 2,
                ClientSize.Height / 2 - Message.Size.Height);

            ToLobby_btn.Visible = false;
            ToLobby_btn.Enabled = false;

            WatchGame_btn.Visible  = false;
            WatchGame_btn.Enabled  = false;
            WatchGame_btn.Location = new Point(
                ClientSize.Width / 2 + 5,
                ClientSize.Height / 2 + 30);
        }
 public ClientEntities(IClientEngine clientEngine, ITime engineTime, IEngineModels engineModels)
 {
     _clientEngine = clientEngine ?? throw new ArgumentNullException(nameof(clientEngine));
     _engineTime   = engineTime ?? throw new ArgumentNullException(nameof(engineTime));
     _engineModels = engineModels ?? throw new ArgumentNullException(nameof(engineModels));
 }
        public bool GetSteamClient()
        {
            if (!Steamworks.Load())
                return false;

            steamClient = Steamworks.CreateInterface<ISteamClient008>(steamClientVersion);
            clientEngine = Steamworks.CreateInterface<IClientEngine>(clientEngineVersion);

            if (steamClient == null)
                return false;

            if (clientEngine == null)
                return false;

            Program.logToWindow("Successfully found the steam client");

            return true;
        }
Example #22
0
        private int LoadSteam()
        {
            if (Steamworks.Load(true))
            {
                Console.WriteLine("Ok, Steam Works!");
            }
            else
            {
                MessageBox.Show("Failed, Steam Works!");
                Console.WriteLine("Failed, Steam Works!");

                return(-1);
            }

            steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            TSteamError steamError = new TSteamError();

            version = new StringBuilder();
            steam006.ClearError(ref steamError);

            steamclient  = Steamworks.CreateInterface <ISteamClient012>();
            clientengine = Steamworks.CreateInterface <IClientEngine>();
            pipe         = steamclient.CreateSteamPipe();
            user         = steamclient.ConnectToGlobalUser(pipe);
            steamuser    = steamclient.GetISteamUser <ISteamUser016>(user, pipe);

            steamutils      = steamclient.GetISteamUtils <ISteamUtils005>(pipe);
            userstats002    = steamclient.GetISteamUserStats <ISteamUserStats002>(user, pipe);
            userstats010    = steamclient.GetISteamUserStats <ISteamUserStats010>(user, pipe);
            steamfriends013 = steamclient.GetISteamFriends <ISteamFriends013>(user, pipe);
            steamfriends002 = steamclient.GetISteamFriends <ISteamFriends002>(user, pipe);
            clientuser      = clientengine.GetIClientUser <IClientUser>(user, pipe);
            clientfriends   = clientengine.GetIClientFriends <IClientFriends>(user, pipe);

            Console.WriteLine("\nSteam2 tests:");


            if (steam006 == null)
            {
                Console.WriteLine("steam006 is null !");
                return(-1);
            }


            Console.Write("GetVersion: ");


            if (steam006.GetVersion(version, (uint)version.Capacity) != 0)
            {
                Console.WriteLine("Ok (" + version.ToString() + "), Version!");
            }
            else
            {
                Console.WriteLine("Failed, Get Version!");
                return(-1);
            }

            Console.WriteLine("\nSteam3 tests:");


            if (steamclient == null)
            {
                Console.WriteLine("steamclient is null !");
                return(-1);
            }


            if (clientengine == null)
            {
                Console.WriteLine("clientengine is null !");
                return(-1);
            }


            if (pipe == 0)
            {
                Console.WriteLine("Failed to create a pipe");
                return(-1);
            }


            if (user == 0 || user == -1)
            {
                Console.WriteLine("Failed to connect to global user");
                return(-1);
            }


            if (steamuser == null)
            {
                Console.WriteLine("steamuser is null !");
                return(-1);
            }

            if (steamutils == null)
            {
                Console.WriteLine("steamutils is null !");
                return(-1);
            }

            if (userstats002 == null)
            {
                Console.WriteLine("userstats002 is null !");
                return(-1);
            }

            if (userstats010 == null)
            {
                Console.WriteLine("userstats010 is null !");
                return(-1);
            }

            if (steamfriends013 == null)
            {
                Console.WriteLine("steamfriends013 is null !");
                return(-1);
            }

            if (clientuser == null)
            {
                Console.WriteLine("clientuser is null !");
                return(-1);
            }

            if (clientfriends == null)
            {
                Console.WriteLine("clientfriends is null !");
                return(-1);
            }

            if (steamfriends002 == null)
            {
                Console.WriteLine("steamfriends002 is nulll!");
                return(-1);
            }

            Console.Write("RequestCurrentStats: ");
            if (userstats002.RequestCurrentStats(steamutils.GetAppID()))
            {
                Console.WriteLine("Ok");
            }
            else
            {
                Console.WriteLine("Failed");
                return(-1);
            }


            return(0);
        }