示例#1
0
    private void RotateGear(int position, int source)
    {
        if (currentGearsObjects[position] != null)
        {
            currentGearsObjects[position].GetComponent <GearController>().Reverse = !currentGearsObjects[source].GetComponent <GearController>().Reverse;
            currentGearsObjects[position].GetComponent <Animator>().enabled       = true;

            // check if goal is reached
            if (position == targetGearId)
            {
                success = true;
                captionBackground.GetComponent <Animator>().enabled = true;
                remote.GetComponent <Animator>().SetBool("success", true);
                if (mainCamera != null)
                {
                    mainCamera.GetComponent <Animator>().SetBool("success", true);
                }
                tvStatic.GetComponent <Animator> ().SetBool("success", true);
                if (isCity == true)
                {
                    audioController.CitySuccess();
                }
                else
                {
                    audioController.Success();
                }
            }

            if (position < 20)
            {
                if (!IsMoving(position + 4))
                {
                    RotateGear(position + 4, position);
                }
            }

            // check up
            if (position > 3)
            {
                if (!IsMoving(position - 4))
                {
                    RotateGear(position - 4, position);
                }
            }

            // check right
            if (position % 4 < 3)
            {
                if (!IsMoving(position + 1))
                {
                    RotateGear(position + 1, position);
                }
            }

            // check left
            if (position % 4 > 0)
            {
                if (!IsMoving(position - 1))
                {
                    RotateGear(position - 1, position);
                }
            }
        }
    }