Beispiel #1
0
 public FakeSenderWithGameApplication(GameApplication gameApplication, Dictionary <byte, object> roomProperties, Func <Dictionary <byte, object>, GameApplication, Guid, Guid> createRoomDelegate, Action <Guid, GameApplication> updateRoomDelegate)
 {
     _gameApplication    = gameApplication;
     _roomProperties     = roomProperties;
     _createRoomDelegate = createRoomDelegate;
     _updateRoomDelegate = updateRoomDelegate;
 }
        private void Client_OnMessage(object sender, MessageEventArgs e)
        {
            GameApplication.Log(Utils.LogEntryType.Connection, "Received message: " + e.Data);
            string[] splitPacketBase = e.Data.Split(':');
            if (splitPacketBase[0] == "$CGENG#PACKET" && splitPacketBase[2] == "PACKETEND")
            {
                string[] splitPacket    = splitPacketBase[1].Split('@');
                string   packetType     = splitPacket[0];
                string   packetContents = splitPacket[1];
                switch (packetType)
                {
                case "INITIALIZEHANDSHAKE":
                    OnInitializeHandshake?.Invoke(this, null);
                    break;

                case "REQOBJECTSIDSRESPONSE":
                    if (_gameWindow.CurrentScene != null)
                    {
                        string[] objectData = packetContents.Split('=');
                        foreach (var nObject in _gameWindow.CurrentScene.Controls.OfType <NetworkGameObject>())
                        {
                            if (nObject.InternalName == objectData[0] && nObject.NetworkObjectName == objectData[1] && nObject.Id == int.Parse(objectData[2]))
                            {
                                nObject.NetworkId = int.Parse(objectData[3]);
                            }
                        }
                    }
                    break;
                }
            }
        }
Beispiel #3
0
    public void ReStart()
    {
        ReInitLuaBytecode();
        GameApplication apl = GameObject.Find("UI Root").GetComponent <GameApplication>();

        apl.ReStart();
    }
Beispiel #4
0
        public void Load()
        {
            if (!IsLoaded)
            {
                bool isNewSave = false;
                PlayerCharacterObject playerCharacter = GetComponent <PlayerCharacterObject>();
                GameApplication       application     = nebulaObject.mmoWorld().application;
                QuestSave             questSave       = QuestDatabase.instance(application).LoadQuests(playerCharacter.characterId, out isNewSave);

                completedQuests.Clear();
                foreach (string cQuest in questSave.CompletedQuests)
                {
                    completedQuests.Add(cQuest);
                }

                startedQuests.Clear();
                foreach (Hashtable sQuest in questSave.StartedQuests)
                {
                    QuestInfo questInfo = new QuestInfo(this);
                    questInfo.ParseInfo(sQuest);
                    if (questInfo.IsValid)
                    {
                        startedQuests.Add(questInfo);
                    }
                }

                questVariables.Clear();
                foreach (DictionaryEntry entry in questSave.QuestVariables)
                {
                    questVariables.TryAdd(entry.Key.ToString(), entry.Value);
                }

                IsLoaded = true;
            }
        }
Beispiel #5
0
 public App()
 {
     _app = new GameApplication(
         new XFInputManager(_gamePage = new GamePage()),
         new XFLocalStorageManager());
     MainPage = _gamePage;
 }
Beispiel #6
0
    private void Awake()
    {
        mIP       = transform.Find("ip").GetComponent <InputField>();
        mTCP      = transform.Find("tcp").GetComponent <InputField>();
        mUDP      = transform.Find("udp").GetComponent <InputField>();
        mPlayer   = transform.Find("player").GetComponent <Text>();
        mFrame    = transform.Find("frame").GetComponent <Text>();
        mProtocol = transform.Find("protocol").GetComponent <Text>();
        mPing     = transform.Find("ping").GetComponent <Text>();


        mIP.text  = GameApplication.GetSingleton().ip;
        mTCP.text = GameApplication.GetSingleton().tcpPort.ToString();
        mUDP.text = GameApplication.GetSingleton().udpPort.ToString();


        mConnect = transform.Find("connect");
        mReady   = transform.Find("ready");
        mSkill1  = transform.Find("skill1");
        mSkill2  = transform.Find("skill2");
        mSkill3  = transform.Find("skill3");
        mTop     = transform.Find("top");
        mItem    = transform.Find("top/item");

        mReady.gameObject.SetActive(false);
        mPlayer.gameObject.SetActive(false);
        mFrame.gameObject.SetActive(false);
        mProtocol.gameObject.SetActive(false);
        mPing.gameObject.SetActive(false);
        mItem.gameObject.SetActive(false);


        RegisterReceiver();
    }
 public void Start()
 {
     pieces.Load();
     newPiece(this, new ListOfBlockEventArgs(pieces.Get()));
     Time  = 0.0f;
     speed = GameApplication.GetOptions().SpeedFlt;
 }
