public override void Die() { isAlive = false; Invoke("Spawn", 1); animator.SetTrigger("Die"); MainCameraTransformer.AddVelocity(Random.insideUnitCircle.normalized * 5); // if(equippedWeapon) { // equippedWeapon.enabled = false; // } }
void Awake() { Instance = this; Camera camera = GetComponent <Camera>(); if (camera == null) { return; } }
public override int TakeDamage(int damage, Material damageType) { if (isAlive && invulnTimer.isDone) { damage = base.TakeDamage(damage, damageType); if (damage > 0 && isAlive) { invulnTimer.SetTime(invulnTime); MainCameraTransformer.AddVelocity(Random.insideUnitCircle.normalized * 5); PlayHurtClip(); } return(damage); } else { return(-1); } }
//============================================================================================= #region PRIVATE METHODS protected override void Move() { // Read Input float _xInput = Input.GetAxis("Horizontal"); float _yInput = Input.GetAxis("Vertical"); // Camera Movement MainCameraTransformer.SetCenterRotation(new Vector3(0, _xInput, 0) * 0.3f); float _newPositionX = transform.position.x + _xInput * moveSpeed * Time.deltaTime; float _newPositionY = transform.position.y + _yInput * moveSpeed * Time.deltaTime; // Check Horizontal Bounds if (_newPositionX - capsuleCollider.size.x / 2 < Global.xBoundMin) { _newPositionX = Global.xBoundMin + capsuleCollider.size.x / 2; } else if (_newPositionX + capsuleCollider.size.x / 2 > Global.xBoundMax) { _newPositionX = Global.xBoundMax - capsuleCollider.size.x / 2; } // Check Vertical Bounds if (_newPositionY - capsuleCollider.size.y / 2 < Global.yBoundMin) { _newPositionY = Global.yBoundMin + capsuleCollider.size.y / 2; } else if (_newPositionY + capsuleCollider.size.y / 2 > Global.yBoundMax) { _newPositionY = Global.yBoundMax - capsuleCollider.size.y / 2; } // Make final movement transform.position = new Vector3(_newPositionX, _newPositionY, 0); // Animate animator.SetFloat("Horizontal Movement", Input.GetAxis("Horizontal")); }