コード例 #1
0
    // Use this for initialization
    void Start()
    {
        // singleton handeling
        if (instance)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }

        // validating input amount
        if (maxObjectsSpawned <= 2)
        {
            throw new System.Exception("Error, max objects spawned must be larger than 2");
        }


        // creating the queue for the spawned objects to destroy them later
        spawnedObjectsQueue = new Queue <Transform>(maxObjectsSpawned);

        // storing the starting position x
        lastSpawnPosDistance = transform.position.x;

        // at the first of the game we add the objects
        AddNextScreenObjects();

        // AT THE START OF THE GAME WE ALSO NEED TO SPAWN SOME AT THE START A FEW WALLS
    }
コード例 #2
0
        public static void StartGame()
        {
            GameWorld newWorld = null;

            switch (ChooseDifficulty())
            {
            case 1:
                newWorld = GameWorldGenerator.GenerateNewWorld(50, 5, 2);
                break;

            default:
                break;
            }

            GameSession newSession = new GameSession(newWorld, 5);

            newSession.Start();
        }