Beispiel #8
0
        public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType);
            }

            this.Application = application;
            this.LobbyName = lobbyName;
            this.MaxPlayersDefault = maxPlayersDefault;
            this.JoinTimeOut = joinTimeOut;

            switch (lobbyType)
            {
                default:
                    this.GameList = new GameList(this);
                    break;

                case AppLobbyType.ChannelLobby:
                    this.GameList = new GameChannelList(this);
                    break;

                case AppLobbyType.SqlLobby:
                    this.GameList = new SqlGameList(this);
                    break;
            }

            this.ExecutionFiber = new PoolFiber();
            this.ExecutionFiber.Start();
        }
Beispiel #9
0
        public void Update(PlayerEventData eventData)
        {
            lock (GameApplication.GetInstance().SFMLLock)
            {
                //OurLogger.Log($"Got event {eventData}");
                GameApplication.defaultLogger.LogMessage(20, $"Got event {eventData}");

                if (!scores.ContainsKey(eventData.Shooter))
                {
                    scores.Add(eventData.Shooter, new CustomText(2 * 7));
                }

                if (!scores.ContainsKey(eventData.Victim))
                {
                    scores.Add(eventData.Victim, new CustomText(2 * 7));
                }

                try
                {
                    scores[eventData.Victim].DisplayedString  = $"{eventData.Victim.Name} {eventData.Victim.Kills}/{eventData.Victim.Deaths}";
                    scores[eventData.Shooter].DisplayedString = $"{eventData.Shooter.Name} {eventData.Shooter.Kills}/{eventData.Shooter.Deaths}";
                }
                catch { }
            }
        }
Beispiel #10
0
        public void Send(string name, string password, GameApplication gameNow)
        {
            if (game == null)
            {
                game = gameNow;
            }
            else
            {
                if (game != gameNow)
                {
                    throw new ArgumentException("Users chouse different games!");
                }
            }

            var  connectionID  = Context.ConnectionId;
            bool alreadyExists = Users.Any(x => x.Name == name && x.Password == password);

            if (!alreadyExists)
            {
                Users.Add(new CurrentUser()
                {
                    Name = name, ConnectionID = connectionID, Password = password
                });
            }
        }
Beispiel #11
0
        public MmoWorld(string name, Vector minCorner, Vector maxCorner, Vector tileDimensions, Res resource, GameApplication app)
            : base(minCorner, maxCorner, tileDimensions, new MmoItemCache())
        {
            try
            {
                m_App = app;
                log.InfoFormat("world = {0} cons()", name);

                this.resource  = resource;
                this.name      = name;
                this.zone      = (Resource().Zones.ExistZone(this.name) ? Resource().Zones.Zone(this.name) : Resource().Zones.Default(this.name));
                this.ownedRace = (this.zone != null) ? this.zone.InitiallyOwnedRace : Race.None;
                underAttack    = false;

                this.InitializeNpcGroups(Resource());
                asteroidManager     = new WorldAsteroidManager(this);
                npcManager          = new WorldNpcManager(this);
                nebulaObjectManager = new MmoWorldNebulaObjectManager(this);

                log.InfoFormat("base init completed");

                m_Cells.Setup(this);

                //load world info from database
                LoadWorldInfo();
                LoadWorldState();
            }
            catch (System.Exception eee)
            {
                CL.Out(LogFilter.WORLD, "Exception in world constructor");
                CL.Out(eee.Message);
                CL.Out(eee.StackTrace);
            }
        }
Beispiel #12
0
        public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType);
            }

            this.Application       = application;
            this.LobbyName         = lobbyName;
            this.MaxPlayersDefault = maxPlayersDefault;
            this.JoinTimeOut       = joinTimeOut;

            switch (lobbyType)
            {
            default:
                this.GameList = new GameList(this);
                break;

            case AppLobbyType.ChannelLobby:
                this.GameList = new GameChannelList(this);
                break;

            case AppLobbyType.SqlLobby:
                this.GameList = new SqlGameList(this);
                break;
            }

            this.ExecutionFiber = new PoolFiber();
            this.ExecutionFiber.Start();
        }
