Ejemplo n.º 1
0
 void Start()
 {
     timeLeft       = maxTime;
     txtTimer.text  = "" + (int)timeLeft;
     ballCtrl       = ball.GetComponent <BallCtrl>();
     singleplayMode = PlayerPrefs.GetInt("Singleplay") == 1 ? true : false;
 }
Ejemplo n.º 2
0
    //public GameObject Win;


    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
    }
Ejemplo n.º 3
0
    public void AssignInput(PlayerSpawner _pSpawn, int _numPlayers, bool _singlePlayerController, InfoPasser.Controls _controls)
    {
        if (_pSpawn.GetPlayer == null)
        {
            Debug.Log("NULL PLAYER");
            return;
        }
        GameObject user = _pSpawn.GetPlayer;
        Ball       ball = user.GetComponent <Ball>();

        ball.AttachedPlayers = new BallCtrl[_numPlayers];
        for (int x = 0; x < _numPlayers; x++)
        {
            GameObject obj = new GameObject("Player " + x);
            obj.transform.SetParent(user.transform);
            obj.AddComponent <BallCtrl>();
        }
        //current player we are assigning input too
        int curPlayer = 0;
        //number of players on the ball
        int size = user.transform.childCount;

        //looping through all the input/controls we need to assign to the players on the ball
        for (int x = 0; x < m_InputList.Count; x++)
        {
            //get the transform so we can get the gameobj
            Transform t = user.transform.GetChild(curPlayer);
            //get the ballctrl on the child transform/gameobj
            BallCtrl b = t.gameObject.GetComponentInChildren <BallCtrl>();
            //the player arry in the ball, assign a ballctrl to it
            ball.AttachedPlayers[curPlayer] = b;
            //error checking
            if (b == null)
            {
                Debug.Log("ASSIGN INPUT B IS NULL");
                return;
            }
            //add the input that the player will be responceable for
            b.m_Controls.Add((InputControlsBall)x);
            //set names for unity to read input
            b.SetNames((InputControlsBall)m_InputList[x], curPlayer, _singlePlayerController, _controls);
            //we need to make sure the current player never excides
            if (curPlayer + 1 >= size)
            {
                curPlayer = 0;
            }
            else
            {
                curPlayer++;
            }
        }
    }
Ejemplo n.º 4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        BallCtrl.setIsWinTrue();
        if (col.gameObject.CompareTag("Player"))
        {
            SFXCtrl.instance.WinSparkles(gameObject.transform.position);
            //AudioCtrl.instance.playerwin (gameObject.transform.position);
            Invoke("LevelCompletePanel", 0.5f);


            //	col.gameObject.transform.position.x = 0;
            //SceneManager.LoadScene ("Level2");
        }
    }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     ballCtrl       = FindObjectOfType <BallCtrl>();
     singleplayMode = PlayerPrefs.GetInt("Singleplay") == 1 ? true : false;
 }
Ejemplo n.º 6
0
 void OnTriggerEnter2D(Collider2D col)
 {
     //AudioCtrl.instance.playerDead(gameObject.transform.position);
     BallCtrl.setIsDeadTrue();
 }
Ejemplo n.º 7
0
 private void boardCtrl_BallClick(BoardCtrl ctrl, BallCtrl ballCtrl)
 {
     _game.Board.SelectBall(ballCtrl.Ball);
 }