private void UpdateCurrentAttack() { _currentAttack = _currentAttackPattern[_attackIndex]; if (_currentAttack == null) { for (var i = 0; i < 1; i++) { Debug.Log($"My name is {name} and my Number {i} Attack is Null. I can't fight without it. " + $"Please assign me in the editor and STOP BREAKING MY PREFAB. It's a very hard life to live. Thank you." + $"Also, my serialization is broken, so I can't be loaded from a different scene. So, maybe take the spaces out of my folder name." + $"Again, thank you. I love to battle!"); } } _attackState = _currentAttack.StartingState; if (_attackState == LaserTurretAttackState.Seeking) { _timeTilNextState = _currentAttack.SeekingTime; } else if (_attackState == LaserTurretAttackState.WindingUp) { _timeTilNextState = _currentAttack.WindUpTime; } else if (_attackState == LaserTurretAttackState.Firing) { _timeTilNextState = _currentAttack.AttackDuration; } else if (_attackState == LaserTurretAttackState.WindingDown) { _timeTilNextState = _currentAttack.WindDownTime; } }
private void WindUp() { _timeTilNextState -= Time.deltaTime; if (_timeTilNextState <= 0) { _attackState = LaserTurretAttackState.Firing; _timeTilNextState = _currentAttack.AttackDuration; _secsTilNextShot = 0; } }
private void SeekTarget() { Turning.enabled = true; Turning.RotationSpeed = _currentAttack.RotationSpeed; _timeTilNextState -= Time.deltaTime; if (_timeTilNextState <= 0) { _attackState = LaserTurretAttackState.WindingUp; _timeTilNextState = _currentAttack.WindUpTime; Turning.enabled = false; } }
private void Fire() { _secsTilNextShot -= Time.deltaTime; if (_secsTilNextShot <= 0) { LaserGun.Fire(); _secsTilNextShot = _currentAttack.TimeBetweenShots; } _timeTilNextState -= Time.deltaTime; if (_timeTilNextState <= 0) { _attackState = LaserTurretAttackState.WindingDown; _timeTilNextState = _currentAttack.WindDownTime; } }
private void FireVolley() { _secsTilNextShot -= Time.deltaTime; if (_secsTilNextShot <= 0) { var target = transform.position + transform.forward; LaserGun.FireTowards(new Vector3(target.x + Random.Range(-_currentAttack.Spread, _currentAttack.Spread), target.y, target.z + Random.Range(-_currentAttack.Spread, _currentAttack.Spread))); _secsTilNextShot += _currentAttack.TimeBetweenShots; } _timeTilNextState -= Time.deltaTime; if (_timeTilNextState <= 0) { _secsTilNextShot = 0; _attackState = LaserTurretAttackState.WindingDown; _timeTilNextState = _currentAttack.WindDownTime; } }