Exemplo n.º 1
0
    bool InitialiseGameState()
    {
        game        = new GameStruct();
        game.names  = new string[4];
        game.scores = new int[4];

        ball        = GameObject.Find("PhysicsBall").GetComponent <BallScript>();
        uiReference = GameObject.Find("Interface").GetComponent <InterfaceScript>();
        camera2DRef = GameObject.Find("TopDownCamera").GetComponent <Camera>();
        camera3DRef = GameObject.Find("PerspectiveCamera").GetComponent <Camera>();


        if (ball == null)
        {
            return(false);
        }
        else
        {
            ball.Init(this);
        }

        if (GameObject.Find("Player1"))
        {
            Debug.Log("found");
        }
        else
        {
            Debug.Log("not found");
        }
        for (int i = 0; i < paddles.Length; i++)
        {
            Debug.Log("searching for Paddle" + (i + 1));
            paddles[i] = GameObject.Find("Paddle" + (i + 1)).GetComponent <PaddleScript>();
            paddles[i].SetPaddlePosition(i);
            if (paddles[i] == null)
            {
                return(false);
            }
        }

        /*set paddle controllers
         * if (game.paddles == GamePaddles.two)
         * {
         *  if (game.playerRules == GamePlayerRules.single)
         *  {
         *      paddles[0].SetControllerType(2); //controller type 0 = keyboard, 1 = mouse, 2 = computer
         *      paddles[1].SetControllerType(2);
         *      paddles[2].DisablePaddle();
         *      paddles[3].DisablePaddle();
         *      game.names[0] = "Player1";
         *      game.names[1] = "Player2";
         *  }
         * }
         * else if (game.paddles == GamePaddles.four)
         * {
         *  if (game.playerRules == GamePlayerRules.single)
         *  {
         *      paddles[0].SetControllerType(2); //controller type 0 = keyboard, 1 = mouse, 2 = computer
         *      paddles[1].SetControllerType(2);
         *      paddles[2].SetControllerType(2);
         *      paddles[3].SetControllerType(2);
         *  }
         * }*/


        if (LoadSettings() == false)
        {
            Debug.Log("could not load settings");
            return(false);
        }

        //load ui after settings to get player names
        if (uiReference == null)
        {
            return(false);
        }
        else
        {
            uiReference.Init(this);
        }


        return(true);
    }