Esempio n. 1
0
        void Start()
        {
            gameEnd = false;
            //set the boundary of the game to put the peddle in the correct position
            bottomLeft = Camera.main.ScreenToWorldPoint(new Vector2(0, 0));
            topRight   = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
            Instantiate(ball);
            //Generate the left peddle and right peddle pass the parameter to the peddle acript and using it in the initialization
            Paddle paddleLeft  = Instantiate(paddle) as Paddle;
            Paddle paddleRight = Instantiate(paddle) as Paddle;

            paddleLeft.Init(false);
            paddleRight.Init(true);
            // Assign the ability to different player
            AbilityCoolDown rightCoolDownButtons = rightUI.GetComponentInChildren <AbilityCoolDown>();
            PaddleAbility   rightPeddleAbility   = peddleRightAbilitie;

            rightCoolDownButtons.Initialize(rightPeddleAbility.paddleAbility, paddleRight.gameObject);
            AbilityCoolDown leftCoolDownButtons = leftUI.GetComponentInChildren <AbilityCoolDown>();
            PaddleAbility   leftPeddleAbility   = peddleLeftAbilityies;

            leftCoolDownButtons.Initialize(leftPeddleAbility.paddleAbility, paddleLeft.gameObject);
        }