コード例 #1
0
 void Awake()
 {
     world = GameObject.Find("WorldGeneration").GetComponent <WorldGeneration>();
     input = GameObject.Find("InputController").GetComponent <InputController>();
     Application.targetFrameRate = 60;
     Screen.SetResolution(1280, 720, false);
 }
コード例 #2
0
    void Update()
    {
        int i = 0;

        while (i < currentJobs.Count)
        {
            if (currentJobs[i].jobDone)
            {
                currentJobs[i].NotifyComplete();
                currentJobs.RemoveAt(i);
            }
            else
            {
                i++;
            }
        }
        if (toDoJobs.Count > 0 && currentJobs.Count < MaxJobs)
        {
            WorldGeneration job = toDoJobs[0];
            toDoJobs.RemoveAt(0);
            currentJobs.Add(job);

            Thread jobThread = new Thread(job.StartCreatingWorld);
            jobThread.Start();
        }
    }
コード例 #3
0
        public override void RandomUpdate(int i, int j)
        {
            WorldGeneration.Spread("The 404 Realm", i, j);

            // A random chance to slow down growth
            if (WorldGen.genRand.Next(20) == 0)
            {
                Tile tile = Framing.GetTileSafely(i, j); // Safely get the tile at the given coordinates
                bool growSucess;                         // A bool to see if the tree growing was sucessful.

                // Style 0 is for the ExampleTree sapling, and style 1 is for ExamplePalmTree, so here we check frameX to call the correct method.
                // Any pixels before 54 on the tilesheet are for ExampleTree while any pixels above it are for ExamplePalmTree
                if (tile.frameX < 54)
                {
                    growSucess = WorldGen.GrowTree(i, j);
                }
                else
                {
                    growSucess = WorldGen.GrowPalmTree(i, j);
                }

                // A flag to check if a player is near the sapling
                bool isPlayerNear = WorldGen.PlayerLOS(i, j);

                //If growing the tree was a sucess and the player is near, show growing effects
                if (growSucess && isPlayerNear)
                {
                    WorldGen.TreeGrowFXCheck(i, j);
                }
            }
        }
コード例 #4
0
    public virtual void LoadBlock(MeshData d, WorldGeneration w)
    {
        Vector3 o = worldPosition;

        MeshUtilities.FaceUp(d, o);

        Block n = w.GetBlock(x, y, z + 1);

        if (n == null || !n.isSolid)
        {
            MeshUtilities.FaceNorth(d, o);
        }

        Block s = w.GetBlock(x, y, z - 1);

        if (s == null || !s.isSolid)
        {
            MeshUtilities.FaceSouth(d, o);
        }

        Block we = w.GetBlock(x - 1, y, z);

        if (we == null || !we.isSolid)
        {
            MeshUtilities.FaceWest(d, o);
        }

        Block e = w.GetBlock(x + 1, y, z);

        if (e == null || !e.isSolid)
        {
            MeshUtilities.FaceEast(d, o);
        }
    }
コード例 #5
0
    IEnumerator CreateChunk()
    {
        Task GenerationTask;

        Vector3[] TempPositions = new Vector3[ChunksToGenerate.Count];
        ChunksToGenerate.CopyTo(TempPositions, 0);
        ChunksToGenerate.Clear();

        foreach (Vector3 pos in TempPositions)
        {
            if (chunks.Get(pos) == null)
            {
                generator = new WorldGeneration();
                WorldPos TempPos = new WorldPos((int)pos.x * Chunk.ChunkSize, (int)pos.y * Chunk.ChunkSize, (int)pos.z * Chunk.ChunkSize);

                yield return(Ninja.JumpToUnity);

                GameObject TempChunkObject = Instantiate(chunkPrefab) as GameObject;
                TempChunkObject.transform.SetParent(this.transform);
                TempChunkObject.name = TempPos.ToString();
                Chunk TempChunkScript = TempChunkObject.GetComponent <Chunk>();

                yield return(Ninja.JumpBack);

                TempChunkScript.world         = this;
                TempChunkScript.ChunkPosition = TempPos;
                this.StartCoroutineAsync(GenerateChunk(TempChunkScript), out GenerationTask);
                yield return(StartCoroutine(GenerationTask.Wait()));

                generator.FetchChunk(out TempChunkScript);
                chunks.Add(TempChunkScript, TempPos.ToVector3());
            }
        }
    }
