예제 #1
0
 public void SetInput(TouchInputReader reader)
 {
     input       = reader;
     reachTarget = playerDirection.FindChild("ReachTarget");
     Debug.Log("playerid " + input.photonView.owner.ID);
     playerIndicator.transform.FindChild("playerno").gameObject.GetComponent <TextMesh>().text       = "" + input.photonView.owner.ID;
     playerIndicator.transform.FindChild("playernoshadow").gameObject.GetComponent <TextMesh>().text = "" + input.photonView.owner.ID;
 }
예제 #2
0
파일: GrabHandler.cs 프로젝트: lanxu/FGJ15
 // Update is called once per frame
 void Update()
 {
     if (inputHandler == null)
     {
         GameObject go = GameObject.FindGameObjectWithTag("InputHandler");
         if (go == null)
         {
             return;
         }
         inputHandler = go.GetComponent <TouchInputReader>();
     }
     if (inputHandler == null)
     {
         return;
     }
 }
예제 #3
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);
            }
        }
    }