protected override void Update() { base.Update(); if (IsActive) { transform.Rotate(0, 0, -_input.GetRotation() * _rotationSpeed * Time.deltaTime); Rigidbody.AddForce(transform.up * _movingForce * _input.GetMovement()); if (_input.ActionButtonPressed()) { if (_timeFromLastShot > _shotDelay) { var laser = _laserSpawner.Spawn() as Laser; if (laser != null) { laser.Setup(_weapon.transform.position, transform.rotation); SignalsManager.Broadcast("PlayAudio", "laser"); } _timeFromLastShot = 0f; } else { _timeFromLastShot += Time.deltaTime; } } else { _timeFromLastShot = float.MaxValue; } } }
public void BlowUp() { GameController.Instance.GameSession.AddScorePoints(_value); SignalsManager.Broadcast(_audioSignal.Name, "splash"); EffectsManager.Instance.Play(GameConfiguration.Instance.PopSettings.BlowUpEffect, _value, transform.position); Deactivate(); }
private void OnTriggerEnter(Collider otherCollider) { var pathLine = otherCollider.GetComponent <Line>(); if (pathLine != null) { _currentLine = pathLine; return; } var platform = otherCollider.GetComponent <Platform>(); if (platform != null) { _isOnPlatform = true; ProcessPlatform(platform); return; } var pickup = otherCollider.GetComponent <Pickup>(); if (pickup != null) { pickup.Trigger(); return; } var fallZone = otherCollider.GetComponent <FallZone>(); if (fallZone != null && !_isOnPlatform) { ProcessFall(); SignalsManager.Broadcast(_stateSignal.Name, GameState.End.ToString()); } }
public void Trigger() { if (GameController.Instance.GameState == GameState.Play) { _animator.SetTrigger("React"); SignalsManager.Broadcast(_audioSignal.Name, _soundName); } }
private void PlayHitEffects(Vector3 hitPoint) { var hitEffect = _effectsPool.GetNext(); hitEffect.transform.position = hitPoint; this.WaitForSeconds(hitEffect.main.duration, () => _effectsPool.Return(hitEffect)); SignalsManager.Broadcast(_playAudioSignal.Name, "ball_hit"); }
public override void OnEnter() { base.OnEnter(); this.WaitForSeconds(_waitTime, () => { SignalsManager.Broadcast(_stateChangeSignal.Name, GameState.Start.ToString()); }); }
public override void Trigger() { base.Trigger(); SignalsManager.Broadcast(_audioSignal.Name, _sound); GameController.Instance.GameSession.ApplyMultiplier(_multiplier); Debug.Log("Trigger Multiplier"); }
public override void Trigger() { _renderer.enabled = false; _splashMaterial.color = GameConfiguration.GetColor(_color); _particleSystem.Play(); SignalsManager.Broadcast(_audioSignal.Name, _sound); GameController.Instance.GameSession.ApplyColor(_color); Debug.Log("Trigger Color"); }
public void PlayDestroyEffect(Vector3 hitPoint) { if (!_destroyEffectPlayed) { Instantiate(_ballView.DestroyEffect, hitPoint, Quaternion.identity, transform.parent); SignalsManager.Broadcast(_playAudioSignal.Name, "ball_destroy"); _destroyEffectPlayed = true; } }
private void StartGame() { _asteroidsSpawner.RestartSpawn(); var spaceShip = _shipSpawner.Spawn() as Ship; if (spaceShip != null) { spaceShip.Setup(ShipSettings.Instance); } SignalsManager.Broadcast(_gameStartedSignal.Name); }
private void OnHitRacketAction() { _hitsCount++; SignalsManager.Broadcast(_scoreChangeSignal.Name, _hitsCount); if (_hitsCount % GameConfiguration.Instance.RacketSizeDecreaseRate == 0) { DecreaseRacketSize(_topRacket); DecreaseRacketSize(_bottomRacket); SignalsManager.Broadcast(_racketsSizeChangeSignal.Name); } }
private void Shoot(Cell cell) { _isActive = false; _firstPop.Move(cell, () => { cell.Attach(_firstPop); cell.React(); cell.Merge(); }); SignalsManager.Broadcast(_audioSignal.Name, "shoot"); Reload(); }
protected override void OnContactHandlerEntered(SpaceObject spaceObject) { if (spaceObject.Type == SpaceObjectType.Asteroid) { return; } if (spaceObject.Type == SpaceObjectType.Laser) { SignalsManager.Broadcast(_destroyedSignal.Name, _scorePoints); SignalsManager.Broadcast("PlayAudio", "destroyed"); Deactivate(); } }
public void AddScorePoints(int scorePoints) { Score += scorePoints; SignalsManager.Broadcast(_scoreSignal.Name, Score); var level = GameConfiguration.GetLevelByScore(Score); if (level > Level) { Level = level; SignalsManager.Broadcast(_levelSignal.Name, level); SaveLevelAndScore(); } }
public void ApplyColor(string color) { if (color != Color) { Color = color; _ball.ApplyColor(color); _path.ApplyColor(color); SignalsManager.Broadcast(_colorSignal.Name, color); } else { Lives++; SignalsManager.Broadcast(_livesSignal.Name, Lives); } }
public void OnShipDestroyed() { _shipSpawner.Flush(); _lives--; if (_lives > 0) { SignalsManager.Broadcast(_livesCountChangedSignal.Name, _lives); this.WaitForSeconds(GameConfiguration.Instance.DelayBetweenSessions, StartGame); } else { GameController.Instance.SetState(GameState.GameOver); } }
public void Enhance(int level) { var value = _value; for (var i = 1; i < level; i++) { value *= 2; } GameController.Instance.GameSession.AddScorePoints(value); Setup(value); SignalsManager.Broadcast(_audioSignal.Name, "merge"); EffectsManager.Instance.Play(GameConfiguration.Instance.PopSettings.MergeEffect, _value, transform.position); }
public void IncreaseScore() { ++CurrentScore; //Use variable from configuration here if (CurrentScore % 10 == 0) { SignalsManager.Broadcast("PassedLineSection"); } if (BestScore > 0) { if (CurrentScore > BestScore) { SignalsManager.Broadcast("BestScoreBeaten"); } } }
public void SubtractLive(bool all = false) { if (all) { Lives = 0; } else { Lives--; } if (Lives > 0) { SignalsManager.Broadcast(_livesSignal.Name, Lives); } else { _ball.BlowUp(); GameController.Instance.SetState(GameState.End); } }
private void OnCollisionEnter(Collision otherCollision) { var hitPoint = otherCollision.contacts[0].point; var racket = otherCollision.gameObject.GetComponentInParent <Racket>(); if (racket != null) { var hitFactor = CalculateHitFactor(transform.position, otherCollision.transform.position, otherCollision.collider.bounds.size.x); racket.React(hitFactor); if (racket.Type == RacketType.Top) { _rigidbody.velocity = new Vector2(hitFactor, -1).normalized *_bouncingSpeed; } else if (racket.Type == RacketType.Bottom) { _rigidbody.velocity = new Vector2(hitFactor, 1).normalized *_bouncingSpeed; } SignalsManager.Broadcast(_hitRacketSignal.Name); } else { var bound = otherCollision.gameObject.GetComponent <Bound>(); if (bound != null) { if (HitVerticalBounds(bound.Type)) { PlayDestroyEffect(hitPoint); Destroy(gameObject); return; } } } PlayHitEffects(hitPoint); }
public void React() { if (_pop == null) { return; } _pop.React(); SignalsManager.Broadcast(_audioSignal.Name, "slap"); this.WaitForSeconds(_rectDelayTime, () => { var neighbors = GridUtils.GetNeighbors(this); for (var i = 0; i < neighbors.Count; i++) { var cell = neighbors[i]; if (cell.Pop != null) { cell.Pop.React(); } } }); }
private bool HitVerticalBounds(BoundType boundType) { var hit = false; switch (boundType) { case BoundType.Top: { hit = true; SignalsManager.Broadcast(_hitTopBoundSignal.Name); break; } case BoundType.Bottom: { hit = true; SignalsManager.Broadcast(_hitBottomBoundSignal.Name); break; } } return(hit); }
private void OnLevelChange(int level) { _level.text = string.Format(LocalizationManager.GetString("Level"), level); SignalsManager.Broadcast(_audioSignal.Name, _sound); NotificationManager.Show(new TextNotification(LocalizationManager.GetString("NewLevel")), 2f); }
public override void Broadcast() { SignalsManager.Broadcast(Signal.Name, Parameter); }
public void Merge() { TryMerge(() => SignalsManager.Broadcast(_updateSignal.Name)); }
public void BlowUp() { _renderer.enabled = false; SignalsManager.Broadcast(_audioSignal.Name, _failSound); NotificationManager.Show(new TextNotification(LocalizationManager.GetString("Ouch")), 2f); }
private void OnPointerDown(PointerEventData eventData) { SignalsManager.Broadcast(_stateChangeSignal.Name, GameState.Play.ToString()); }
private void OnLevelChange(int level) { UpdateLevel(level, GameController.Instance.GameSession.Score); SignalsManager.Broadcast(_audioSignal.Name, "new_level"); }
protected override void OnContactHandlerEntered(SpaceObject spaceObject) { base.OnContactHandlerEntered(spaceObject); SignalsManager.Broadcast("PlayAudio", "ship_destroyed"); Deactivate(); }
protected override void FireDeactivated() { base.FireDeactivated(); SignalsManager.Broadcast(_destroyedSignal.Name); }