Esempio n. 1
0
    public void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.tag == "Enemy")
        {
            StaticData.Hp -= 5;
            EventCenter.Broadcast(EventType.ScoreType);
        }
        if (coll.tag == "Enemy3")
        {
            StaticData.Hp -= 10;
            EventCenter.Broadcast(EventType.ScoreType);
        }
        if (coll.tag == "Bullet3")
        {
            StaticData.Hp -= 5;
            EventCenter.Broadcast(EventType.ScoreType);
        }
        if (StaticData.PlyaerHP == 0)
        {
            // EventCenter.Broadcast(EventType.GameOver);
            JsonSingle.Single.PlayerJsonData.Clear();
            BaseFactory.ClearDict();
            StaticData.PlayerBool = false;
            EventCenter.m_EventTable.Clear();

            SceneManager.LoadSceneAsync(0);
        }
    }
Esempio n. 2
0
    //public Transform GunKou;
    //public Rigidbody2D bossbull;
    //void Start()
    //{
    //    Rigidbody2D bulletcolone;
    //    bulletcolone = (Rigidbody2D)Instantiate(bossbull, GunKou.position, GunKou.rotation);
    //    bulletcolone.velocity = transform.TransformDirection(Vector2.up * 2f);
    //}

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet_1" || other.tag == "Bullet_2" || other.tag == "Bullet_3")
        {
            switch (other.tag)
            {
            case "Bullet_1":
                GameManager.Single.PushGameObjectToFactory(FactoryType.GameFactory, Paths.PLAYER1_BULLET, other.gameObject);
                break;

            case "Bullet_2":
                GameManager.Single.PushGameObjectToFactory(FactoryType.Bullet_2, Paths.PLAYER2_BULLET, other.gameObject);
                break;

            case "Bullet_3":
                GameManager.Single.PushGameObjectToFactory(FactoryType.Bullet_3, Paths.PLAYER3_BULLET, other.gameObject);
                break;
            }

            AudioSourceManager.Single.PlayEffectMusic(GameManager.Single.GetAudioClip(Paths.AUDIO_ENEMY_1));
            _bossHp -= _attackDps * 0.1f;
            if (_bossHp <= 0)
            {
                Destroy(this.gameObject);
                //EventCenter.Broadcast(EventType.PassUI);
                JsonSingle.Single.PlayerJsonData.Clear();
                BaseFactory.ClearDict();
                StaticData.PlayerBool = false;
                EventCenter.m_EventTable.Clear();
                SceneManager.LoadSceneAsync(0);
            }
            transform.GetComponent <SpriteRenderer>().color = new Color(255, 255, 255, 0.5f);
            transform.Find("Boss2").GetComponent <SpriteRenderer>().color = new Color(255, 255, 255, 0.5f);
            Invoke("WaitColor", 0.05f);
        }
    }