コード例 #6
0
    void Start()
    {
        //Start singleton managers
        WorldGeneration instance = WorldGeneration.Instance;

        Region.setWorld(this);
        regions = new Dictionary <string, Region> ();
//				for (int x = 0; x < initialRegions; x++) {
//						for (int y =0; y < initialRegions; y++) {
//								for (int z = 0; z < initialRegions; z++) {
//										createRegion (x, y, z, false);
//								}
//						}
//				}
        //Region centerRegion = getRegionAtIndex (1, 0, 1);
        Region centerRegion = createRegion(0, 0, 0, false);

        loadAllNeighbors(centerRegion, false);

        //Initialize Chunk Manager
        GameObject   chunkManagerGO = GameObject.Find("Chunk Manager") as GameObject;
        ChunkManager manager        = chunkManagerGO.GetComponent <ChunkManager> ();

        manager.createChunkPool();

        clientRenderer = gameObject.GetComponent("VoxelModifyTerrain") as VoxelModifyTerrain;
        clientRenderer.setStartRegion(centerRegion);


        InvokeRepeating("SaveToDiskEvent", 30f, 30f);
    }
コード例 #7
0
        /// <summary>
        /// Constructor for the Battle Form. Only supports Singleplayer combat atm
        /// </summary>
        /// <param name="_listOfChars"></param>
        /// <param name="_difficulty"></param>
        public BattleForm(List <Core.Units.Character> _listOfChars, int _difficulty, RPG.Core.PlayerSettings settings)
        {
            InitializeComponent();
            this.StartPosition   = FormStartPosition.CenterParent;
            this.BackgroundImage = GeneralFunctions.ResizeImage(Properties.Resources.background, labelBackgroundIGNORE.Size);
            Function.SoundManager.PlayMain(settings.SoundOn, this, settings.SoundVolume);

            numberOfPlayers = _listOfChars.Count;

            battleChars = _listOfChars;

            int sum = 0;

            foreach (var item in battleChars)
            {
                sum += item.UnitLevel;
                liveChars.Add(item.UnitName);
            }

            int average = (int)(sum / battleChars.Count);

            enemy = WorldGeneration.GenerateNPC(null, average, _difficulty, EnumMonsterType.Null, battleChars.Count);
            ai    = WorldGeneration.GenerateNPCAI(enemy, battleChars);
            enemy = ai.ModifiedNPC;

            foreach (var item in battleChars)
            {
                ucCharacterBattle ucb = new ucCharacterBattle(item, battleChars.Count);
                ucb.AttackClicked += ucb_AttackClicked;
                flpCharacters.Controls.Add(ucb);
            }

            flpNPCs.Controls.Add(new ucNPC(enemy));
        }
コード例 #8
0
        static void Main()
        {
            #region Initialization
            ItemGeneration.ItemGenerationInitialization();
            WorldGeneration.InitializeWorldGeneration();
            #endregion

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            List <Player> playerList = ServerManagement.LoadPlayers("players.xml");
            SoundManager.InitializeSounds();

            playerList = ServerManagement.LoadFromFolder(Path.Combine(Environment.SpecialFolder.MyDocuments.ToString(), "/The Legend of Eiwar/players.xml"));

            if (playerList == null)
            {
                playerList = new List <Player>();
            }

            LoginForm lf = new LoginForm(playerList);
            Application.Run(lf);

            if (lf.DialogResult == DialogResult.OK)
            {
                Player player = lf.ReturnedPlayer();
                Application.Run(new MainWindow(player, playerList));
            }
        }
コード例 #9
0
 public Map(Game game, Vector2 mapSize, long Seed)
 {
     map          = new Tile[(int)mapSize.X, (int)mapSize.Y, 2];
     this.mapSize = mapSize;
     this.Seed    = Seed;
     wg           = new WorldGeneration(this.GetType().Name.ToString(), Seed, mapSize);
     mobs         = new List <IEntity>();
 }
コード例 #10
0
 private static States.GameState CreateDefaultState()
 {
     return(new States.GameState(
                WorldGeneration.makeDefaultWorld(),
                States.SimulationState.Simulating,
                Simulator.defaultTurnsLeft
                ));
 }
