public void SetGazedAt(bool gazedAt) { if (GameObject.FindWithTag("Player") != null) { GameObject localPlayer = GameObject.FindGameObjectWithTag("Player"); if (localPlayer.GetComponent <MP_PlayerController>() != null) { MP_PlayerController controller = localPlayer.GetComponent <MP_PlayerController>(); if (controller.player != null) { MP_Player mainPlayer = controller.player; if (mainPlayer.getSpellIndex() == 0 || (gazedAt == false && localPlayer.GetComponent <MP_PlayerController>().player.getSpellIndex() != 0)) { if (inactiveMaterial != null && gazedAtMaterial != null) { GetComponent <Renderer>().material = gazedAt ? gazedAtMaterial : inactiveMaterial; return; } GetComponent <Renderer>().material.color = gazedAt ? Color.green : Color.red; } } } } }
// Update is called once per frame void Update() { //Debug.Log ("Current Player Health: " + player.getHealth ()); // prevent non-local players from responding to input from the local system if (!isLocalPlayer) { return; } // Spell changing using gesture recognition if (GvrController.TouchDown) { prevTouchPos = GvrController.TouchPos; } if (GvrController.TouchUp) { touchPos = GvrController.TouchPos; int index = whichSwitch(prevTouchPos, touchPos); CmdSwitchSpell(index); } if (GvrController.AppButtonDown) { pauseMenu.SetActive(!pauseMenu.activeSelf); } else if (player.getSpellIndex() == 3 && !pauseMenu.activeSelf) { Shield(); } else if ((GvrController.ClickButtonDown || Input.GetMouseButtonDown(0)) && !pauseMenu.activeSelf) { if (player.getSpellIndex() == 0) { SetTeleport(); } else { CmdShoot(); } } if (teleporting) { float step = movementSpeed * Time.deltaTime; this.transform.position = Vector3.MoveTowards(this.transform.position, newPos, step); if (this.transform.position == newPos) { teleporting = false; } } /* * //Constant mana regeneration * if (player.getSpellIndex() != 3 || (player.getSpellIndex() == 3 && !GvrController.ClickButton)) * { * CmdManaRegen(); * } */ }