Пример #1
0
    private void SetUpContinents()
    {
        //Store information about the main continent before we do anything
        ContinentManager contMan = continentsMain.GetComponent <ContinentManager>();

        contMan.InstantiateMainContinent(connectionManager, gameManager, lineDraw, continentsMain.transform.Find("Player").gameObject, peopleManager.updateRate);

        //Store information about the respawn details for the continents
        BoxCollider2D curCollider = continentsMain.transform.GetComponent <BoxCollider2D>(); //Get the box collider

        _continentWidth = curCollider.size.x * continentsMain.transform.localScale.x;

        _continentRespawnPosX = continentsMain.transform.position.x + _continentWidth;

        //We generate copies of the current continent map and move the main version side
        _continents1 = Instantiate(continentsMain, worldMapParent);
        _continents2 = Instantiate(continentsMain, worldMapParent);
        //ContinentsForward is a false continent ahead of our current continent to maintain lines
        _continentsForward = Instantiate(continentsMain, worldMapParent);

        connectionManager.currentPlayer = _continents1.GetComponent <ContinentManager>().player;

        //Change the position of the second set of continents and set the first continent as our main
        _continents2.transform.position = SpawnPosition(continentsMain.transform.position, _continentWidth);
        curContinent = _continents1;
        _curCont1    = true;

        //Change the position of the forward continent for previewing purposes
        _continentsForward.transform.position = ForwardSpawnPosition(continentsMain.transform.position, _continentWidth);

        //Move the main continent out of the way
        Vector3 holdPos = continentsMain.transform.position;

        holdPos.y += 50; //Offset out of the way by 50.
        continentsMain.transform.position = holdPos;

        //Send references of our active players to PeopleManager
        peopleManager.player1 = _continents1.transform.Find("Player").gameObject;
        peopleManager.player2 = _continents2.transform.Find("Player").gameObject;
        //Set Player1 as the active player
        peopleManager.player1Active = true;
    }