コード例 #11
0
 void Start()
 {
     pausa   = FindObjectOfType <pauseMenu>();
     inv     = FindObjectOfType <inventorySys>();
     world   = FindObjectOfType <WorldGeneration>();
     rb      = GetComponent <Rigidbody>();
     ArmAnim = arm.GetComponentInChildren <Animator>();
 }
コード例 #12
0
 void Awake()
 {
     input          = GameObject.Find("InputController").GetComponent <InputController>();
     world          = GameObject.Find("WorldGeneration").GetComponent <WorldGeneration>();
     items          = GameObject.Find("ItemController").GetComponent <ItemController>();
     mapController  = GameObject.Find("WorldGeneration").GetComponent <DrawMap>();
     uiController   = GameObject.Find("UIController").GetComponent <UIController>();
     gameController = GameObject.Find("GameController").GetComponent <GameController>();
     timeController = GameObject.Find("TimeController").GetComponent <TimeController>();
     spriteAnimator = GetComponent <SpriteAnimator>();
 }
コード例 #13
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(this);
     }
 }
コード例 #14
0
 private void Start()
 {
     world        = FindObjectOfType <WorldGeneration>();
     BlockButtons = GetComponentsInChildren <Button>();
     for (int i = 0; i < BlockButtons.Length; i++) // Asigna las funciones a cada boton, aunque ya me di cuenta que no los usé como botón, la puta madre
     {
         int        index = i;
         GameObject cube  = world.DefaultBlocks[index];
         BlockButtons[index].onClick.AddListener(delegate { AssingBlock(cube, BlockButtons[index]); });
     }
     AssingBlock(world.DefaultBlocks[0], BlockButtons[0]);
 }
コード例 #15
0
        public static void Write(string fileName)
        {
            PreFab pf = new PreFab {
                GoalPoint     = WorldGeneration.Goal,
                StartingPoint = WorldGeneration.Start,
                NodeSize      = WorldGeneration.NodeSize,
                Prefab        = { WorldGeneration.ObstaclesToObs() }
            };

            using (var output = File.Create(fileName))
                pf.WriteTo(output);
        }
コード例 #16
0
ファイル: World.cs プロジェクト: RedCardOP/SpaceCraftWorld
    void Start()
    {
        gameObject.AddComponent <EntityManager>();
        Random.InitState(seed);
        spawnPosition = new Vector3(VoxelData.WorldSizeInVoxels / 2f, VoxelData.ChunkHeight - 150f, VoxelData.WorldSizeInVoxels / 2f);
        worldGen      = new WorldGeneration(this);
        worldGen.GenerateWorld();
        Player player = new Player(this, hightlightBlock, placeBlock, placeBlockMesh, debugOverlay);

        player.Start();
        player.position      = spawnPosition;
        playerLastChunkCoord = GetChunkCoord(player.position);
    }
コード例 #17
0
    public void Init()
    {
        myGridLayoutGroup = GetComponent <GridLayoutGroup>();

        myGridLayoutGroup.cellSize = Vector2.one * (myGridLayoutGroup.GetComponent <RectTransform>().rect.width / Data.myBiomeSideSize);

        if (myWorldGeneration == null)
        {
            myWorldGeneration = FindObjectOfType <WorldGeneration>();
        }

        UpdateBiomeOnMap();
    }
コード例 #18
0
ファイル: Chunk.cs プロジェクト: RedCardOP/SpaceCraftWorld
 public Chunk(World _world, ChunkCoord _coord, bool generateOnLoad, bool _activeOnInit)
 {
     world               = _world;
     worldGen            = world.worldGen;
     coord               = _coord;
     _isActive           = true;
     spawnableStructures = new SS_Tree(world);
     activeOnInit        = _activeOnInit;
     if (generateOnLoad)
     {
         Init();
     }
 }
