Beispiel #1
0
 public void OnDrag(PointerEventData eventData)
 {
     if (_isInteract)
     {
         EventUtil.SendMessage(BallonEventType.BalloonInteractDraging, eventData.position);
     }
 }
Beispiel #2
0
 public ParticleSystem DestroySelf()
 {
     EventUtil.SendMessage(BallonEventType.Destroy, this);
     _mergeParticle.transform.SetParent(transform.parent);
     Destroy(this.gameObject);
     return(_mergeParticle);
 }
Beispiel #3
0
    private void onAddScore(object args)
    {
        _score += (int)args;
        if (_score > _topScore)
        {
            _topScore = _score;
            PlayerPrefs.SetInt("topScore", _topScore);
        }

        EventUtil.SendMessage(BallonEventType.ScoreChange, _score);
    }
Beispiel #4
0
 private void upgrade()
 {
     EventUtil.SendMessage(BallonEventType.AddScore, _config.score);
     _collider.enabled = false;
     this.Init(this._config.nextID);
     _collider.enabled = true;
     if (this._config.id > PlayerPrefs.GetInt("topBalloonID", 1))
     {
         PlayerPrefs.SetInt("topBalloonID", this._config.id);
     }
 }
Beispiel #5
0
 private void OnAdsSuccess()
 {
     _eraseTime     -= 1;
     _countText.text = _eraseTime.ToString();
     if (_eraseTime <= 0)
     {
         gameObject.SetActive(false);
     }
     _useState = State.Ready;
     _button.SetActive(false);
     EventUtil.SendMessage(BallonEventType.AdSuccess);
 }
Beispiel #6
0
 private void processCollide(Collision2D collision)
 {
     if (_shooting && (collision.collider.CompareTag("Ceil") || collision.collider.CompareTag("Balloon")))
     {
         isFinishShooting = true;
         _shooting        = false;
         EventUtil.SendMessage(BallonEventType.FinishLaunch, this);
         SoundManager.Instance.PlayImpactSound();
     }
     if (!_shooting)
     {
         var other = collision.collider.GetComponent <Balloon>();
         if (other && other._config.size == this._config.size)
         {
             merge(this, other, collision.GetContact(0).point);
         }
     }
 }
Beispiel #7
0
    private void mergeFrom(Balloon from, Vector2 contactPos)
    {
        if (this._config.nextID > 0)
        {
            if (this._config.nextID >= 1)
            {
                SoundManager.Instance.PlayMergeSound();
            }
            _mergeParticle.Stop();
            _mergeParticle.Play();
            upgrade();
            from._canMerge = false;
            //transform.position = new Vector3(contactPos.x, contactPos.y, transform.position.z);
            _canMerge = false;
            StartCoroutine(mergeCoroutine(from._image));

            EventUtil.SendMessage(BallonEventType.Destroy, from);
            Destroy(from.gameObject);
        }
    }
Beispiel #8
0
    public void OnPointerUp(PointerEventData eventData)
    {
        if (_isInTap)
        {
            Ray            ray  = Camera.main.ScreenPointToRay(eventData.position);
            RaycastHit2D[] hits = Physics2D.RaycastAll(ray.origin, ray.direction);
            foreach (var hit in hits)
            {
                var balloon = hit.collider.GetComponent <Balloon>();

                if (balloon)
                {
                    var particle = balloon.DestroySelf();
                    particle.Play();
                    SoundManager.Instance.PlayMergeSound();
                    StartCoroutine("ParticleDestroyCroutine", particle.gameObject);
                    _isInTap = false;
                    EventUtil.SendMessage(BallonEventType.EraseSuccess);
                    break;
                }
            }
        }
    }
Beispiel #9
0
 public void OnStartButtonClicked()
 {
     EventUtil.SendMessage(BallonEventType.StartGame);
 }
 public void OnNoButtonClicked()
 {
     EventUtil.SendMessage(BallonEventType.BackToMainMenu);
 }
 public void OnAdsSuccess()
 {
     EventUtil.SendMessage(BallonEventType.AdSuccess);
 }
Beispiel #12
0
 public void OnPointerUp(PointerEventData eventData)
 {
     _isInteract = false;
     EventUtil.SendMessage(BallonEventType.BalloonInteractEnd, eventData.position);
 }
Beispiel #13
0
 public void OnPointerDown(PointerEventData eventData)
 {
     _isInteract = true;
     EventUtil.SendMessage(BallonEventType.BalloonInteractBegin, eventData.position);
 }
    // Update is called once per frame
    void Update()
    {
        if (!_isGameStart)
        {
            return;
        }
        _shootTimer += Time.deltaTime;
        if (_currentBalloon == null && _shootTime <= _shootTimer)
        {
            _currentBalloon = randomGenerateBalloon();
            _currentBalloon.transform.position = _shooter.position;
        }
        _shooterLerpTimer += Time.deltaTime;
        float prograss = _shooterLerpTimer / _shooterLerpTime;

        _shooter.position = Vector3.Lerp(_oriShooterPos, _shooterTargetPos, prograss);

        if (_currentBalloon != null)
        {
            _currentBalloon.transform.position = _shooter.position;
        }
        var   currentTime   = Time.time;
        float nearestTime   = -1;
        var   shouldWarning = false;

        _finishImage.enabled = false;
        foreach (var balloon in _bollons)
        {
            if (balloon.isFinishShooting && balloon.inFinishAreaTime > 0)
            {
                _finishImage.enabled = true;
                shouldWarning        = true;
                var diff = currentTime - balloon.inFinishAreaTime;
                if (diff > nearestTime)
                {
                    nearestTime = diff;
                }
            }
            if (balloon.isFinishShooting && !_finishImage.enabled)
            {
                if (balloon.transform.position.y - _finishTransform.position.y < 2)
                {
                    _finishImage.enabled = true;
                }
            }
        }
        if (shouldCheckFinish())
        {
            if (shouldWarning)
            {
                float leftTime = _finishTime - nearestTime;
                if (leftTime > 0f)
                {
                    EventUtil.SendMessage(BallonEventType.GameoverWarning, Mathf.CeilToInt(leftTime));
                }
                else if (_gameState != GameState.ReadyToFinish)
                {
                    _gameState = GameState.ReadyToFinish;
                    EventUtil.SendMessage(BallonEventType.ReadyToFinish);
                }
            }
            else
            {
                EventUtil.SendMessage(BallonEventType.CancleGameoverWarning);
            }
        }
    }