Пример #1
0
 void Deactivate()
 {
     for (int i = 0; i < childCount + 1; i++)
     {
         Active deactivateScript = (Active)ObjectList[i].GetComponent(typeof(Active));
         deactivateScript.Deactivate();
     }
 }
Пример #2
0
    void CheckShoot()
    {
        RaycastHit hit;

        if (Physics.Raycast(gameCamera.transform.position, gameCamera.transform.forward, out hit) && (hit.transform.tag == "Target" || hit.transform.tag == "Chain"))
        {
            Active checkActive = (Active)hit.transform.gameObject.GetComponent(typeof(Active));
            if (checkActive.active)
            {
                if (hit.transform.tag == "Target")
                {
                    int index = 0;
                    for (int i = 0; i < TargetList.Count; i++)
                    {
                        if ((hit.transform.position.x == TargetList[i].transform.position.x) && (hit.transform.position.z == TargetList[i].transform.position.z))
                        {
                            index = i;
                        }
                    }
                    Destroy(TargetList[index]);
                    TargetList.RemoveAt(index);
                    activeTargets--;
                    UpdateScore(25);
                }

                if (hit.transform.tag == "Chain")
                {
                    hit.transform.gameObject.GetComponentInChildren <MeshRenderer>().enabled   = false;
                    hit.transform.gameObject.GetComponentInChildren <SphereCollider>().enabled = false;
                    int index = 0;
                    for (int i = 0; i < TargetList.Count; i++)
                    {
                        if ((hit.transform.position.x == TargetList[i].transform.position.x) && (hit.transform.position.z == TargetList[i].transform.position.z))
                        {
                            index = i;
                        }
                    }

                    CreateTarget targetScript = (CreateTarget)TargetList[index].GetComponent(typeof(CreateTarget));
                    targetScript.DropObjectAtHeight(hit.transform.position.y);

                    Active deactivateScript = (Active)TargetList[index].GetComponent(typeof(Active));
                    deactivateScript.Deactivate();

                    activeTargets--;
                    UpdateScore(50);
                }

                if (activeTargets <= 0)
                {
                    rest = true;
                }
            }
        }
    }