Example #1
0
 // Use this for initialization
 void Start()
 {
     code           = GameObject.Find("GameManager").GetComponent <GameManager>();
     paddleCode     = GameObject.Find("Paddle").GetComponent <MovePaddle>();
     playPanelImage = GameObject.Find("PlayPanel").GetComponent <Image>();
     mainCamera     = GameObject.Find("Main Camera").GetComponent <Camera>();
 }
Example #2
0
 public static MovePaddle Instance()
 {
     if (instance == null)
     {
         instance = GameObject.FindObjectOfType <MovePaddle> ();
     }
     return(instance);
 }
Example #3
0
        void FixedUpdate()
        {
            if (_end)
            {
                return;
            }

            if (UnityEngine.Input.GetKey(KeyCode.W))
            {
                Client.BaseClient.Send(MovePaddle.Up(Game.Session.Id, Client.BaseClient.Secret), ProtocolType.Udp);
            }
            else if (UnityEngine.Input.GetKey(KeyCode.S))
            {
                Client.BaseClient.Send(MovePaddle.Down(Game.Session.Id, Client.BaseClient.Secret), ProtocolType.Udp);
            }
        }
Example #4
0
        void HandleMovePaddleMessage(MovePaddle message)
        {
            ServerPlayer player = GetPlayerBySecret(message.Secret);

            if (player == null)
            {
                return;
            }

            GameState session;

            if (!_sessions.TryGetValue(message.SessionId, out session))
            {
                return;
            }

            session.MovePaddle(player, message.Direction);
        }
Example #5
0
 public void SetGameModel(String gameId, GameLogic gameModel, short playerNumber)
 {
     if (playerNumber == 1)
     {
         this.paddleModel        = gameModel.paddle1;
         this.movePaddleFunction = gameModel.MovePaddle1;
     }
     else
     {
         this.paddleModel        = gameModel.paddle2;
         this.movePaddleFunction = gameModel.MovePaddle2;
     }
     this.playerNumber     = playerNumber;
     this.gameId           = gameId;
     this.gameModel        = gameModel;
     this.lowerBoundGridX  = gameModel.lowerBoundGridX;
     this.higherBoundGridX = gameModel.higherBoundGridX;
 }
Example #6
0
    // Use this for initialization
    public void Start()
    {
        DayAndNightCycle(true);
        settingsCode       = GameObject.FindObjectOfType <Settings>();
        paddleSensitivity  = settingsCode.Sensitivity;
        ballCode           = ballObject.GetComponent <MoveBall>();
        ballSprite         = ballObject.GetComponent <SpriteRenderer>();
        paddleCode         = paddleObject.GetComponent <MovePaddle>();
        paddleSprite       = paddleObject.GetComponent <SpriteRenderer>();
        paddleSpriteOGSize = paddleSprite.size;

        scoreText.text  = "SCORE: " + points.ToString("D8");
        powerTx.enabled = false;
        SetCreditText();
        settingsCode.GetLeaderboard();
        bestScore       = settingsCode.LeaderboardScores[0];
        rankedText.text = string.Empty;
        LoadLvl();
        InitBallSpeed();
    }
Example #7
0
    public void OnCollisionEnter(Collision c)
    {
        //if (!isSetByPaddle) {
        Vector3 inDirection = transform.up;

        inDirection.z = 0;
        Vector3 outDirection = Vector3.Reflect(inDirection, c.contacts[0].normal);

        outDirection.z = 0;
        Quaternion rotation = Quaternion.FromToRotation(transform.up, outDirection) * transform.rotation;

        GetComponent <Rigidbody>().MoveRotation(rotation);
        //}

        if (c.gameObject.name == "Block")
        {
            Destroy(c.gameObject);
            Gameplay.Instance().OnScore();
            MovePaddle.Instance().PaddleExtend();
            if (Random.Range(0, 10) <= 3 && GameObject.FindObjectsOfType <BallMotion>().Length == 1)
            {
                StartCoroutine(Double());
            }
        }
        else if (c.gameObject.name == "Bottom")
        {
            //store player score
            if (isPlayer)
            {
                Application.LoadLevel("GameOver");
            }
            else
            {
                DestroyObject(gameObject);
            }
        }
        else if (c.gameObject.name == "EasterEgg")
        {
            Application.LoadLevel("EasterEgg");
        }
    }