Beispiel #13
0
	public static void Execute(RequestFinishQuestQuestUserCmd_CS cmd)
	{
		var role = Role.All[cmd.charid];
		if (role == null)
			return;
		GameApplication.PlayEffect("Prefabs/Models/Effect/wanchengrenwu", role.transform);
	}
Beispiel #14
0
        private AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut, bool?useLegacyLobbies, int?limitGameList, int?limitGameListUpdate, int?limitSqlFilterResults, string matchmakingStoredProcedure = null)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType);
                string limitGameListStr = limitGameList != null?limitGameList.ToString() : "null";

                string useLegacylobbiesStr = useLegacyLobbies != null?useLegacyLobbies.ToString() : "null";

                string limitGameListUpdateStr = limitGameListUpdate != null?limitGameListUpdate.ToString() : "null";

                string limitSqlFilterResultsStr = limitSqlFilterResults != null?limitSqlFilterResults.ToString() : "null";

                log.DebugFormat("AppLobby - useLegacyLobbies {0}, limitGameList {1}, limitGameListUpdate {2}, limitSqlFilterResults {3}",
                                useLegacylobbiesStr, limitGameListStr, limitGameListUpdateStr, limitSqlFilterResultsStr);
                log.DebugFormat("MasterServerSettings - useLegacyLobbies {0}, limitGameList {1}, limitGameListUpdate {2}," +
                                " limitSqlFilterResults {3}",
                                MasterServerSettings.Default.UseLegacyLobbies, MasterServerSettings.Default.LimitGameList,
                                MasterServerSettings.Default.LimitGameListUpdate, MasterServerSettings.Default.LimitSqlFilterResults);
            }

            this.Application       = application;
            this.LobbyName         = lobbyName;
            this.LobbyType         = lobbyType;
            this.MaxPlayersDefault = maxPlayersDefault;
            this.JoinTimeOut       = joinTimeOut;
            this.gameListLimit     = limitGameList.HasValue ? limitGameList.Value : MasterServerSettings.Default.GameListLimit;

            application.IncrementLobbiesCount();

            if (MasterServerSettings.Default.GameChangesPublishInterval > 0)
            {
                this.gameChangesPublishInterval = MasterServerSettings.Default.GameChangesPublishInterval;
            }

            switch (lobbyType)
            {
            default:
                this.GameList = new LimitedGameList(this, useLegacyLobbies, limitGameList, limitGameListUpdate);
                break;

            case AppLobbyType.ChannelLobby:
                this.GameList = new GameChannelList(this);
                break;

            case AppLobbyType.SqlLobby:
                this.GameList = new SqlFilterGameList(this, useLegacyLobbies, limitSqlFilterResults, matchmakingStoredProcedure);
                break;

            case AppLobbyType.AsyncRandomLobby:
                this.GameList = new AsyncRandomGameList(this);
                break;
            }

            InitUpdateLobbyLimits(application);
            InitUpdateMatchmakingStoredProcedure(application);

            this.ExecutionFiber = new PoolFiber();
            this.ExecutionFiber.Start();
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("ENTER TO CONTINUE TO NEXT PATTERN..\n1 = Factory Method\n2 = Singleton");
            List <Car> cars = new List <Car>();

            CarFactory factory = new CarFactory();

            cars.Add(factory.GetCar(CarType.Compact, "Peugotje", "Peugot"));
            cars.Add(factory.GetCar(CarType.Motorcycle, "Hondatje", "Honda"));
            cars.Add(factory.GetCar(CarType.Sports, "Lambotje", "Lambo"));

            foreach (Car c in cars)
            {
                Console.WriteLine(c);
                Console.WriteLine(c.Sound() + "\n");
            }
            Console.ReadLine();

            GameApplication appl = GameApplication.GetInstance();

            appl.Name = "Pakimon Go";
            Console.WriteLine(appl);
            //Using the default constructor doesn't work for the GameApplication class! Neither does inheriting from this class work.

            Console.ReadLine();
            AppleFactory appleFactory = new AppleFactory();

            Console.WriteLine(appleFactory.GetFood());
            BananaFactory bananaFactory = new BananaFactory();

            Console.WriteLine(bananaFactory.GetFood());

            Console.ReadLine();
        }
