Ejemplo n.º 1
0
    private void Start()
    {
        NetworkServer.SpawnObjects();
        if (!NetworkManager.singleton || !(DayClock)FindObjectOfType(typeof(DayClock)))
        {
            return;
        }
        if (!isServer)
        {
            return;
        }

        Player_ID.OnPlayerSetupComplete += OnPlayerJoined;
        NetworkServer.Spawn(gameObject);

        m_Nodules.SpawnNoduleController = (p, r, t) =>
        {
            var nod = NoduleFactory.InstantiateNodule(p, r, t);
            NetworkServer.Spawn(nod.gameObject);
            return(nod);
        };

        DataStore.OnDataChange += OnDataChange;

        var ssDataMap = DataStore.GetAllData();

        DataMap =
            ssDataMap.Select(kvp => new KeyValuePair <Data, string>((Data)Enum.Parse(typeof(Data), kvp.Key), kvp.Value))
            .ToDictionary(x => x.Key, x => x.Value);

        HerbivoreMinimum = DataStore.GetInt(Data.EcoHerbivoreMinimum);
        CarnivoreMinimum = DataStore.GetInt(Data.EcoCarnivoreMinimum);

        InitialFGLColonycount = DataStore.GetInt(Data.EcoInitialFGLColonyCount);
        InitialHerbivoreCount = DataStore.GetInt(Data.EcoInitialHerbivoreCount);
        InitialCarnivoreCount = DataStore.GetInt(Data.EcoInitialCarnivoreCount);

        NoduleLimit    = DataStore.GetInt(Data.EcoNoduleLimit);
        HerbivoreLimit = DataStore.GetInt(Data.EcoHerbivoreLimit);
        CarnivoreLimit = DataStore.GetInt(Data.EcoCarnivoreLimit);

        CreatureSpawnExtent    = DataStore.GetFloat(Data.EcoCreatureSpawnExtent);
        WorldExtent            = DataStore.GetFloat(Data.EcoWorldExtent);
        PlantSpawnExtentBuffer = DataStore.GetFloat(Data.EcoPlantSpawnExtentBuffer);

        Creature.PredationAllowed = DataStore.Get(Data.EcoPredation) == "on";

        DiscoverChildren();

        for (var i = 0; i < InitialFGLColonycount; i++)
        {
            var pos = Random.insideUnitSphere * (WorldExtent - PlantSpawnExtentBuffer);
            Debug.Log("Note that plant spawning is deactivated");
            //SpawnPlant(pos, Quaternion.identity, PlantType.FloatGrassLargeColony);
        }

        for (var i = 0; i < InitialHerbivoreCount; i++)
        {
            var pos = Random.insideUnitSphere * CreatureSpawnExtent;
            SpawnHerbivore(pos, Quaternion.identity, HerbivoreFactory.GetRandomSpawnableIndividualType());
        }

        for (var i = 0; i < InitialCarnivoreCount; i++)
        {
            var pos = Random.insideUnitSphere * CreatureSpawnExtent;
            SpawnCarnivore(pos, Quaternion.identity, EnumHelper.GetRandomEnum <CarnivoreType>());
        }

        InvokeRepeating("SyncCounts", SYNC_COUNTS_RATE, SYNC_COUNTS_RATE);
    }
 private void Awake()
 {
     m_Singleton = this;
 }