public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (GUILayout.Button("Generate Tilemaps"))
        {
            TilemapGenerator tilemapGenerator = (TilemapGenerator)target;
            tilemapGenerator.Generate();
        }
    }
Esempio n. 2
0
    public IEnumerator StartingGame()
    {
        StartingOverlayPanel.SetActive(true);

        // done on start because otherwise there would be problem with retained Entitas entities (solvable of course)
        GeneratingText.text += Environment.NewLine + "...";
        yield return(new WaitForSeconds(0.3f));

        if (Difficulty.value == 0)         // easy
        {
        }

        float enemyCountRate = Difficulty.value == 0 ? 0.9f : Difficulty.value == 1 ? 1f : 1.1f;

        _worldActorFiller.FillWithActors(enemyCountRate);

        yield return(new WaitForSeconds(0.3f));

        _tilemapGenerator.Clear();
        yield return(new WaitForSeconds(0.3f));

        _tilemapGenerator.Generate();

        yield return(new WaitForSeconds(0.1f));

        foreach (GameObject gameObjectToEnable in ToEnableWhenStarting)
        {
            gameObjectToEnable.SetActive(true);
            yield return(new WaitForSeconds(0.05f));            // without this objects may start in wrong order, causing data to be corrupted
        }

        StartingOverlayPanel.SetActive(false);
        _uiFacade.AddLogEntry("<color=#adf>Welcome!</color> \nHave fun working with Osnowa.");
        _uiFacade.AddLogEntry("Feel free to play around with the engine.");

        gameObject.SetActive(false);
    }
Esempio n. 3
0
        public void BuildMap(List <Tuple <AreaType, List <GameObjectType> > > map)
        {
            currentMapLength = 0;
            Spawn(Resources.Load <GameObject>("Prefabs/Bound"), _nextSpawn + new Vector3(-0.5f, 0, 0));

            // строим район
            foreach (var areaContent in map)
            {
                var areaType            = areaContent.Item1;
                var nextBackgroundSpawn = _nextSpawn;

                // строим здания
                foreach (var gameObject in areaContent.Item2)
                {
                    var g = GetGameObject(gameObject);
                    Spawn(g);

                    var building = g.GetComponent <Building>();
                    if (building != null)
                    {
                        building.GenerateObstacles();

                        foreach (var positionInfo in Building.Positions[building.buildingType])
                        {
                            if (building.freePositions[positionInfo.PositionNumber])
                            {
                                continue;
                            }

                            var obstacle = GetGameObject(positionInfo.Info.ObType);
                            Spawn(obstacle, _nextSpawn + positionInfo.RelativePosition);
                        }
                    }

                    currentMapLength += g.GetWidth() + _spacing;
                    _nextSpawn       += Vector3.right * (g.GetWidth() + _spacing);
                }

                _buildingsCount += areaContent.Item2.Count;

                // ставим фон для района
                // TODO: change the logic behind calculation of iterations
                var backIterations    = areaContent.Item2.Count;
                var backgroundObjects = MapGenerator.AreaBackground[areaType];

                // TODO это ЧТО??
                if (backgroundObjects.Length == 0)
                {
                    continue;
                }

                var rand = new Random();

                for (var i = 0; i < backIterations; i++)
                {
                    var index          = rand.Next(backgroundObjects.Length);
                    var backgroundItem = GetGameObject(backgroundObjects[index]);
                    Spawn(backgroundItem, nextBackgroundSpawn);
                    nextBackgroundSpawn += Vector3.right * backgroundItem.GetWidth();
                }
            }

            // время на прохождение карты
            countdownManager.SetTime(_buildingsCount);
            tilemapGenerator.Generate((int)_nextSpawn.x + 1);
            cameraManager.SetBounds(0, _nextSpawn.x);
        }