示例#1
0
    void Update()
    {
        LevelTime += Time.deltaTime;


#if UNITY_ANDROID || UNITY_IPHONE
        if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
        {
            Vector3 MousePos = Input.touches[0].position;
#else
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 MousePos = Input.mousePosition;
#endif

            MousePos.z = 20.0f;

            RaycastHit Hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(MousePos), out Hit))
            {
                Barrel Brl = Hit.collider.GetComponent <Barrel>();

                if (Brl != null)
                {
                    Brl.Activate();
                }
            }
        }
    }

    void FixedUpdate()
    {
        foreach (Target T in Targets)
        {
            if (!T.AtDestination)
            {
                return;
            }
        }

        // level complete
        if (!Win)
        {
            Win = true;

            if (Application.loadedLevel + 1 > HighestLevel)
            {
                HighestLevel = Application.loadedLevel + 1;
                PlayerPrefs.SetInt("Highest Level", HighestLevel);
            }
        }
    }