コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        // set the game manager instance, add the listener to the cancel button
        _gameManager = GameManager.Instance;
        cancelButton.onClick.AddListener(OnClick);



        // make the target score for the player and display it
        CreateDisplayTargetScore();



        _pongManager = GameObject.Find("PongManager").GetComponent <PongManager>();

        _partnerOwner = _gameManager.GetManagerOwnerName(); // we get the owner of the arcade machine from the game manager
        // it's in the game manager because the scope of the arcade machine owner transcends a single scene.
        // it will be used for scoring the managers.

        // makes sure that score to win is above minimum for game objectives to work.
        if (scoreToWin < 2)
        {
            scoreToWin = 2;
        }
    }
コード例 #2
0
    public override void OnStartClient()
    {
        CanvasScaler scaler = transform.GetComponent <CanvasScaler>();

        Bar.deltaScaler = scaler.referenceResolution.y / Screen.height;

        Transform panel = transform.Find("Panel");

        oppBar = panel.Find("OppBar").GetComponent <Bar>();
        ball   = panel.Find("Ball").GetComponent <Ball>();
        ball.Reset();
        mainMenu = panel.GetComponent <LobbyMainMenu>();

        if (NetworkClient.allClients.Count > 0)
        {
            NetworkClient client = NetworkClient.allClients[0];
            client.RegisterHandler(PongMsgType.Start, OnStartMessage);
            PongMessage.client = client;
        }

        string user_id, token;

        PongManager.GetUserIdAndToken(out user_id, out token);
        PongMessage.SendReady(user_id, token);
    }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //if (collision.gameObject.name == "")
        //if (collision.gameObject.tag == "")
        if (collision.gameObject.CompareTag("Match/Paddle"))
        {
            rigid.velocity = -rigid.velocity;
            collision.gameObject.transform.parent.GetComponent <Animator>().SetTrigger("willHit");
        }
        else if (collision.gameObject.CompareTag("Match/Goal"))
        {
            print("GOLO DO MAREGA");
            //StartCoroutine(GameObject.Find("Manager").GetComponent<PongManager>().StartBall());
            if (collision.gameObject.name == "WallRight")
            {
                GlobalVariablesManager.Instance.PointsP1++;
            }
            else
            {
                GlobalVariablesManager.Instance.PointsP2++;
            }
            print("SCORE P1: " + GlobalVariablesManager.Instance.PointsP1
                  + " P2: " + GlobalVariablesManager.Instance.PointsP2);

            PongManager auxManager = GameObject.Find("Manager").GetComponent <PongManager>();
            auxManager.ChangeState(PongManager.MatchState.ready);
            auxManager.ChangeScoreText();
        }
        else if (collision.gameObject.CompareTag("Match/Wall"))
        {
            rigid.velocity = new Vector2(rigid.velocity.x, -rigid.velocity.y);
        }
    }
コード例 #4
0
ファイル: Ball.cs プロジェクト: Niller/Pong
 public Ball(Vector2 startPosition, float size, float speed, float speedIncrement)
 {
     Position        = startPosition;
     Size            = size;
     Speed           = speed;
     _speedIncrement = speedIncrement;
     Direction       = Random.insideUnitCircle.normalized;
     PongManager     = ServiceLocator.Get <PongManager>();
 }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: rubyleehs/Love-Pong
 private void Awake()
 {
     if (chatManager == null)
     {
         chatManager = GetComponent <Dialogue.ChatManager>();
     }
     if (pongManager == null)
     {
         pongManager = GetComponent <PongManager>();
     }
 }
コード例 #6
0
    void Awake()
    {
        _rb         = GetComponent <Rigidbody>();
        _meshPaddle = GetComponent <MeshFilter>().mesh;

        _manager  = transform.parent.GetComponent <PongManager>();
        _colWall1 = _manager.WallNorth.GetComponent <Collider>();
        _colWall2 = _manager.WallSouth.GetComponent <Collider>();

        northWallBottom = _colWall1.bounds.center.y - _colWall1.bounds.extents.y;
        southWallTop    = _colWall2.bounds.center.y + _colWall2.bounds.extents.y;
    }
コード例 #7
0
        public override void Enter()
        {
            _inputSystem = ServiceLocator.Get <IInputSystem>();
            ServiceLocator.Get <GuiManager>().Open(GuiViewType.Match, true);

            var difficult = (int)FsmManager.GetBlackboardValue("Difficult");

            _pongManager = CreatePongManager();
            _pongManager.Initialize(ServiceLocator.Get <SettingsManager>().Config.Difficulties[difficult]);
            _pongManager.SpawnPaddles();
            _pongManager.SpawnBall();

            SignalBus.Invoke(new GameStartedSignal(_pongManager.Paddle1, _pongManager.Paddle2));
        }
コード例 #8
0
ファイル: PongClientForm.cs プロジェクト: mcdobr/ds-labs
        private void PongClientForm_Load(object sender, EventArgs e)
        {
            RemotingConfiguration.Configure("PongClient.exe.config");

            pongManager = new PongManager();
            playerID    = pongManager.connectPlayer();
            playerSide  = pongManager.getPlayerSide(playerID);
            coords      = pongManager.getRoomCoords(playerID);


            this.ClientSize = new Size(RoomInfo.GAME_WIDTH, RoomInfo.GAME_HEIGHT);

            gameClock          = new Timer();
            gameClock.Interval = TIMER_INTERVAL;
            gameClock.Tick    += onGameClockTick;
            gameClock.Start();
        }
コード例 #9
0
ファイル: PongManager.cs プロジェクト: Nam-DaeHyeon/Toon_AOS
 private void Awake()
 {
     instance = this;
 }
コード例 #10
0
ファイル: BallControl.cs プロジェクト: mgovilla/FBLA-QFS
    private Rigidbody rigid;                                                            //For physics for the ball

    /*Initialize the variables*/
    void Start()
    {
        manager     = GameObject.Find("GameManager");
        pongManager = manager.GetComponent <PongManager>();
        rigid       = gameObject.GetComponent <Rigidbody>();
    }
コード例 #11
0
 /*Initialize the variables*/
 void Start()
 {
     manager     = UnityEngine.GameObject.Find("GameManager");
     pongManager = manager.GetComponent <PongManager>();
 }
コード例 #12
0
ファイル: Goal.cs プロジェクト: canadar/pong-twisted
 private void Start()
 {
     _gameManager = GetComponentInParent <PongManager>();
 }
コード例 #13
0
ファイル: PongManager.cs プロジェクト: pyh0884/Arkapong
 private void Start()
 {
     instance = this;
     timer    = timeCount;
     StartCoroutine(StartTimer());
 }