Exemplo n.º 1
0
 public void score(string name)
 {
     if (disk.findDisk(name).color == Color.green)
     {
         count++;
     }
     else if (disk.findDisk(name).color == Color.yellow)
     {
         count += 2;
     }
     else if (disk.findDisk(name).color == Color.red)
     {
         count += 3;
     }
 }
Exemplo n.º 2
0
    //检查玩家是否射中飞碟
    public void Hit(Vector3 pos)
    {
        Ray ray = Camera.main.ScreenPointToRay(pos);

        RaycastHit[] hits;
        hits = Physics.RaycastAll(ray);
        DiskModel hitDisk;

        for (int i = 0; i < hits.Length; i++)
        {
            RaycastHit hit = hits[i];
            hitDisk = diskFactory.findDisk(hit.collider.gameObject.GetInstanceID());

            //射线打中物体
            if (hitDisk != null)
            {
                score += hitDisk.score;

                //显示爆炸粒子效果
                hitDisk.disk.GetComponent <ParticleSystem>().Play();

                //等0.5秒后执行回收飞碟
                StartCoroutine(WaitingParticle(0.50f, diskFactory, hitDisk));
                break;
            }
        }
    }