private void PositionLightningBolt() { /// Starting Position lightningBoltScript.StartPosition = m_controllerPosition; /// Ending Position { RaycastHit hitInfo; LayerMask layerMask = ~LayerMask.NameToLayer("Lit"); if (Physics.Raycast(m_controllerPosition, m_direction, out hitInfo, Mathf.Infinity, layerMask)) { lightningBoltScript.EndPosition = hitInfo.transform.position; if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("Game Scene")) { ElementalMagic.SpellCollision(gameObject, hitInfo.transform.gameObject); } else { ElementalMagic.TrainingCollision(gameObject, hitInfo.transform.gameObject); } } else { lightningBoltScript.EndPosition = m_controllerPosition + 10.0f * m_direction; } } }
void OnTriggerEnter(Collider other) { if (other.tag == "MainCamera") { Destroy(gameObject); } if (other.tag == "Spell") { ElementalMagic.TrainingCollision(other.gameObject, gameObject); } }
void OnTriggerEnter(Collider other) { if (other.tag == "MainCamera") { GameManager.GetHit(); Destroy(gameObject); } if (other.tag == "Spell") { ElementalMagic.SpellCollision(other.gameObject, gameObject); } }
void Update() { UpdateSpellSwitcher(); if (ViveInput.GetPressDown(m_handRole, ControllerButton.Trigger)) { ElementalMagic.CastSpell(transform.position, transform.forward); } if (ViveInput.GetPressDown(m_handRole, ControllerButton.Grip)) { ElementalMagic.SwitchSpell(); } if (ViveInput.GetPressDown(m_handRole, ControllerButton.PadTouch)) { m_spellSwitcherScript.Activate(); } else if (ViveInput.GetPress(m_handRole, ControllerButton.PadTouch)) { Vector2 touchPosition = ViveInput.GetPadAxis(m_handRole, true); if (touchPosition.x > 0 && touchPosition.y > 0) // First Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Fire); } else if (touchPosition.x < 0 && touchPosition.y > 0) // Second Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Water); } else if (touchPosition.x < 0 && touchPosition.y < 0) // Third Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Lightning); } else if (touchPosition.x > 0 && touchPosition.y < 0) // Fourth Quadrant { ElementalMagic.ChangeSpell(ElementalMagic.MagicType.Stone); } } else if (ViveInput.GetPressUp(m_handRole, ControllerButton.PadTouch)) { m_spellSwitcherScript.Deactivate(); } }
void Start() { ElementalMagic.FillSpellsArray(); m_spellSwitcherScript = (transform.GetChild(1)).GetComponent <SpellSwitcherController>(); }