public AsteroidFieldControllerPersistance Serialize()
    {
        List <AsteroidControllerPersistance> asteroidPersistances = new List <AsteroidControllerPersistance>();

        foreach (KeyValuePair <ResourceType, HashSet <GameObject> > keyValuePair in _asteroids)
        {
            foreach (GameObject asteroid in keyValuePair.Value)
            {
                asteroidPersistances.Add(asteroid.GetComponent <AsteroidController>().Serialize());
            }
        }

        return(new AsteroidFieldControllerPersistance(asteroidFieldAsteroidSettings.Serialize(), asteroidPersistances, initialized, GetComponent <MapObject>().Serialize(), size));
    }
Ejemplo n.º 2
0
        public static GameSceneData NewGameDefault()
        {
            long id = 0;

            #region Player 1

            ///////////////////////////////////Player 1///////////////////////////////////////////////////////
            List <ResourcePersistance> player1Resources = new List <ResourcePersistance>
            {
                new ResourcePersistance(ResourceType.Metal, 500),
                new ResourcePersistance(ResourceType.Crystal, 500),
                new ResourcePersistance(ResourceType.BlackMatter, 100)
            };

            List <ShipControllerPersistance> player1Ships = new List <ShipControllerPersistance>()
            {
                new ShipControllerPersistance(ShipFactory.getInstance().CreateShip(ShipType.MotherShip), ShipType.MotherShip, new MapObjectPersitance(id++, new Vector3(-15, 0, -20), new Vector3(1, 1, 1), Quaternion.identity, -1), new Navigation.FleetCommandQueue().Serialize(), false)
            };

            #endregion Player 1

            #region Player 2

            List <ResourcePersistance> player2Resources = new List <ResourcePersistance>
            {
                new ResourcePersistance(ResourceType.Metal, 500),
                new ResourcePersistance(ResourceType.Crystal, 500),
                new ResourcePersistance(ResourceType.BlackMatter, 100)
            };

            List <ShipControllerPersistance> player2Ships = new List <ShipControllerPersistance>()
            {
                new ShipControllerPersistance(ShipFactory.getInstance().CreateShip(ShipType.MotherShip), ShipType.MotherShip, new MapObjectPersitance(id++, new Vector3(15, 0, 20), new Vector3(1, 1, 1), Quaternion.identity, -1), new Navigation.FleetCommandQueue().Serialize(), false)
            };

            #endregion Player 2

            List <PlayerPersistance> players = new List <PlayerPersistance>()
            {
                new PlayerPersistance(new Player("player 1", 0, PlayerType.Real, new SerializableColor(Color.blue)), player1Resources, player1Ships, new List <StationControllerPersistance>()),
                new PlayerPersistance(new Player("player 2", 1, PlayerType.AI, new SerializableColor(Color.red)), player2Resources, player2Ships, new List <StationControllerPersistance>())
            };

            #region asteroids

            AsteroidFieldAsteroidSettings asteroidFieldAsteroidSettings = AsteroidFieldAsteroidSettings.CreateDefaultSettings();

            AsteroidFieldControllerPersistance middleAsteroidField = new AsteroidFieldControllerPersistance(asteroidFieldAsteroidSettings.Serialize(), new List <AsteroidControllerPersistance>(), false, new MapObjectPersitance(id++, new Vector3(0, 0, 0), new Vector3(1, 1, 1), Quaternion.identity, -1), new Vector3(15, 3, 15));

            #endregion asteroids

            return(new GameSceneData("New Game", new Vector2(40, 50), players, new List <AsteroidFieldControllerPersistance>()
            {
                middleAsteroidField
            }, id++));
        }