コード例 #1
0
    void OnCollisionEnter2D(Collision2D hitInfo)
    {
        // enemy enemy = hitInfo.gameObject.GetComponent<enemy>();
        // if(enemy != null)
        // {
        //     enemy.TakeDamage(damage);

        // }

        cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>();

        if (player != null)
        {
            player.TakeDamage(damage);
        }

        // barrierdetails barrier = hitInfo.gameObject.GetComponent<barrierdetails>();
        // if(barrier != null)
        // {
        //     barrier.TakeDamage(damage);
        // }

        // //Debug.Log(hitInfo.gameObject.name);

        if (hitInfo.gameObject.tag != "bullets") // destroy if collide with anything/dont need?
        {
            // impact = Instantiate(impact, transform.position, Quaternion.identity); *create effect upon collide*
            GameObject     ParticleObject = Instantiate(Particle, transform.position, Quaternion.identity);
            ParticleSystem Effect         = ParticleObject.GetComponent <ParticleSystem>();
            var            main           = Effect.main;
            main.startColor = Sprite.color;
            Destroy(gameObject);
            // Destroy(impact, 0.5f);
        }
    }
コード例 #2
0
 void Start()
 {
     player          = GameObject.Find("Cubeman");
     CubeAttributes  = player.GetComponent <cube_attributes>();
     Color_Selection = player.GetComponent <color_selection>();
     SetColorDefault();
 }
コード例 #3
0
 void Start()
 {
     if (SceneManager.GetActiveScene().buildIndex == 2)
     {
         Player          = GameObject.Find("Cubeman");
         Cube_Attributes = Player.GetComponent <cube_attributes>();
         LoadColor();
     }
 }
コード例 #4
0
    //bullet spawning -------------------------------



    void OnCollisionEnter2D(Collision2D hitInfo)
    {
        cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>();

        if (player != null)
        {
            player.TakeDamage(30);
        }
    }
コード例 #5
0
ファイル: hp_boost.cs プロジェクト: kimbolls/Cubeman-The-Game
    void OnCollisionEnter2D(Collision2D hitInfo)
    {
        cube_attributes player = hitInfo.gameObject.GetComponent <cube_attributes>();

        if (player != null)
        {
            player.HealHP(HealValue);
            Destroy(gameObject);
        }
    }