Beispiel #1
0
    public void ShootBall()
    {
        if (MoveState == ePlayerState.Move)
        {
            return;
        }

        _instArrow.transform.localScale = new Vector3(0, 0, 0);
        isClickOn = false;

        Vector2 direction = _instArrow.transform.rotation * new Vector2(1, 0.0f) * _powerSize;



        BasketBallGame.BasketBall ball = _ballFactory.Get() as BasketBallGame.BasketBall;
        ball.ShotToTarget(direction);
        ball.Activate(transform.position, BasketBallGame.EBallOwner.LeftPlayer, "Ball");
        ball.destroyed += OnBallDestroyed;

        if (!NetworkManager.Instance.IsSinglePlay())
        {
            NetworkManager.Instance.SendRequestFireBall(_powerSize, direction.x, direction.y);
        }

        _powerSize = 0.0f;
    }
Beispiel #2
0
        public void ShootBall()
        {
            Vector2 direction = directionArrow.transform.rotation * new Vector2(aiFireSpeed, 0.0f) * _powerSize;

            _powerSize = 0.0f;

            BasketBall ball = _ballFactory.Get() as BasketBall;

            ball.Activate(transform.position, EBallOwner.RightPlayer, "AIBall");
            ball.ShotToTarget(direction);
            ball.destroyed += OnBallDestroyed;
        }
Beispiel #3
0
    public void ShootBallAuto()
    {
        isClickOn = false;

        Vector2 direction = _instArrow.transform.rotation * new Vector2(1, 0.0f) * _powerSize;

        _powerSize = 0.0f;

        BasketBallGame.BasketBall ball = _ballFactory.Get() as BasketBallGame.BasketBall;
        ball.ShotToTarget(direction);
        ball.Activate(transform.position, BasketBallGame.EBallOwner.AI, "AIBall");
        ball.destroyed += OnBallDestroyed;
    }
Beispiel #4
0
        void OnTriggerExit2D(Collider2D collision)
        {
            collision.transform.SetParent(null);
            if (collision.transform.CompareTag("Ball"))
            {
                --LeftBallCount;
                leftText.text = LeftBallCount.ToString();
            }
            if (collision.transform.CompareTag("AIBall"))
            {
                --RightBallCount;
                rightText.text = RightBallCount.ToString();
            }
            BasketBall basket = collision.GetComponent <BasketBall>();

            basket.SetActiveTraill(true);
        }
Beispiel #5
0
    public void ShootBall(float power, float angleX, float angleY)
    {
        if (MoveState == ePlayerState.Move)
        {
            return;
        }
        //Vector2 direction = _instArrow.transform.rotation * new Vector2(1, angleY) * power;
        Vector2 direction;

        direction.x = angleX;
        direction.y = angleY;

        BasketBallGame.BasketBall ball = _ballFactory.Get() as BasketBallGame.BasketBall;
        ball.ShotToTarget(direction);
        ball.Activate(transform.position, BasketBallGame.EBallOwner.LeftPlayer, "Ball");
        ball.destroyed += OnBallDestroyed;
    }
Beispiel #6
0
        void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.transform.CompareTag("Ball"))
            {
                ++LeftBallCount;
                leftText.text = LeftBallCount.ToString();
                AudioManager.Instance.PlaySound(eSoundId.Score);
                goalInEffectPrefab.PlayEffect(collision.transform);
            }
            else if (collision.transform.CompareTag("AIBall"))
            {
                ++RightBallCount;
                rightText.text = RightBallCount.ToString();
                AudioManager.Instance.PlaySound(eSoundId.Score);
                goalInEffectPrefab.PlayEffect(collision.transform);
            }

            BasketBall basket = collision.GetComponent <BasketBall>();

            basket.SetActiveTraill(false);
        }
Beispiel #7
0
 void OnBallDestroyed(BasketBall usedBall)
 {
     usedBall.destroyed -= OnBallDestroyed;
     _ballFactory.Restore(usedBall);
 }
Beispiel #8
0
 void OnBallDestroyed(BasketBallGame.BasketBall usedBall)
 {    //To Do: 게임매니저로 옮겨서 플레이어로 이어주도록 해야함.
     usedBall.destroyed -= OnBallDestroyed;
     _ballFactory.Restore(usedBall);
 }