Пример #1
0
    //New keywords is used to hide the default Unity camera keyword for this one.

    void Start()
    {
        state            = 0;
        round            = 1;
        timer            = 90f;
        scores[0]        = 0;
        scores[1]        = 0;
        currPlayer       = 0;
        currCreator      = 1;
        ranTwice         = false;
        playerReachedEnd = false;
        roundStarted     = false;

        if (maxRounds <= 0)
        {
            maxRounds = 5;
        }

        spawnedContainer = transform.FindChild("spawnedContainer").gameObject;
        camera           = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        scoreboardCanvas = Instantiate(scoreboardCanvas);
        scoreboard       = scoreboardCanvas.transform.FindChild("Scoreboard").GetComponent <Scoreboard>();
        scoreboardCanvas.SetActive(false);
        MatchSettingsHolder SettingsManager = GameObject.Find("ColorHolder").GetComponent <MatchSettingsHolder> ();

        player1Color = SettingsManager.player1Color;
        player2Color = SettingsManager.player2Color;

        //SpriteRenderer SprRen = new SpriteRenderer ();
        //SprRen.sprite = scoreboardSprites [0];
        //SprRen.color = player1Color;
        //SpriteRenderer SprRen2 = new SpriteRenderer ();
        //SprRen2.sprite = scoreboardSprites [1];
        //SprRen2.color = player2Color;
    }
Пример #2
0
    // Use this for initialization
    void Awake()
    {
        timerText    = transform.Find("PhaseSwitch").GetComponent <Text> ();
        roundText    = transform.Find("Round#").GetComponent <Text> ();
        p1ScoreText  = transform.Find("Player1Score").GetComponent <Text> ();
        p2ScoreText  = transform.Find("Player2Score").GetComponent <Text> ();
        infoText     = transform.Find("Info").GetComponent <Text> ();
        p1Role       = transform.Find("Player1Role").GetComponent <Image> ();
        p2Role       = transform.Find("Player2Role").GetComponent <Image> ();
        loserTextsP1 = transform.Find("LoserTextsP1").gameObject;
        loserTextsP2 = transform.Find("LoserTextsP2").gameObject;
        loserTextsP1.SetActive(false);
        loserTextsP2.SetActive(false);
        MatchSettingsHolder SettingsManager = GameObject.Find("SettingsHolder").GetComponent <MatchSettingsHolder> ();
        Color temp1 = SettingsManager.player1Color;
        Color temm2 = SettingsManager.player2Color;

        color1 = new Color(temp1.r, temp1.g, temp1.b, 255);
        color2 = new Color(temm2.r, temm2.g, temm2.b, 255);

        /*
         * Debug.Log ("Creating...");
         * roleSprites = new SpriteRenderer[2];
         * roleSprites [0] = new SpriteRenderer (); //gameObject.GetComponent<SpriteRenderer> ();
         * roleSprites [0].sprite = roles [0];
         * roleSprites [0].color = GameObject.Find ("Game").GetComponent<GC2> ().player1Color;
         * roleSprites [1] = new SpriteRenderer (); //gameObject.GetComponent<SpriteRenderer> ();
         * roleSprites [1].sprite = roles [1];
         * roleSprites [1].color = GameObject.Find ("Game").GetComponent<GC2> ().player2Color;
         * Debug.Log ("Finished...");
         */
    }
Пример #3
0
    //New keywords is used to hide the default Unity camera keyword for this one.

    void Start()
    {
        state            = 0;
        round            = 1;
        timer            = 90f;
        scores[0]        = 0;
        scores[1]        = 0;
        currPlayer       = 0;
        currCreator      = 1;
        ranTwice         = false;
        playerReachedEnd = false;
        roundStarted     = false;

        if (maxRounds <= 0)
        {
            maxRounds = 5;
        }

        spawnedContainer = transform.FindChild("spawnedContainer").gameObject;
        camera           = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        scoreboardCanvas = Instantiate(scoreboardCanvas);
        scoreboard       = scoreboardCanvas.transform.FindChild("Scoreboard").GetComponent <Scoreboard>();
        scoreboardCanvas.SetActive(false);

        SettingsManager = GameObject.Find("SettingsHolder").GetComponent <MatchSettingsHolder> ();
        player1Color    = SettingsManager.player1Color;
        player2Color    = SettingsManager.player2Color;
        twoControllers  = SettingsManager.useTwoControllers;

        mapSlectionUI = GameObject.Find("MapSelectionCanvas").GetComponent <MapSelection>();
        mapSlectionUI.gameObject.SetActive(false);
        selectingMap = false;

        maxRounds  = SettingsManager.rounds;
        randomMaps = SettingsManager.randomMaps;

        //set up music objects
        createSource = GameObject.Find("CreatorMusic").GetComponent <AudioSource>();
        runnerSource = GameObject.Find("PlayerMusic").GetComponent <AudioSource>();
        menuSource   = GameObject.Find("MenuMusic").GetComponent <AudioSource>();
        startMusic   = true;
        createSource.Play();
        AudioSource temp = GameObject.Find("BackgroundMusic").GetComponent <AudioSource>();

        temp.Stop();
    }
Пример #4
0
    void Update()
    {
        float leftX = Input.GetAxisRaw("L_XAxis_1");
        float leftY = Input.GetAxisRaw("L_YAxis_1");

        if ((Mathf.Abs(leftX) > 0.1f || Mathf.Abs(leftY) > 0.1f) && canInteract)
        {
            canInteract = false;
            StartCoroutine(SelectionChange(leftX, leftY));
        }

        if (Input.GetButtonDown("RB_1"))
        {
            colorSelected[0]++;
            if (colorSelected[0] >= availColors.Length)
            {
                colorSelected [0] = 0;
            }
        }
        if (Input.GetButtonDown("LB_1"))
        {
            colorSelected [0]--;
            if (colorSelected[0] < 0)
            {
                colorSelected[0] = availColors.Length - 1;
            }
        }
        if (Input.GetButtonDown("RB_2") || (!twoControllers && Input.GetButtonDown("Y_1")))
        {
            colorSelected[1]++;
            if (colorSelected[1] >= availColors.Length)
            {
                colorSelected [1] = 0;
            }
        }
        if (Input.GetButtonDown("LB_2") || (!twoControllers && Input.GetButtonDown("X_1")))
        {
            colorSelected [1]--;
            if (colorSelected[1] < 0)
            {
                colorSelected[1] = availColors.Length - 1;
            }
        }
        UpdateCharacters();

        if (Input.GetButtonDown("B_1"))
        {
            SceneManager.LoadScene("NewMainMenu");
        }
        if (Input.GetButtonDown("Start_1"))
        {
            MatchSettingsHolder msh = GameObject.Find("SettingsHolder").GetComponent <MatchSettingsHolder> ();
            msh.player1Color      = new Color(availColors [colorSelected [0]].r, availColors [colorSelected [0]].g, availColors [colorSelected [0]].b, 1f);
            msh.player2Color      = new Color(availColors [colorSelected [1]].r, availColors [colorSelected [1]].g, availColors [colorSelected [1]].b, 1f);
            msh.useTwoControllers = twoControllers;
            msh.rounds            = rounds;
            msh.randomMaps        = randomMap;
            if (randomMap)
            {
                SceneManager.LoadScene("FinalGame");
            }
            else
            {
                SceneManager.LoadScene("MapSelection");
            }
        }
    }