Moves a 3D Cube (or any 3D object) from side to side on the X-axis according to the provided configuration from Google Sheets if available. The class loads the configuration from Google Docs each run of the game, so to see the effect of changing the doc, reload the game.
Inheritance: MonoBehaviour
Example #1
0
    // Use this for initialization
    void Start()
    {
        if (!photonView.isMine)
        {
            Debug.Log("Connecting the player input to the correct tentacle");
            // connects input to the correct tentacle

            TouchInputReader touchInputReader = GetComponent <TouchInputReader>();

            bool octoFound = false;

            // TODO: here try to find existing octopuses to connect to
            GameObject[] octos = GameObject.FindGameObjectsWithTag("Octopus");
            for (int i = 0; i < octos.Length; i++)
            {
                CubeMover[] movers = octos[i].GetComponentsInChildren <CubeMover>();

                for (int j = 0; j < movers.Length; j++)
                {
                    // check if the tentacle is already controlled by someone
                    if (!movers[j].HasInput())
                    {
                        // un-controlled tentacle found
                        movers[j].SetInput(touchInputReader);
                        octoFound = true;
                        Debug.Log("Connecting the player to tentacle in existing octopus");
                        break;
                    }
                }
            }

            if (!octoFound)
            {
                Debug.Log("Connecting the player to a tentacle in a new octopus");
                // if no octopus exists, create one
                GameObject startPos = GameObject.Find("OctopusStartingPos");
                GameObject octopus  = (GameObject)Instantiate(octopusPrefab, startPos.transform.position, Quaternion.identity);

                CubeMover mover = octopus.GetComponentInChildren <CubeMover>();
                mover.SetInput(touchInputReader);
            }
        }
    }