コード例 #1
0
    //public bool HasParrentObject = false;

    void OnCollisionEnter(Collision other)
    {
        GameObject target = other.gameObject;

        stupidColors playerScript = target.GetComponent <stupidColors>();
        Shooting     shootScript  = Gun.GetComponent <Shooting>();

/*
 *      if (playerScript != null)
 *          playerScript.HP -= damage;
 */


        if (playerScript != null)                   //bullet hits other turtle
        {
            if (shotType == playerScript.charaType) //colors match
            {
                //Destroy(target);
                //activate explode.exe
                explode(shotType);

                Destroy(gameObject);
            }
            else//colors dont match
            {
                if (shotType == 0)
                {
                    shootScript.weaponSelect = playerScript.charaType;
                    Destroy(target);
                    //set parent object to playerScript.charaType
                    Destroy(gameObject);
                }
                else
                {
                    SpawnTurtle(shotType);
                }
            }
        }
        else//turtle hits wall
        {
            SpawnTurtle(shotType);
        }
    }
コード例 #2
0
    void OnTriggerStay(Collider other)
    {
        GameObject target = other.gameObject;

        stupidColors playerScript = target.GetComponent <stupidColors>();

        if (playerScript != null)
        {
            if (charaType == playerScript.charaType)
            {//found another thing
             //increment score

                if (charaType == 1)
                {
                    GameObject redExplosion = Instantiate(prefaba) as GameObject;
                    redExplosion.transform.position = target.transform.position;
                }
                else if (charaType == 2)
                {
                    GameObject blueExplosion = Instantiate(prefabb) as GameObject;
                    blueExplosion.transform.position = target.transform.position;
                }
                else if (charaType == 3)
                {
                    GameObject yellowExplosion = Instantiate(prefabc) as GameObject;
                    yellowExplosion.transform.position = target.transform.position;
                }
                else if (charaType == 4)
                {
                    GameObject greenExplosion = Instantiate(prefabd) as GameObject;
                    greenExplosion.transform.position = target.transform.position;
                }
                else if (charaType == 5)
                {
                    GameObject grayExplosion = Instantiate(prefabe) as GameObject;
                    grayExplosion.transform.position = target.transform.position;
                }
            }
        }
    }