コード例 #1
0
ファイル: GameMaster.cs プロジェクト: Alan-Baylis/VoxelGame-1
 public GameStartSettings(ChunkGenerationMode i_genMode)
 {
     generationMode   = i_genMode;
     chunkSize        = 8;
     difficulty       = Difficulty.Normal;
     terrainRoughness = 0.3f;
 }
コード例 #2
0
ファイル: GameMaster.cs プロジェクト: Alan-Baylis/VoxelGame-1
 public GameStartSettings(ChunkGenerationMode i_genMode, byte i_chunkSize, Difficulty diff, float i_terrainRoughness)
 {
     generationMode   = i_genMode;
     chunkSize        = i_chunkSize;
     difficulty       = diff;
     terrainRoughness = i_terrainRoughness;
 }
コード例 #3
0
ファイル: MenuUI.cs プロジェクト: Hengle/VoxelGame
 public void NG_GenerateButton()
 {
     newGameGenMode = availableGenerationModes[generationTypeDropdown.value];
     terrainPresetsPanel.SetActive(false);
     terrainSavenames = null;
     usePresetsButtonImage.overrideSprite = null;
     generationPanel.SetActive(true);
     generateButtonImage.overrideSprite = overridingSprite;
     gameStartButton.interactable       = true;
 }
コード例 #4
0
    public void NG_GenerateButton()
    {
        selectedGameMode    = GameMode.Survival;
        chunkPrepareAction  = ChunkPreparingAction.Generate;
        chunkGenerationMode = availableGenerationModes[generationTypeDropdown.value];

        terrainPresetsPanel.SetActive(false);
        terrainSavenames = null;
        usePresetsButtonImage.overrideSprite = null;
        generationPanel.SetActive(true);
        generateButtonImage.overrideSprite = overridingSprite;
        gameStartButton.interactable       = true;
        terrainGenerationEnabled           = true;
    }
コード例 #5
0
ファイル: EnvironmentMaster.cs プロジェクト: Hengle/VoxelGame
    public void PrepareIslandBasis(ChunkGenerationMode cmode)
    { // его придётся сохранять!
        switch (cmode)
        {
        case ChunkGenerationMode.Peak:
            int        resolution = 15;
            GameObject g          = Constructor.CreatePeakBasis(resolution, ResourceType.STONE_ID);
            float      cs         = Chunk.chunkSize * Block.QUAD_SIZE;
            g.transform.localScale = Vector3.one * cs / 2f;
            g.transform.position   = new Vector3(cs / 2f - 0.5f * Block.QUAD_SIZE, g.transform.localScale.y / 2f - 0.5f * Block.QUAD_SIZE, cs / 2f - 0.5f * Block.QUAD_SIZE);
            break;

        default: return;
        }
    }
コード例 #6
0
    public void ConstructChunk(byte chunkSize, ChunkGenerationMode mode)
    {
        seed += System.DateTime.Now.Second;
        TERRAIN_ROUGHNESS = GameMaster.gameStartSettings.terrainRoughness;
        int size = chunkSize;

        int[,,] dat = new int[size, size, size];
        GenerateDataArray(size, ref dat);
        GameObject g = new GameObject("chunk");

        c = g.AddComponent <Chunk>();
        GameMaster.mainChunk = c;
        c.SetChunk(dat);
        NatureCreation(c);
    }
コード例 #7
0
ファイル: Constructor.cs プロジェクト: Hengle/VoxelGame
    public static void ConstructChunk(byte chunkSize, ChunkGenerationMode mode)
    {
        int size = chunkSize;

        int[,,] dat = new int[size, size, size];
        switch (mode)
        {
        case ChunkGenerationMode.Standart: GenerateSpiralsData(size, ref dat); break;

        case ChunkGenerationMode.Cube: GeneratePyramidData(size, ref dat); break;

        case ChunkGenerationMode.Peak: dat = GeneratePeakData(size); break;
        }

        //testzone

        /*
         * dat = new int[size, size, size];
         * var ac = PoolMaster.MATERIAL_WHITE_METAL_ID;
         * for (int x = 0; x < 8; x++)
         * {
         *  for (int z = 0; z < 8; z++)
         *  {
         *      for (int y = 0; y < 8; y++)
         *      {
         *          dat[x, y, z] = ac;
         *      }
         *  }
         * }
         */
        //eo testzone

        GameObject g = new GameObject("chunk");
        Chunk      c = g.AddComponent <Chunk>();

        GameMaster.realMaster.SetMainChunk(c);
        c.CreateNewChunk(dat);
        c.GetNature().FirstSet(size * size * 500f);
        //CheckForLandingPosition(c);
        c.RenderDataFullRecalculation();
    }