Beispiel #16
0
 public MmoPeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer, GameApplication application)
     : base(rpcProtocol, nativePeer)
 {
     Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
     this.application = application;
     this.SetCurrentOperationHandler(this);
 }
        public static MmApplication GetMm(ushort mmPort, ushort gamePort, GameApplication gameApplication, int maximumPlayers = 2, int mmTime = 10000, int ddosConnectionsLevel = 300, int ddosConnectionCheckInterval = 5000)
        {
            var socketFactory = new LiteNetSockFactory();
            var serializer    = new BinarySerializer();
            var serverLogger  = new ConsoleLogger("M ", LogLevel.Error | LogLevel.Info | LogLevel.Debug);

            var config = new ApplicationConfig
            {
                PublicDomainNameOrAddress = "127.0.0.1",
                ListenPorts = new List <ushort> {
                    mmPort
                },
                BindToPortHttp               = 7002,
                MaxPacketSize                = 300,
                BasePacketBufferSize         = 64,
                SendTickTimeMs               = 20,
                SocketTickTimeMs             = 10,
                SocketType                   = SocketType.BareSocket,
                ReceiveTickTimeMs            = 20,
                IsConnectionDdosProtectionOn = false
            };
            var roomPropertiesProvider = new FakeRoomPropertiesProvider3(250, maximumPlayers, mmTime);
            var taskSchedulerFactory   = new TaskSchedulerFactory(serverLogger);
            var requestSender          = new FakeSenderWithGameApplication(gameApplication, new Dictionary <byte, object> {
                { PropertyCode.RoomProperties.GameMode, (byte)GameMode.SinglePlayer }
            }, CreateRoomDelegate, UpdateRoomDelegate);

            var _mmPacketSender = new PacketBatchSender(taskSchedulerFactory, config, serverLogger);

            var _playerManager = new PlayersManager(Mock.Of <IMmMetrics>(), serverLogger);

            //_serverProvider = new MatchMakerServerInfoProvider(requestSender, taskSchedulerFactory, config, _serverLogger, _statsProvider);
            var _serverProvider = new FakeMatchMakerServerInfoProvider(requestSender, "127.0.0.1", $"{gamePort}");
            var roomApiProvider = new DefaultRoomApiProvider(requestSender, serverLogger);
            var _mmRoomManager  =
                new MM.Managers.RoomManager(_serverProvider, serverLogger, taskSchedulerFactory, roomApiProvider);

            var sender          = GetSHamanMessageSender(serializer, _mmPacketSender, config, serverLogger);
            var _mmGroupManager = new MatchMakingGroupManager(serverLogger, taskSchedulerFactory, _playerManager,
                                                              sender, Mock.Of <IMmMetrics>(), _mmRoomManager, roomPropertiesProvider, config);

            var matchMaker = new MatchMaker(_playerManager, _mmGroupManager);

            //
            // var _measures = new Dictionary<byte, object>();
            // _measures.Add(FakePropertyCodes.PlayerProperties.Level, 1);
            // matchMaker.AddMatchMakingGroup(_measures);
            matchMaker.AddRequiredProperty(FakePropertyCodes.PlayerProperties.Level);

            var senderFactory            = new ShamanMessageSenderFactory(serializer, config);
            var protectionManagerConfig  = new ConnectionDdosProtectionConfig(ddosConnectionsLevel, ddosConnectionCheckInterval, 5000, 60000);
            var connectionDdosProtection = new ConnectDdosProtection(protectionManagerConfig, taskSchedulerFactory, serverLogger);
            var protectionManager        = new ProtectionManager(connectionDdosProtection, protectionManagerConfig, serverLogger);

            //setup mm server
            return(new MmApplication(serverLogger, config, serializer, socketFactory, matchMaker,
                                     requestSender, taskSchedulerFactory, _mmPacketSender, senderFactory, _serverProvider, _mmRoomManager,
                                     _mmGroupManager, _playerManager, Mock.Of <IMmMetrics>(), protectionManager));
        }
Beispiel #18
0
 public static DialogDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new DialogDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #19
0
 public static ServerRuntimeStats Default(GameApplication app)
 {
     if (stats == null)
     {
         stats = new ServerRuntimeStats(app);
     }
     return(stats);
 }
Beispiel #20
0
 public static InventoryDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new InventoryDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #21
