Exemple #1
0
 protected void Score()
 {
     if (OnScored != null)
     {
         OnScored.Invoke();
     }
 }
Exemple #2
0
    protected virtual void Score(int s, Vector2?pos = null, bool flashBottom = true, int sndIdx = 0)
    {
        int    _score;
        string _text;
        Color  _color;

        switch (s)
        {
        default:
            _score = badScore;
            _text  = "Miss";
            _color = Color.grey;
            ++Scoring.missCount;
            break;

        case 1:
            _score = goodScore;
            _text  = "Good";
            _color = Color.red;    //green
            ++Scoring.goodCount;
            break;

        case 2:
            _score = perfectScore;
            _text  = "Perfect";
            _color = Color.yellow;
            ++Scoring.perfectCount;
            break;
        }
        RhythmGameManager.UpdateScore(_score);
        lastScorePos = pos == null?GetExit().center : pos.Value;

        if (coloringParts.Length > 0 && !noAnim && s >= 1)
        {
            BlockEnlarge.Create(noteImages[sndIdx], _color, lastScorePos.Value, lastScorePos.Value + new Vector2(panel == PanelType.Left ? BlockSize.x : -BlockSize.x, BlockSize.y), rt.parent);
        }

        if (s >= 1)
        {
            if (sound.Length > 0 && allScores.Count == 0 && s == 1)
            {
                sound[0].Play(1);                                                     // 按到good时声效不会按时播放
            }
            if (flashBottom && coloringParts.Length > 0)
            {
                Bottom.SetColor(panel, coloringParts[0].color * 0.75f);                                          // 底边变色
            }
        }
        else
        {
            if (sound.Length > 0 && allScores.Count == 0)
            {
                sound[0].Play(0);                                           // 按到miss时声效不会按时播放
            }
            FlyingText.Create(_text, _color, lastScorePos.Value, rt.parent);
        }
        allScores.Add(new ScoreRecord(Time.time - createTime, s));
        OnScored?.Invoke(s);
    }
Exemple #3
0
 void DamageCore(int amount = -1)
 {
     _currentReactorHealth += amount;
     if (_currentReactorHealth <= 0)
     {
         OnScored?.Invoke(_scoreValue);
         OnDestroyed?.Invoke();
         int        explosionID = _explosionPrefab.GetExplosionID();
         GameObject explosion   = OnGetExplosion?.Invoke(explosionID);
         explosion.transform.position = transform.position;
         explosion.SetActive(true);
         gameObject.SetActive(false);
     }
 }
Exemple #4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            OnDamagePlayer?.Invoke(-_damage);
            int        explosionID = _explosionPrefab.GetExplosionID();
            GameObject explosion   = OnGetExplosion?.Invoke(explosionID);
            if (explosion != null)
            {
                explosion.transform.position = transform.position;
                explosion.SetActive(true);
            }
            gameObject.SetActive(false);
        }

        if (other.tag == "Laser")
        {
            OnScored?.Invoke(_scoreValue);
            other.gameObject.SetActive(false);
            int        explosionID = _explosionPrefab.GetExplosionID();
            GameObject explosion   = OnGetExplosion?.Invoke(explosionID);
            explosion.transform.position = transform.position;
            explosion.SetActive(true);
            gameObject.SetActive(false);
        }

        if (other.tag == "Omni Shot")
        {
            OnScored?.Invoke(_scoreValue);
            int        explosionID = _explosionPrefab.GetExplosionID();
            GameObject explosion   = OnGetExplosion?.Invoke(explosionID);
            explosion.transform.position = transform.position;
            explosion.SetActive(true);
            gameObject.SetActive(false);
        }
    }
Exemple #5
0
 /// <summary>
 /// Fires when drone flies past obstacles
 /// </summary>
 public void EventScored()
 {
     OnScored?.Invoke();
 }
Exemple #6
0
 /// <summary>
 /// Fires when drone flies past obstacles
 /// </summary>
 public void EventScored(int points)
 {
     OnScored?.Invoke(points);
 }
Exemple #7
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Omni Shot")
        {
            if (_isShieldActive == true)
            {
                _currentShieldStrength--;

                if (_currentShieldStrength > 0)
                {
                    ChangeShield(_currentShieldStrength);
                    return;
                }

                _isShieldActive = false;
                _shieldVisual.SetActive(false);
                return;
            }

            if (_player.gameObject.activeInHierarchy == true)
            {
                OnScored?.Invoke(_scoreValue);
            }

            if (_isDead == false)
            {
                PlayClip(_explosionClip);
                _isDead = true;
            }

            _anim.SetTrigger("Destroyed");
            _speed = 0;
            gameObject.GetComponent <Collider2D>().enabled = false;
            StartCoroutine(DisableRoutine());
        }

        if (other.tag == "Laser")
        {
            other.gameObject.SetActive(false);

            if (_isShieldActive == true)
            {
                _currentShieldStrength--;

                if (_currentShieldStrength > 0)
                {
                    ChangeShield(_currentShieldStrength);
                    return;
                }

                _isShieldActive = false;
                _shieldVisual.SetActive(false);
                return;
            }

            if (_player.gameObject.activeInHierarchy == true)
            {
                OnScored?.Invoke(_scoreValue);
            }

            if (_isDead == false)
            {
                PlayClip(_explosionClip);
                _isDead = true;
            }

            _anim.SetTrigger("Destroyed");
            _speed = 0;
            gameObject.GetComponent <Collider2D>().enabled = false;
            StartCoroutine(DisableRoutine());
        }

        if (other.tag == "Player")
        {
            if (_player.gameObject.activeInHierarchy == true)
            {
                OnDamagePlayer?.Invoke(-_ramDamage);
            }

            if (_isShieldActive == true)
            {
                _currentShieldStrength--;

                if (_currentShieldStrength > 0)
                {
                    ChangeShield(_currentShieldStrength);
                    return;
                }

                _isShieldActive = false;
                _shieldVisual.SetActive(false);
                return;
            }

            if (_isDead == false)
            {
                PlayClip(_explosionClip);
                _isDead = true;
            }

            _anim.SetTrigger("Destroyed");
            _speed = 0;
            gameObject.GetComponent <Collider2D>().enabled = false;
            StartCoroutine(DisableRoutine());
        }
    }
Exemple #8
0
 internal void ScoreObject(int id, int scores, int?taskId)
 {
     OnScored?.Invoke(new ScoreObjectArgs(id, scores, taskId));
 }