Exemple #1
0
    //Creates the playerdata from the variables selected by the players
    public void CreatePlayerData()
    {
        UpdatePlayerData();

        //If this player is a CPU and a car has not been assigned to it, a car is automatically assigned
        if (!is_this_ready && ThisPlayerSelector.is_CPU)
        {
            l.hasGameStarted = true;

            if (!Car1.ThisCarSelected)
            {
                ThisPlayerCar = 0; Car1.ThisCarSelected = true; ThisPlayerSelector.CurrentCar = Car1.ThisCarImage; Coin.transform.position = Car1.ThisCarIconPosition;
            }
            else if (!Car2.ThisCarSelected)
            {
                ThisPlayerCar = 1; Car2.ThisCarSelected = true; ThisPlayerSelector.CurrentCar = Car2.ThisCarImage; Coin.transform.position = Car2.ThisCarIconPosition;
            }
            else if (!Car3.ThisCarSelected)
            {
                ThisPlayerCar = 2; Car3.ThisCarSelected = true; ThisPlayerSelector.CurrentCar = Car3.ThisCarImage; Coin.transform.position = Car3.ThisCarIconPosition;
            }
            else if (!Car4.ThisCarSelected)
            {
                ThisPlayerCar = 3; Car4.ThisCarSelected = true; ThisPlayerSelector.CurrentCar = Car4.ThisCarImage; Coin.transform.position = Car4.ThisCarIconPosition;
            }

            ThisPlayerSelector.ImageSwapper();
        }

        ThisPlayerData = new PlayerData(playerID, ThisPlayerCar, ThisControlScheme, ThisPlayerType);
    }
Exemple #2
0
    void SelectCar()
    {
        t.transform.parent = Car.transform;               //The coin is given the car icon as a parent
        Car.GetComponent <Collider2D>().enabled = false;  //The collider of the car icon is deactivated. This car cannot be selected by other players
        ThisCarSelected = true;                           //Bool variable telling the player has selected this car
        m.is_this_ready = true;                           //This player has selected the car and is ready to GO
        l.num_ready_players++;                            // Increase the number of players who are ready to GO
        source.PlayOneShot(click);

        if (m.playerID == 1)
        {
            CPU.player.GetComponent <Collider2D>().enabled = true;
        }

        switch (m.playerID)   //Assign the car image to the correct player
        {
        case 1:
            p1.CurrentCar = ThisCarImage;
            p1.ImageSwapper();
            p1.Hand.sprite = p1.hand_opened;
            break;

        case 2:
            p2.CurrentCar = ThisCarImage;
            p2.ImageSwapper();
            p2.Hand.sprite = p2.hand_opened;
            break;

        case 3:
            p3.CurrentCar = ThisCarImage;
            p3.ImageSwapper();
            p3.Hand.sprite = p3.hand_opened;
            break;

        case 4:
            p4.CurrentCar = ThisCarImage;
            p4.ImageSwapper();
            p4.Hand.sprite = p4.hand_opened;
            break;
        }

        m.ThisPlayerCar = ThisCarType;
    }