// Get current direction player is facing in & attack enemy occupying slot in said direction public void Attack() { if (playerTurner == null || GameManager.gameStatus != GameManager.GameStatus.Running) { return; } Utils.Directions direction = playerTurner.currentDirection; switch (direction) { case Utils.Directions.Top: AttackTop(); break; case Utils.Directions.Right: AttackRight(); break; case Utils.Directions.Bottom: AttackBottom(); break; case Utils.Directions.Left: AttackLeft(); break; } playerAttackAnimator.PlayAttackAnimation(); playerAttackSFX.Play(); }
public void ProcessSwipeInput(Utils.Directions direction) { if (playerTurner != null) { playerTurner.TurnPlayer(direction); } }
private void SendSwipe(Utils.Directions direction) { if (swipeProcessor != null) { swipeProcessor.ProcessSwipeInput(direction); } }
public Projectile(string name, float damage, float movementSpeed, Vector2 pos, Vector2 size, Utils.Directions direction, string[] shape) : base(name, pos, size, shape) { this.damage = damage; this.movementSpeed = movementSpeed; this.direction = direction; this.color = ConsoleColor.Red; }
private void TurnLeft() { currentDirection = Utils.Directions.Left; shouldTurnTop = false; shouldTurnRight = false; shouldTurnBottom = false; shouldTurnLeft = true; }
public Enemy(string name, float health, float damage, Vector2 pos, Vector2 shootingPos, float movementSpeed, float maxMovementSpeed, float increaseMovementSpeed, float initialAttackSpeed, float maxAttackSpeed, float cooldownReduction, Vector2 size, string[] shape) : base(name, pos, size, shape) { this.health = health; this.maxHealth = health; this.damage = damage; this.movementSpeed = movementSpeed; this.maxMovementSpeed = maxMovementSpeed; this.increaseMovementSpeed = increaseMovementSpeed; this.shootingPos = shootingPos; this.size = size; this.shape = shape; this.direction = Utils.Directions.LEFT; this.attackSpeed = initialAttackSpeed; this.timeToShoot = this.attackSpeed; this.maxAttackSpeed = maxAttackSpeed; this.cooldownReduction = cooldownReduction; }
public Enemy(string name, EnemySerializable enemy) : base(name, enemy.pos) { this.health = enemy.health; this.maxHealth = this.health; this.damage = enemy.damage; this.movementSpeed = enemy.movementSpeed; this.maxMovementSpeed = enemy.maxMovementSpeed; this.increaseMovementSpeed = enemy.increaseMovementSpeed; this.shootingPos = enemy.shootingPos; this.size = enemy.size; this.shape = enemy.shape; this.pos = enemy.pos; this.direction = Utils.Directions.LEFT; this.attackSpeed = enemy.attackSpeed; this.timeToShoot = this.attackSpeed; this.maxAttackSpeed = enemy.maxAttackSpeed; this.cooldownReduction = enemy.cooldownReduction; }
private void DetectSwipe() { if (SwipeDistanceCheckMet()) { if (IsVerticalSwipe()) { Utils.Directions direction = fingerDownPosition.y - fingerUpPosition.y > 0 ? Utils.Directions.Top : Utils.Directions.Bottom; SendSwipe(direction); } else { Utils.Directions direction = fingerDownPosition.x - fingerUpPosition.x > 0 ? Utils.Directions.Right : Utils.Directions.Left; SendSwipe(direction); } fingerUpPosition = fingerDownPosition; } }
public override void Update() { timeSinceDamaged += Time.DeltaTime; if (direction == Utils.Directions.LEFT) { this.pos = this.pos.Add(-this.movementSpeed * Time.DeltaTime, 0); if (this.pos.GetXInt() <= 0) { this.direction = Utils.Directions.RIGHT; Buff(); } } else if (direction == Utils.Directions.RIGHT) { this.pos = this.pos.Add(this.movementSpeed * Time.DeltaTime, 0); if (this.pos.GetXInt() >= Renderer.GetWindowWidth() - this.size.GetXInt()) { this.direction = Utils.Directions.LEFT; Buff(); } } this.timeToShoot -= Time.DeltaTime; if (this.timeToShoot <= 0f) { this.timeToShoot = this.attackSpeed; Projectile projectile = new Projectile( "projectile" + Rand.GetRandomInt(0, int.MaxValue), this.damage, 10f, this.pos + this.shootingPos, Vector2.One, Utils.Directions.DOWN, new string[] { this.shape[this.shootingPos.GetYInt()][this.shootingPos.GetXInt()].ToString() } ); Engine.AddGameObject(projectile); } }
public void DeathSequence() { //-----GET VALUE FROM STORAGE COMPONENT EnemyValue enemyValue = GetComponent <EnemyValue>(); //-----INCREMENT SCORE ProgressTracker.IncrementScore(enemyValue.scoreValue); //-----ADD COINS if (enemyValue.coinValue > 0) { ProgressTracker.IncrementCoins(enemyValue.coinValue); } //-----STOP ALLIGNING WITH SLOT GetComponent <EnemyMovement>().StopAllignment(); //-----GET & FREE PREVIOUS SLOT Utils.Directions occupiedSlotDirection = transform.parent.transform.GetComponent <TrackSlotFinal>().GetDirection(); transform.parent.transform.GetComponent <TrackSlot>().FreeSlot(); //-----DECREMENT ENEMY COUNT EnemyCounter.DecrementCounter(); //-----INCREMENT CHARGING SPEED EnemyValue.IncrementCharge(); //-----DECREMENT SPAWN COOLDOWN EnemySpawnCoordinator.DecrementSpawnCooldown(); //-----INCREMENT ATTACK MUSIC PITCH FindObjectOfType <MusicController>().IncrementPitch(); //-----PLAY ANIMATION GetComponent <EnemyDeathAnimator>().PlayDeathAnimation(occupiedSlotDirection); //-----PLAY DEATH SFX GetComponent <EnemyAudioController>().PlayEnemyDeathSFX(); //-----SHAKE CAMERA Camera.main.GetComponent <CameraShaker>().ShakeCam(cameraShakeDuration, cameraShakeMagnitude); }
public void TurnPlayer(Utils.Directions direction) { switch (direction) { case Utils.Directions.Top: TurnTop(); break; case Utils.Directions.Right: TurnRight(); break; case Utils.Directions.Bottom: TurnBottom(); break; case Utils.Directions.Left: TurnLeft(); break; } }
public void PlayAnimation(Utils.Directions direction) { switch (direction) { case Utils.Directions.Top: PushToBottom(); break; case Utils.Directions.Right: PushToLeft(); break; case Utils.Directions.Bottom: PushToTop(); break; case Utils.Directions.Left: PushToRight(); break; } }
public void Move(Utils.Directions direction) { switch (direction) { case Utils.Directions.RIGHT: if (this.pos.Add(movementSpeed * Time.DeltaTime, 0).GetXInt() < Renderer.GetWindowWidth() - this.size.GetYInt()) { this.pos = this.pos.Add(movementSpeed * Time.DeltaTime, 0); } break; case Utils.Directions.LEFT: if (this.pos.Add(-movementSpeed * Time.DeltaTime, 0).GetXInt() >= 0) { this.pos = this.pos.Add(-movementSpeed * Time.DeltaTime, 0); } break; default: break; } }
public void PlayDeathAnimation(Utils.Directions direction) { switch (direction) { case Utils.Directions.Top: PlayDeathTopAnimation(); break; case Utils.Directions.Right: PlayDeathRightAnimation(); break; case Utils.Directions.Bottom: PlayDeathBottomAnimation(); break; case Utils.Directions.Left: PlayDeathLeftAnimation(); break; } GetComponent <Rigidbody2D>().gravityScale = 1; }