Ejemplo n.º 1
0
    public void initNewPlayer(NewWorldSettings settings)
    {
        this.inCreativeMode = settings.creativeEnabled;

        // Center the camera on the Truck.
        foreach (CellBehaviorMasterDepositPoint behavior in this.world.getAllBehaviors <CellBehaviorMasterDepositPoint>())
        {
            this.setCameraPos(behavior.center);
            break;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Initialized a new World.
    /// </summary>
    public void initialize(string saveName, NewWorldSettings settings)
    {
        this.saveName = saveName;
        this.seed     = settings.getSeed();


        this.preInitialization();


        // Create land plots
        this.plotManager.initializeFirstTime(this.seed);


        // Generate the map.
        for (int depth = 0; depth < this.storage.layerCount; depth++)
        {
            this.mapGenerator.generateLayer(this, depth);
        }


        // Unlock the plot that contains the Dumptruck and set the
        // Worker spawn point.
        List <CellBehaviorMasterDepositPoint> masters = this.getAllBehaviors <CellBehaviorMasterDepositPoint>();

        if (masters.Count > 0)
        {
            CellBehaviorMasterDepositPoint m = masters[0];
            this.plotManager.getPlot(m.pos.x, m.pos.y).isOwned = true;
            this.storage.workerSpawnPoint = m.pos.add(-1, -1);
        }
        else
        {
            Debug.LogWarning("No MasterDepositPoint could be found when generating a new map, there must always be at least one!");
        }


        // Set starting money.
        this.money.value = this.mapGenerator.startingMoney;


        // Setup the new Player.
        CameraController.instance.initNewPlayer(settings);


        // Spawn the starting Workers.
        WorkerFactory factory = Main.instance.workerFactory;

        foreach (WorkerType workerType in this.mapGenerator.startingWorkers)
        {
            if (workerType != null)
            {
                int          xShift = UnityEngine.Random.Range(-1, 2);
                int          yShift = UnityEngine.Random.Range(0, 2);
                EntityWorker worker = factory.spawnWorker(
                    this,
                    this.storage.workerSpawnPoint.add(xShift, -yShift),
                    factory.generateWorkerInfo(workerType, Main.instance.personalityRegistry.getDefaultPersonality()),
                    workerType);
            }
        }


        this.postInitialization();


        CameraController.instance.changeLayer(this.mapGenerator.playerStartLayer);
    }
Ejemplo n.º 3
0
    public void createWorld(string saveName, NewWorldSettings settings)
    {
        World world = this.instantiateGame();

        world.initialize(saveName, settings);
    }