コード例 #19
0
    private IEnumerator InstantiateRooms()
    {
        if (WorldGeneration.GetInstance().DEBUG)
        {
            WorldGeneration.GetInstance().DEBUGCANVAS.ClearHighlightBiome();
        }

        for (int y = 0; y < myBiomeSideSize; ++y)
        {
            for (int x = 0; x < myBiomeSideSize; ++x)
            {
                if (myWorld[y * myBiomeSideSize + x].myRoomUsed == true)
                {
                    Room room = Instantiate(myRoomPrefab, myTransform);
                    room.transform.localPosition = new Vector3(x * myRoomSideSize * mySpriteSpace, y * myRoomSideSize * mySpriteSpace, 0);
                    room.myRoomData = myWorld[y * myBiomeSideSize + x];
                    myRooms.Add(room);
                    //room.ConstuctRoom(myRoomSideSize, this);

                    room.GetSeedAndGenerate(this);

                    if (myStartingRoomData.myX == x && myStartingRoomData.myY == y)
                    {
                        room.myStartingRoom = true;
                        myStartingRoom      = room;
                    }

                    room.transform.parent = myTransform;

                    LoadingManager.GetInstance().AddSpawned();

                    if (WorldGeneration.GetInstance().DEBUG)
                    {
                        WorldGeneration.GetInstance().DEBUGCANVAS.HighlightBiome(x, y);

                        yield return(new WaitForSeconds(WorldGeneration.GetInstance().STEPTIME));
                    }
                    else
                    {
                        yield return(null);
                    }
                }
            }
        }

        myGenerationDone = true;

        gameObject.SetActive(false);
    }
コード例 #20
0
    public void RequestWorldGeneration(Vector3 o)
    {
        WorldChunkStats s = new WorldChunkStats {
            maxX            = chunkX,
            maxZ            = chunkZ,
            baseNoise       = baseNoise,
            baseNoiseHeight = baseNoiseHeight,
            elevation       = elevation,
            frequency       = frequency,
            origin          = o
        };
        WorldGeneration wg = new WorldGeneration(s, LoadMeshData);

        toDoJobs.Add(wg);
    }
コード例 #21
0
ファイル: World.cs プロジェクト: NayosVieurer/Rub_Networking
    public void GenerateMap(WorldGeneration worldGeneration)
    {
        this.worldGeneration = worldGeneration;
        blockSize            = blockPrefabs[0].GetComponent <Transform>().localScale.x /* + 0.05f*/;
        int maxHeight = Mathf.RoundToInt(worldGeneration.mapSeed) + worldGeneration.minHeight + 1;

        mapTable = new MapBlock[worldGeneration.mapWidth, worldGeneration.mapLength, maxHeight];
        // for(int i = 0; i < mapTable.Length; i++){
        //  mapTable[i] = new MapBlock[length][];
        //  for(int j = 0; j < mapTable[i].Length; j++){
        //      mapTable[i][j] = new MapBlock[Mathf.RoundToInt(floatScale) + 1];
        //  }
        // }

        for (int i = 0; i < worldGeneration.mapWidth; i++)
        {
            for (int j = 0; j < worldGeneration.mapLength; j++)
            {
                Vector2 realPos = GetRealVector2BlockPosition(i, j);

                int biomeNoise = (int)(MakePerlinNoise(i * worldGeneration.biomeSeed, j * worldGeneration.biomeSeed, blockPrefabs.Length + worldGeneration.biomeSeed));

                MapBlock prefab = blockPrefabs[biomeNoise];

                int blockHeight = GetBlockHeight(worldGeneration.mapSeed, biomeNoise, i, j, worldGeneration.minHeight, blockPrefabs);

                if (createInside)
                {
                    for (int k = blockHeight; k >= 1; k--)
                    {
                        CreateBlock(new Vector3(realPos.x, k * blockSize, realPos.y), new Vector3Int(i, j, k), selfTransform, prefab);
                    }

                    CreateBlock(new Vector3(realPos.x, 0, realPos.y), new Vector3Int(i, j, 0), selfTransform, blockPrefabs[2]);
                }
                else
                {
                    CreateBlock(new Vector3(realPos.x, blockHeight * blockSize, realPos.y), new Vector3Int(i, j, blockHeight), selfTransform, prefab);
                }
            }
        }

        spawnBlocks = new Vector3Int[nbSpawnBlock];
        for (int i = 0; i < nbSpawnBlock; i++)
        {
            spawnBlocks[i] = GenerateSpawnBlock(worldGeneration, blockPrefabs);
        }
    }
コード例 #22
0
        private void Awake()
        {
            TerrainTileSet.InitialiseTileSets();
            World           = new World(784893570);
            WorldGeneration = new WorldGeneration(World.Seed, World.NegativeXSeed, World.NegativeYSeed);
            WorldGameObject = new GameObject("WorldGameObject");

            if (UseMonobehaviours)
            {
                InitialiseMonos();
            }
            else
            {
                InitialiseNonMonos();
            }
        }
