private void DeactivateBeam() { if (this.beamEnd != null) { if (this.currentTarget != null) { ActiveOutline outline = this.currentTarget.gameObject.GetComponent <ActiveOutline>(); if (outline != null) { Destroy(outline); } this.currentTarget = null; } AkSoundEngine.PostEvent("PlayerBeamInActiveEvent", gameObject); Destroy(this.beamEnd); Destroy(this.beam); } }
private void RemoveMinion(Minion minion) { if (minion == null || !this.minions.Contains(minion)) { return; } GameObject.Destroy(this.minionIcons[this.minions.IndexOf(minion)]); this.minionIcons.RemoveAt(this.minions.IndexOf(minion)); this.minions.Remove(minion); /*minion.gameObject.AddComponent<MinionEnergyReturn>();*/ ActiveOutline outline = minion.GetComponent <ActiveOutline>(); if (outline != null) { Destroy(minion.GetComponent <ActiveOutline>()); } }
private void ChannelSpell(Transform caster) { this.EnableBeam(); this.line.positionCount = 2; Vector3 start = this.BeamStartPosition.transform.position; this.line.SetPosition(0, start); Vector3 casterPos1 = caster.position + new Vector3(0, this.vec1Height, 0); Vector3 casterPos2 = caster.position + new Vector3(0, this.vec2Height, 0); Vector3 casterPos3 = caster.position + new Vector3(0, this.vec3Height, 0); Vector3 casterPos4 = caster.position + new Vector3(0, this.vec4Height, 0); Vector3 casterPos5 = caster.position + new Vector3(0, this.vec5Height, 0); RaycastHit hit; Debug.DrawRay(caster.position, caster.forward, Color.cyan); if (this.currentTarget != null) { if (this.beamEnd.activeSelf) { this.beamEnd.SetActive(false); } if (Physics.Raycast(casterPos1, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos2, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos3, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos4, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos5, caster.forward, out hit, this.channelRange, this.mask)) { Vector3 end = new Vector3(hit.point.x, start.y, hit.point.z) - (this.transform.forward.normalized * this.beamEndOffset); if (this.currentTarget.transform.IsChildOf(hit.transform)) { this.line.SetPosition(1, end); float distance = Vector3.Distance(start, end); this.line.sharedMaterial.mainTextureScale = new Vector2(distance / this.textureLengthScale, 1); this.line.sharedMaterial.mainTextureOffset = new Vector2(Time.deltaTime * this.textureScrollSpeed, 0); // Debug.Log("Is child of: " + hit.transform.name); } else { // Debug.Log("Not child of: " + hit.transform.name); ActiveOutline outline = this.currentTarget.gameObject.GetComponent <ActiveOutline>(); if (outline != null) { Destroy(outline); } this.currentTarget = null; } } else { // Debug.Log("Raycast didn't hit."); ActiveOutline outline = this.currentTarget.gameObject.GetComponent <ActiveOutline>(); if (outline != null) { Destroy(outline); } this.currentTarget = null; } } else { Vector3 end = start + (this.transform.forward * (this.channelRange - Vector3.Distance(start, this.transform.position))); if (!this.beamEnd.activeSelf) { this.beamEnd.SetActive(true); } Vector3 beamCirclePos = end + ((this.line.GetPosition(1) - this.line.GetPosition(0)) * this.beamEndOffset); this.beamEnd.transform.position = beamCirclePos; this.line.SetPosition(1, end); this.beamEnd.transform.LookAt(this.BeamStartPosition.transform.position); float distance = Vector3.Distance(start, end); this.line.sharedMaterial.mainTextureScale = new Vector2(distance / this.textureLengthScale, 1); this.line.sharedMaterial.mainTextureOffset = new Vector2(Time.deltaTime * this.textureScrollSpeed, 0); if (Physics.Raycast(casterPos1, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos2, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos3, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos4, caster.forward, out hit, this.channelRange, this.mask) || Physics.Raycast(casterPos5, caster.forward, out hit, this.channelRange, this.mask)) { this.currentTarget = hit.transform; if (this.currentTarget.GetComponent <ActiveOutline>() == null) { this.currentTarget.gameObject.AddComponent <ActiveOutline>(); Abilities abilities = this.gameObject.GetComponent <Abilities>(); if (!abilities.HasUnlockedAnyLimb()) { if (this.energyLine == null) { AkSoundEngine.PostEvent("PlayerGiveEnergyNoAbilityEvent", gameObject); EventHandler.Instance.Raise(new NoAbilitiesEvent() { }); } } } } } }