0
 public override void OnCollision(GameObject gameObject)
 {
     base.OnCollision(gameObject);
     if (gameObject == collidableObj)
     {
         GameApplication.Log(LogEntryType.Info, "Collided with object");
     }
 }
Beispiel #22
0
 public static TimedEffectsDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new TimedEffectsDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #23
0
 private ShipModelDatabase(GameApplication app)
 {
     m_App = app;
     //DbClient = new MongoClient(connectionString);
     //DbServer = DbClient.GetServer();
     //Database = DbServer.GetDatabase(GameServerSettings.Default.DatabaseName);
     ShipModelDocuments = m_App.defaultDatabase.GetCollection <ShipModelDocument>(GameServerSettings.Default.DatabaseShipModelCollectionName);
 }
Beispiel #24
0
 public override void OnCollide(GameObject collidedObject)
 {
     GameApplication.Log(LogEntryType.Info, this.InternalName + " Collided with " + collidedObject.InternalName, true);
     if (collidedObject.InternalName == "obj2")
     {
         Game.scene.RemoveGameObject(this);
     }
 }
Beispiel #25
0
 public static AchievmentDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new AchievmentDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #26
0
 public static ShipModelDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new ShipModelDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #27
0
 public static ContractDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new ContractDatabase(app);
     }
     return(s_Instance);
 }
 public PassiveBonusesDatabase(GameApplication app)
 {
     m_App = app;
     //DbClient = new MongoClient(connectionString);
     //DbServer = DbClient.GetServer();
     //Database = DbServer.GetDatabase(GameServerSettings.Default.DatabaseName);
     collection = m_App.defaultDatabase.GetCollection <PassiveBonusesDocument>(GameServerSettings.Default.PassiveBonusesCollectionName);
 }
Beispiel #29
0
 private StationDatabase(GameApplication app)
 {
     //DbClient = new MongoClient(connectionString);
     //DbServer = DbClient.GetServer();
     //Database = DbServer.GetDatabase(GameServerSettings.Default.DatabaseName);
     m_App            = app;
     StationDocuments = m_App.defaultDatabase.GetCollection <WorkshopDocument>(GameServerSettings.Default.DatabaseWorkshopCollectionName);
 }
 public static PassiveBonusesDatabase instance(GameApplication app)
 {
     if (s_Instance == null)
     {
         s_Instance = new PassiveBonusesDatabase(app);
     }
     return(s_Instance);
 }
Beispiel #31
0
 public GameUpdater(GameApplication app)
 {
     application = app;
     log.InfoFormat("Updater created!!");
     m_CheckFiber = new PoolFiber();
     m_CheckFiber.Start();
     m_CheckLoop = m_CheckFiber.ScheduleOnInterval(CheckUpdate, 15000, 15000);
 }
 public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType)
 {
     this.application = application;
     this.defaultLobby = new AppLobby(this.application, string.Empty, defaultLobbyType);
 }
Beispiel #33
0
		/// <summary>
		/// Initializes the specified app.
		/// </summary>
		/// <param name="app">The app.</param>
		public virtual void Initialize(GameApplication app)
		{
			InitializeSelf(app);
			InitializeChildren(app);

			Initialized = true;
		}
Beispiel #34
0
		/// <summary>
		/// Initializes the self.
		/// </summary>
		/// <param name="app">The app.</param>
		protected virtual void InitializeSelf(GameApplication app)
		{
		}
Beispiel #35
0
		/// <summary>
		/// Initializes the children.
		/// </summary>
		/// <param name="app">The app.</param>
		protected virtual void InitializeChildren(GameApplication app)
		{
			foreach (IGameComponent child in Children) {
				child.GameApplication = GameApplication;
				child.GameVariables = GameVariables;
				child.StateVariables = StateVariables;
				child.Initialize(app);
			}
		}
Beispiel #36
0
		/// <summary>
		/// Runs the specified app.
		/// </summary>
		/// <param name="app">The app.</param>
		public abstract void Run(GameApplication app);
Beispiel #37
0
 public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType)
 {
     this.application = application;
     this.defaultLobbyType = defaultLobbyType;
 }
Beispiel #38
0
 public LobbyFactory(GameApplication application)
     : this(application, AppLobbyType.Default)
 {
 }
Beispiel #39
0
 public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType)
     : this(application, lobbyName, lobbyType, 0, TimeSpan.FromSeconds(15))
 {
 }