コード例 #23
0
ファイル: World.cs プロジェクト: NayosVieurer/Rub_Networking
    private static Vector3Int GenerateSpawnBlock(WorldGeneration worldGeneration, MapBlock[] possibleBlocks)
    {
        int posX;
        int posZ;
        int biomeNoise;

        do
        {
            posX       = UnityEngine.Random.Range(0, worldGeneration.mapWidth);
            posZ       = UnityEngine.Random.Range(0, worldGeneration.mapLength);
            biomeNoise = (int)(MakePerlinNoise(posX * worldGeneration.biomeSeed, posZ * worldGeneration.biomeSeed, possibleBlocks.Length + worldGeneration.biomeSeed));
        } while(!possibleBlocks[biomeNoise].canSpawnOn);

        int blockHeight = GetBlockHeight(worldGeneration.mapSeed, biomeNoise, posX, posZ, worldGeneration.minHeight, possibleBlocks);

        return(new Vector3Int(posX, blockHeight, posZ));
    }
コード例 #24
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        WorldGeneration worldGeneration = (WorldGeneration)target;

        if (worldGeneration.segmentsSpawnChance.Length != worldGeneration.segments.Length)
        {
            System.Array.Resize(ref worldGeneration.segmentsSpawnChance, worldGeneration.segments.Length);
        }

        //Check if chance is valid
        for (int i = 0; i < worldGeneration.segmentsSpawnChance.Length; i++)
        {
            if (worldGeneration.segmentsSpawnChance[i] < 1)
            {
                worldGeneration.segmentsSpawnChance[i] = 1;
            }
        }

        //Check if tile deletion is valid
        if (worldGeneration.startTileDeletionFrom < 1)
        {
            worldGeneration.startTileDeletionFrom = 1;
        }

        //Check if spaces are checked
        if (worldGeneration.hasSpaces == true)
        {
            worldGeneration.gapMinDistance = EditorGUILayout.FloatField("Minimum distance", worldGeneration.gapMinDistance);
            worldGeneration.gapMaxDistance = EditorGUILayout.FloatField("Maximum distance", worldGeneration.gapMaxDistance);
        }


        if (worldGeneration.getMainGeneratorStats == false)
        {
            int size = 0;
            System.Array.Resize(ref worldGeneration.dontSpawnInObjectArea, size);
        }
    }
コード例 #25
0
    void Awake()
    {
        mainCamera   = GameObject.FindGameObjectWithTag("MainCamera");
        smoothFollow = mainCamera.GetComponent <SmoothFollow>();

        generationObject = GameObject.FindGameObjectWithTag("MainGenerator");
        worldGeneration  = generationObject.GetComponent <WorldGeneration>();

        tanFov = Mathf.Tan(Mathf.Deg2Rad * Camera.main.fieldOfView / 2.0f);
        players.Add(GameObject.Find("player1"));
        if (GameObject.Find("player2") != null)
        {
            players.Add(GameObject.Find("player2"));
        }
        if (GameObject.Find("player3") != null)
        {
            players.Add(GameObject.Find("player3"));
        }
        if (GameObject.Find("player4") != null)
        {
            players.Add(GameObject.Find("player4"));
        }
    }
コード例 #26
0
ファイル: The404Snow.cs プロジェクト: DaRubyMiner360/MoTools
 public override void RandomUpdate(int i, int j)
 {
     WorldGeneration.Spread("The 404 Realm", i, j);
 }
コード例 #27
0
 private void RandomizeWorlds()
 {
     _worlds = WorldGeneration.makeWorlds(_random, 10);
     SimulateCurrentPopulation();
 }
コード例 #28
0
 void Awake()
 {
     world          = GameObject.Find("WorldGeneration").GetComponent <WorldGeneration>();
     gameController = GameObject.Find("GameController").GetComponent <GameController>();
 }
コード例 #29
0
 public void Abolish()
 {
     WorldGeneration.Destroy(chunk);
 }
コード例 #30
0
 void Awake()
 {
     world          = GameObject.Find("WorldGeneration").GetComponent <WorldGeneration>();
     spriteAnimator = GetComponent <SpriteAnimator>();
 }