コード例 #8
0
ファイル: MenuUI.cs プロジェクト: Hengle/VoxelGame
    public void Start()
    {
        int k = 0;

        if (PlayerPrefs.HasKey(GameConstants.BASE_SETTINGS_PLAYERPREF))
        {
            k = PlayerPrefs.GetInt(GameConstants.BASE_SETTINGS_PLAYERPREF);
        }

        if ((k & 2) == 0)  // first launch
        {
            LODController.SetLODdistance(0.5f);
            GameObject g = Instantiate(Resources.Load <GameObject>("UIPrefs/firstLaunchPanel"), transform);
            g.GetComponent <FirstLaunchUI>().menuScript = this;
            transform.GetChild(0).gameObject.SetActive(false);
            authorsButton.gameObject.SetActive(false);
        }
        else
        {
            if (saveSystem == null)
            {
                saveSystem = SaveSystemUI.Initialize(transform.root);
            }

            availableGenerationModes = new List <ChunkGenerationMode>()
            {
                ChunkGenerationMode.Standart, ChunkGenerationMode.Cube, ChunkGenerationMode.Peak
            };
            List <string> genModenames = new List <string>();
            foreach (ChunkGenerationMode cmode in availableGenerationModes)
            {
                genModenames.Add(cmode.ToString());
            }
            generationTypeDropdown.AddOptions(genModenames);
            generationTypeDropdown.value = 0;
            newGameGenMode = availableGenerationModes[0];
            LocalizeTitles();
            transform.GetChild(0).gameObject.SetActive(true);
        }
        GameMaster.SetPause(false);
    }
コード例 #9
0
 public GameStartSettings(ChunkGenerationMode i_genMode)
 {
     generationMode = i_genMode;
     chunkSize      = 8;
     difficulty     = Difficulty.Normal;
 }
コード例 #10
0
 public GameStartSettings(ChunkGenerationMode i_genMode, byte i_chunkSize, Difficulty diff)
 {
     generationMode = i_genMode;
     chunkSize      = i_chunkSize;
     difficulty     = diff;
 }
コード例 #11
0
ファイル: MenuUI.cs プロジェクト: Hengle/VoxelGame
 public void NG_SetGenMode()
 {
     newGameGenMode = availableGenerationModes[generationTypeDropdown.value];
 }
コード例 #12
0
ファイル: MenuUI.cs プロジェクト: Hengle/VoxelGame
    public void NG_UsePresetButton()
    {
        newGameGenMode = ChunkGenerationMode.TerrainLoading;
        GameMaster.SetSavename(string.Empty);
        generationPanel.SetActive(false);
        generateButtonImage.overrideSprite = null;
        gameStartButton.interactable       = false;

        //preparing terrains list
        string        directoryPath  = SaveSystemUI.GetTerrainsPath();
        Transform     contentHolder  = terrainPresetsPanel.transform.GetChild(0).GetChild(0);
        RectTransform zeroButton     = contentHolder.GetChild(0).GetComponent <RectTransform>();
        bool          no_saves_found = true;

        if (Directory.Exists(directoryPath))
        {
            terrainSavenames = Directory.GetFiles(directoryPath, "*." + SaveSystemUI.TERRAIN_FNAME_EXTENSION);
            if (terrainSavenames.Length != 0)
            {
                no_saves_found = false;
                int c = contentHolder.childCount;
                int i = 0;
                zeroButton.GetComponent <Button>().interactable = true;
                for (; i < terrainSavenames.Length; i++)
                {
                    string s            = terrainSavenames[i];
                    int    lastSlashPos = s.LastIndexOf('\\'); // в редакторе так
                    if (lastSlashPos == -1)
                    {
                        lastSlashPos = s.LastIndexOf('/');
                    }
                    terrainSavenames[i] = s.Substring(lastSlashPos + 1, s.Length - lastSlashPos - 5); //  от последнего слеша до ".sav"
                    Transform t;
                    if (i < c)
                    {
                        t = contentHolder.GetChild(i); // 0 - example
                    }
                    else
                    {
                        t = Instantiate(zeroButton, contentHolder).transform;
                        t.transform.localPosition = zeroButton.localPosition + Vector3.down * (zeroButton.rect.height * i + 16);
                    }
                    t.gameObject.SetActive(true);
                    t.GetComponent <Button>().onClick.RemoveAllListeners(); // т.к. на example тоже может висеть listener
                    t.GetChild(0).GetComponent <Text>().text = terrainSavenames[i];
                    int index = i;
                    t.GetComponent <Button>().onClick.AddListener(() =>
                    {
                        this.NG_SelectTerrain(index);
                    });
                    t.GetComponent <Image>().overrideSprite = null;
                }
                if (i < c)
                {
                    i++;
                    for (; i < c; i++)
                    {
                        contentHolder.GetChild(i).gameObject.SetActive(false);
                    }
                }
            }
        }
        if (no_saves_found)
        {
            terrainSavenames = null;
            zeroButton.GetChild(0).GetComponent <Text>().text = Localization.GetPhrase(LocalizedPhrase.NoSavesFound);
            zeroButton.GetComponent <Button>().interactable   = false;
            zeroButton.GetComponent <Image>().overrideSprite  = null;
            zeroButton.gameObject.SetActive(true);
            if (contentHolder.childCount > 1)
            {
                while (contentHolder.childCount > 1)
                {
                    Destroy(contentHolder.GetChild(1));
                }
            }
        }
        terrainPresetsPanel.SetActive(true);
        usePresetsButtonImage.overrideSprite = overridingSprite;
    }