public void Collision(IAlive bot, int offset_x) { // Console.WriteLine($"{bot.x-offset_x}, {x}"); if (bot.x - offset_x > x - 50 && bot.x - offset_x < x + 50) { Console.WriteLine($"Collision {bot.x-offset_x} {x}"); } }
void OnCollisionStay2D(Collision2D _collision) // Bu ozellik simdilik sadece basic monsterda var. { passingTimeSinceLastCollision += Time.deltaTime; if (_collision.collider.tag.Equals("Player") && passingTimeSinceLastCollision > collisionCooldown) { IAlive _aliveScript = _collision.gameObject.GetComponent <IAlive>(); _aliveScript.DamageTakingCalculations(damage); passingTimeSinceLastCollision = 0; } }
private void OnTriggerEnter(Collider collider) { // let bullet pass through towers and gold if (collider.gameObject.tag != "tower" && collider.gameObject.tag != "towerrange" && collider.gameObject.tag != "gold ") { // deal damage if object is alive IAlive obj = collider.GetComponent <IAlive>(); if (obj != null) { collider.GetComponent <IAlive>().InflictDamage(damage); } Destroy(); } }
private void OnTriggerEnter2D(Collider2D _collision) { if (_collision.gameObject.CompareTag("Player") && !hasEntered) { //Burda alive scriptini cekip hasar verdir //Playerin damageTaking animasyonunu yap //Dusmanlarinkinden farkli renkte popup hasar cikar IAlive _aliveScript = _collision.gameObject.GetComponent <IAlive>(); _aliveScript.DamageTakingCalculations(damage); hasEntered = true; } }
public void OnTriggerEnter2D(Collider2D _collider) { if (_collider.tag.Equals("Enemy")) { IAlive _aliveScript = _collider.GetComponent<IAlive>(); IDamageableParticle _particleScript = _collider.GetComponent<IDamageableParticle>(); IEnemyAI _enemyAIScript = _collider.GetComponent<IEnemyAI>(); _aliveScript.DamageTakingCalculations(damage); // Bura hedef oldugunde son hasari bastirmiyor. _enemyAIScript.DamageTakingAnimation(angle, force); _particleScript.InitializeParticle(_particleCollisionWithTarget); Destroy(this.gameObject); } else if (_collider.tag.Equals("Ground")) { InitializeParticle(_particleCollisionWithObstacle); Destroy(this.gameObject); } }
private void Start() { status = GetComponent <IAlive>(); attack = GetComponent <IAttack>(); }
public void MakeDamage(IAlive entity) { entity.TakeDamage(5f); }
private void OnDamageTaken(IAlive source, DamageTakenEventArgs e) { _totalDamage += e.Damage; while (_totalDamage > DamageEmissionThreshold && DamageParticleGenerator != null) { var particle = DamageParticleGenerator(); var x = Random.Next(40, WorldCollisionRectangle.Width - 40); var y = Random.Next(40, WorldCollisionRectangle.Height - 40); particle.WorldPosition = new Vector2(WorldCollisionRectangle.X + x, WorldCollisionRectangle.Y + y); EmitParticle(particle); _totalDamage -= DamageEmissionThreshold; } }
void Awake() { Live(); parent = GetComponent <PlayerController>() ?? (IAlive)GetComponent <EnemyController>(); }
private void TestEntityValues(IAlive entity, alive message, AssertHelper assertHelper) { TestMessageProperties(assertHelper, entity, message.timestamp, message.product); assertHelper.AreEqual(() => entity.Subscribed, message.subscribed == 1); }
private void OnNanobotDie(IAlive sender, DieEventArgs e) { var deathAnimations = sender.ToDeathAnimation(); foreach (var damageAnimation in deathAnimations) { damageAnimation.Finished += OnAnimationFinished; damageAnimation.WorldPosition = e.DeathPoint; AddLevelObject(damageAnimation); damageAnimation.Initialize(_game, _game.Services.GetService<SpriteBatch>(), _game.Services.GetService<GameState>().Camera); } }
private void OnEnemyDie(IAlive sender, DieEventArgs e) { var enemy = sender as ObstacleGameObject; if (enemy != null) { var deathAnimations = sender.ToDeathAnimation(); foreach (var deathAnimation in deathAnimations) { deathAnimation.Finished += OnAnimationFinished; AddLevelObject(deathAnimation); deathAnimation.Initialize(_game, _game.Services.GetService<SpriteBatch>(), _game.Services.GetService<GameState>().Camera); } SoundManager.EnemyBlow.Play(); var bio = _resourceBuilder.BuildBio(_game.Content, enemy.BiomaerialGeneratedMin, enemy.BiomaerialGeneratedMax); if (enemy.Size.HasValue && bio.Size.HasValue) { bio.WorldPosition = enemy.WorldPosition + (enemy.Size.Value - bio.Size.Value)/2; } else { bio.WorldPosition = enemy.WorldPosition; } bio.Initialize(_game, _game.Services.GetService<SpriteBatch>(), _game.Services.GetService<GameState>().Camera); AddLevelObject(bio); var state = _game.Services.GetService<GameState>(); state.AddScript(new PickObjectScript(_game) { PickTarget = bio, PickBy = state.Player.Nanobot }); } if (sender is DrawableGameObject) { RemoveLevelObject(sender as DrawableGameObject); } if (sender is IObstacle) { RemoveStop(sender as IObstacle); } sender.Die -= OnEnemyDie; }
private void OnEnemyDamage(IAlive sender, DamageTakenEventArgs e) { var damageAnimations = sender.ToDamageAnimation(); foreach (var damageAnimation in damageAnimations) { damageAnimation.Finished += OnAnimationFinished; AddLevelObject(damageAnimation); damageAnimation.Initialize(_game, _game.Services.GetService<SpriteBatch>(), _game.Services.GetService<GameState>().Camera); } }
void OnParticleCollision(GameObject other) { IAlive _aliveScript = other.GetComponent <IAlive>(); _aliveScript.Heal(healingAmount); }
void Awake() { _alive = GetComponent <IAlive>(); }