/// <summary> /// Works as the psuedo-constructor /// </summary> /// <param name="combat">Combat player with the health</param> /// <param name="playerType">Type of player</param> /// <param name="avatar">The avatar of the player</param> public void Init(VRCombat combat, PlayerType playerType, Transform avatar) { player = combat; typeOfPlayer = playerType; playerAvatar = avatar; maxHealth = player.health; }
/// <summary> /// Used as a 'constructor' of sorts /// </summary> /// <param name="combat">The player with the health</param> public void Init(VRCombat combat) { for (int i = 0; i < 3; i++) { lives [i].SetActive(true); } player = combat; maxHealth = player.health; }
// Use this for initialization void Start() { if (!charRenderer) { charRenderer = GetComponentInChildren <Renderer>(); } defaultMat = charRenderer.material; transparentC = new Color(0, 0, 0, 0); solidColor = new Color(0, 0, 0, 0.95f); timer = 0f; combat = GetComponentInParent <VRCombat>(); }
private void OnTriggerEnter(Collider other) { if (!isServer || hasBeenStolen) { return; } if (other.gameObject.tag == "Player") { VRCombat combat = other.GetComponent <VRCombat>(); if (!combat) { combat = other.transform.parent.GetComponent <VRCombat>(); } //if (!combat.IsInvulnerable) //{ hasBeenStolen = true; combat.GainRelic(); RpcStealRelic(); //} } }
/// <summary> /// Handles when a VR player collides with the entrance /// </summary> private void OnTriggerEnter(Collider other) { if (!isServer) { return; } // if (other.CompareTag("Player")) { VRCombat combat = other.GetComponent <VRCombat>(); if (!combat) { combat = other.transform.parent.GetComponent <VRCombat>(); } if (!combat.IsInvulnerable && combat.GetRelicCount() == 2 && manager.CurrGamePhase != GamePhase.Over) { Win(combat); } } }
/// <summary> /// Sets Activates the Health UI /// </summary> /// <param name="combat">Movement script to tie it to</param> public void InitHealthEnergyBar(VRCombat combat) { healthUIObj.SetActive(true); healthUIObj.GetComponent <HealthBarUI>().Init(combat); }
/// <summary> /// Raycasts and updates where the other end of the laser should be /// </summary> private void UpdateLaser() { //if the laser is being shot if (isShootingLaser) { laserTimer += Time.deltaTime; if (laserTimer < windUpDuration) { flashLight.spotAngle = Mathf.Lerp(spotLightAngle, 0, laserTimer / windUpDuration); } if (!isLocalPlayer) { return; } //updates timer if (laserTimer > laserDuration) { laserTimer = 0f; isShootingLaser = false; } if (laserTimer > windUpDuration) { //raycasts RaycastHit hit; //puts the laser where it 'hits' if (Physics.Raycast(avatar.position, -avatar.forward, out hit, layerMaxDist, laserLayerMask)) { laserPoint = hit.point; if (hit.transform.tag == "Player") { VRCombat combat = hit.transform.GetComponent <VRCombat>(); combat.TakeDamage(); } } } //puts it at the furthest distance else { laserPoint = avatar.position + -avatar.forward * layerMaxDist; } } //manages cool down if laser isn't being shot else { if (laserTimer < laserCoolDown) { laserTimer += Time.deltaTime; flashLight.spotAngle = Mathf.Lerp(0, spotLightAngle, laserTimer / laserCoolDown); } else if (isLocalPlayer) { canShoot = true; } } }
/// <summary> /// Appropriately adjust values to reflect winning /// </summary> /// <param name="combat">The VRcombat with the relics</param> private void Win(VRCombat combat) { manager.SetPhaseTo(GamePhase.Over); RpcAlertVRWin(combat.GetRelicCount()); }