Exemple #1
0
        public GameLogic()
        {
            GameSettingsWrapper wrapper = GlobalSettings.Wrapper;
            Map map = new Map();

            map.LoadMap(Path.Combine(Settings.Default.Maps, ClientPlayerInfo.GameInfo.MapName));

            for (int i = 0; i < _definedGroups.Length; i++)
            {
                _definedGroups[i] = new List <Unit>();
            }
            GameMessageHandler.Instance.GameMessageReceive += new GameMessageEventHandler(Instance_GameMessageReceive);
            GameMessageHandler.Instance.DoTurnPermission   += new DoTurnEventHandler(Instance_DoTurnPermission);
            GameMessageHandler.Instance.GameInitialization += new GameInitEventHandler(Instance_GameInitialization);
            GameMessageHandler.Instance.PlayerDisconnected += new PlayerDisconnectedHandler(Instance_PlayerDisconnected);
            _sim            = new ClientSimulation(map);
            _sim.onTurnEnd += new SimulationHandler(SandwormHandler);

            //pobranie obiektu aktualnego gracza z symulacji - do obsługi w GameLogic
            _currentPlayer = _sim.GetPlayer(ClientPlayerInfo.Player.Id);

            _sim.BuildingCompleted += new ClientSimulation.BuildingCreationHandler(_sim_OnBuildingCompleted);
            _sim.BuildingDestroyed += new ClientSimulation.BuildingHandler(_sim_BuildingDestroyed);
            _sim.UnitDestroyed     += new ClientSimulation.UnitHandler(_sim_UnitDestroyed);
            _sim.OnCreditsUpdate   += new ClientSimulation.OnCreditsHandler(_sim_OnCreditsUpdate);
            _sim.MCVDeployed       += new ClientSimulation.UnitHandler(_sim_MCVDeployed);
            _sim.ammoBlow          += new ClientSimulation.AmmoHandler(_sim_ammoBlow);
            _sim.ammoShoot         += new ClientSimulation.AmmoHandler(_sim_ammoShoot);
            this.GameEnd           += new GameEndHandler(GameLogic_GameEnd);
            _sim.onTurnEnd         += new SimulationHandler(CheckGameEndCondition);
        }
Exemple #2
0
        public static GameSettingsWrapper get(String configFilePath, String configFileXSDPath)
        {
            try
            {
#pragma warning disable 0618
                FileStream          sr     = new FileStream(configFilePath, FileMode.Open);
                XmlSerializer       xmlSer = new XmlSerializer(typeof(GameSettings));
                XmlReader           xr     = new XmlTextReader(sr);
                XmlValidatingReader xvr    = new XmlValidatingReader(xr);
                xvr.Schemas.Add(Declarations.SchemaVersion, configFileXSDPath);
                GameSettings        gameSettings = (GameSettings)xmlSer.Deserialize(xvr);
                GameSettingsWrapper gsw          = new GameSettingsWrapper(gameSettings);
#pragma warning restore 0618
                xvr.Close();
                xr.Close();
                sr.Close();

                return(gsw);
            } catch (Exception e) {
                throw new XMLLoaderException(e);
            }
        }