// Use this for initialization void Start() { myRigidBody = GetComponent <Rigidbody2D>(); _playerSpellManager = FindObjectOfType <PlayerSpellManager>(); spellDirection = _playerSpellManager.SpellDirection; if (!String.IsNullOrEmpty(SpellSoundName)) { _sFXManager = FindObjectOfType <SFXManager>(); _sFXManager.PlaySound(SpellSoundName); } }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); myRigidBody = GetComponent <Rigidbody2D>(); sfxManager = FindObjectOfType <SFXManager>(); playerHealthManager = GetComponent <PlayerHealthManager>(); playerManaManager = GetComponent <PlayerManaManager>(); playerSpellManager = GetComponent <PlayerSpellManager>(); direction = EnumsAndConstants.SpellDirection.None; if (!playerExists) { playerExists = true; DontDestroyOnLoad(transform.gameObject); } else { Destroy(gameObject); } }
public Quaternion SpellRotation(Vector2 move) { SpellDirection = EnumsAndConstants.SpellDirection.None; Quaternion spawnRotation = Quaternion.Euler(Vector3.zero); float xDirection = _animator.GetFloat("MoveX"); float yDirection = _animator.GetFloat("MoveY"); if (xDirection == 0f && yDirection == 0f) { xDirection = _animator.GetFloat("LastMoveX"); yDirection = _animator.GetFloat("LastMoveY"); } if (yDirection > 0f) { SpellDirection = EnumsAndConstants.SpellDirection.Up; } else if (yDirection < 0f) { SpellDirection = EnumsAndConstants.SpellDirection.Down; } if (SpellDirection != EnumsAndConstants.SpellDirection.None) { if (SpellDirection == EnumsAndConstants.SpellDirection.Up) { if (xDirection < 0f) { SpellDirection = EnumsAndConstants.SpellDirection.UpLeft; } else if (xDirection > 0f) { SpellDirection = EnumsAndConstants.SpellDirection.UpRight; } } else { if (xDirection < 0f) { SpellDirection = EnumsAndConstants.SpellDirection.DownLeft; } else if (xDirection > 0f) { SpellDirection = EnumsAndConstants.SpellDirection.DownRight; } } } else { if (xDirection < 0f) { SpellDirection = EnumsAndConstants.SpellDirection.Left; } else if (xDirection > 0f) { SpellDirection = EnumsAndConstants.SpellDirection.Right; } } switch (SpellDirection) { case EnumsAndConstants.SpellDirection.Right: spawnRotation = Quaternion.Euler(0, 0, 0); break; case EnumsAndConstants.SpellDirection.UpRight: spawnRotation = Quaternion.Euler(0, 0, 45); break; case EnumsAndConstants.SpellDirection.Up: spawnRotation = Quaternion.Euler(0, 0, 90); break; case EnumsAndConstants.SpellDirection.UpLeft: spawnRotation = Quaternion.Euler(0, 0, 135); break; case EnumsAndConstants.SpellDirection.Left: spawnRotation = Quaternion.Euler(0, 0, 180); break; case EnumsAndConstants.SpellDirection.DownLeft: spawnRotation = Quaternion.Euler(0, 0, 225); break; case EnumsAndConstants.SpellDirection.Down: spawnRotation = Quaternion.Euler(0, 0, 270); break; case EnumsAndConstants.SpellDirection.DownRight: spawnRotation = Quaternion.Euler(0, 0, 315); break; } return(spawnRotation); }