public ServerFactionManager(int id, ServerMapManager mapManagerReference, ServerGameManager gameManagerReference, ConnectedClient fClient = null, bool neutral = true)
        {
            Debug.Log("Faction Manager: Initializing player faction...");
            // TODO: genericize context?
            FactionID     = id;
            GameManager   = gameManagerReference;
            MapManager    = mapManagerReference;
            FactionClient = fClient;
            Credits       = Constants.Global.START_CREDITS;

            FactionMap = new Tile[MapManager.Map.GetLength(0), MapManager.Map.GetLength(0)];
            for (int i = 0; i < FactionMap.GetLength(0); i++)
            {
                for (int j = 0; j < FactionMap.GetLength(0); j++)
                {
                    FactionMap[i, j] = Tile.Fog;
                }
            }

            _pathfinder = new ServerPathfinder();
            Territory   = new HashSet <ByteVector2>();
            _toReveal   = new HashSet <ByteVector2>();

            if (!neutral)
            {
                SendInit();
                CrashDown();
                SendMap();
            }

            _neutral = neutral;
        }
示例#2
0
            public GasManager(ServerMapManager MapManager)
            {
                _emitters   = new List <Entity>();
                _pathfinder = new ServerPathfinder();
                _mapManager = MapManager;
                _territory  = new HashSet <ByteVector2>();

                int length = MapManager.Map.GetLength(0);

                _gasMap  = new double[length, length];
                _fillMap = new double[length, length];
            }
示例#3
0
        public ServerGameManager()
        {
            // Game init
            NumberGenerator = new System.Random();
            MapManager      = new ServerMapManager(100, this);
            PlayerFactions  = new List <ServerFactionManager>();


            // Server init
            _newPackets = new ConcurrentQueue <byte[]>();
            GameServer  = new Server();
            GameServer.Start(RecievePacket, AddPlayer);

            // Add a new "player manager" for managing ore and other neutral entities
            // The neutral faction is assumed to be index 0
            PlayerFactions.Add(new ServerFactionManager(
                                   PlayerFactions.Count, //id
                                   MapManager,           //context
                                   this));

            // Start game loop
            StartGameClock();
        }