Exemplo n.º 1
0
    /// <summary>
    /// Start the generation of levels
    /// </summary>
    public GameObject StartGeneration()
    {
        if (levelCount != -1)
        {
            levelsToGenerate = levelCount;
        }

        generationParameters = new LevelMapGenerator.GenerationParameters();
        generationParameters.levelsToGenerate = levelsToGenerate;

        // Start area
        lastPos = GenerateStartArea(lastPos);
        // Levels
        lastPos = GenerateLevels(lastPos);

        GenerateBossArea(lastPos);

        // Create teleporter links
        GenerateLinks();

        // Call map generation
        if (levelMapGenerator != null)
        {
            levelMapGenerator.GenerateMap(generationParameters);
        }

        // Return start location
        if (generateStartArea)
        {
            return(generatedStartArea);
        }
        else if (levelsToGenerate != 0)
        {
            return(generatedLevels[0]);
        }
        else if (generateBossArea)
        {
            return(generatedBossArea);
        }
        else
        {
            throw new System.InvalidOperationException("No sublevel generated");
        }
    }
Exemplo n.º 2
0
    void Awake()
    {
        // First we check if there are any other instances conflicting
        if (Instance != null && Instance != this)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }
        else
        {
            // Here we save our singleton instance
            Instance = this;

            // Furthermore we make sure that we don't destroy between scenes (this is optional)
            DontDestroyOnLoad(gameObject);

            NpcDatabase.ClearLists();

            transform.FindChild("Canvas").gameObject.SetActive(true);

            GameObject playerGO = Instantiate(stageRandomController.player, partyCells[0].transform.position, Quaternion.identity) as GameObject;
            playerGO.name  = "Player";
            playerGO.tag   = "Ally";
            player         = playerGO.GetComponent <InteractiveObject>();
            player.inParty = true;

            GetRandomSkills(skills);
            skillsCurrent = skills;

            foreach (NpcController mob in stageRandomController.npcList) // generate mobs stats on start of new game
            {
                mob.objectController.GenerateDynamicStats();
            }
            player.GenerateDynamicStats();
            _levelMapGenerator.GenerateMap(roomsMinimum);
        }
    }