// Use this for initialization
    void Start()
    {
        lavaSphere  = transform.FindChild("LavaSphere").GetComponent <LavaSphereScript>();   //transform.GetChild(3).GetComponent<LavaSphereScript>();
        waterSphere = transform.FindChild("WaterSphere").GetComponent <WaterSphereScript>(); //transform.GetChild(4).GetComponent<WaterSphereScript>();

        chargeable = transform.GetComponentInChildren <ChargeableScript>();
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        //EnableFlash(false);
        Vector3    point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
        Ray        ray   = _camera.ScreenPointToRay(point);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            GameObject       hitObject  = hit.transform.gameObject;
            ChargeableScript chargeable = hitObject.GetComponentInChildren <ChargeableScript>();
            Meteor           meteor     = hitObject.GetComponentInParent <Meteor>();

            if (chargeable != null && !ChargeableScript.gameover)
            {
                EnableFlash(true);
                chargeable.Charge(Time.deltaTime * chargeSpeed);
                //Debug.Log("Target hit");
            }
            else if (meteor != null)
            {
                EnableFlash(true);
                meteor.HitBySun();
                //Debug.Log("Meteor hit");
            }
            else
            {
                EnableFlash(false);
                //Debug.Log("Deactivate!");
            }
        }
        else
        {
            EnableFlash(false);
        }
    }