public override void GenerateBullet(IUnitControl owner, Vector2 position, Quaternion rotation, Vector2 direction) { var right = Vector2.Perpendicular(direction); var direction1 = direction * bulletForce; GenerateOneBullet(owner, position, rotation, direction1); }
public override void GenerateBullet(Transform pos, IUnitControl owner) { var up = pos.up; var right = pos.right; var rotation = pos.rotation; var position = pos.position; var direction1 = up * bulletForce + right * 2f; var direction2 = up * bulletForce; var direction3 = up * bulletForce - right * 2f; var direction4 = -up * bulletForce + right * 2f; var direction5 = -up * bulletForce - right * 2f; var direction6 = -up * bulletForce; var direction7 = -right * bulletForce; var direction8 = right * bulletForce; var offset = direction2.normalized; var r_offset = Vector3.right; GenerateBullet(owner, position + 2 * offset, rotation, direction1); GenerateBullet(owner, position + 2 * offset, rotation, direction2); GenerateBullet(owner, position + 2 * offset, rotation, direction3); GenerateBullet(owner, position - 2 * offset, rotation, direction4); GenerateBullet(owner, position - 2 * offset, rotation, direction5); GenerateBullet(owner, position - 2 * offset, rotation, direction6); GenerateBullet(owner, position - 2 * r_offset, rotation, direction7); GenerateBullet(owner, position + 2 * r_offset, rotation, direction8); }
public override void GenerateBullet(IUnitControl owner, Vector2 position, Quaternion rotation, Vector2 direction) { GameObject b = Instantiate(gameObject, position, rotation); BulletCollision bc = b.GetComponent <BulletCollision>(); bc.setOwner(owner); Rigidbody2D rb = b.GetComponent <Rigidbody2D>(); rb.velocity = direction.normalized * speed; }
protected virtual void GenerateOneBullet(IUnitControl owner, Vector2 position, Quaternion rotation, Vector2 direction) { GameObject b = Instantiate(gameObject, position, rotation); BulletCollision bc = b.GetComponent <BulletCollision>(); bc.setOwner(owner); Rigidbody2D rb = b.GetComponent <Rigidbody2D>(); rb.AddForce(direction, ForceMode2D.Impulse); }
public void setOwner(IUnitControl newOwner) { owner = newOwner; var weapon = newOwner.getWeaponSystem().weapon; var weaponConfig = weapon.GetComponent <WeaponConfig>(); maxDistance = weaponConfig.maxAttackRange; startPosition = newOwner.getStartPosition(); canBreakTrough = weaponConfig.canBreakTrough(); weaponAbility = weaponConfig.weaponAbility; }
/// <summary> /// Получение урона /// </summary> /// <param name="phisic">физический</param> /// <param name="magic">магический</param> /// <param name="pure">чистый</param> public IUnit GatDamage(int phisic, int magic, int pure, IUnit demagedUnit) { Player playerDemaged = demagedUnit as Player; int magicDemagePlus = magic; ///Действие аганима if (playerDemaged != null) { foreach (var item in playerDemaged.Items) { if (item.BonusMagicDemage > 0) { magicDemagePlus = magicDemagePlus + (int)(magic * item.BonusMagicDemage); } } } int demage = StaticVaribl.DemageAndArmor(phisic, Arrmor) + StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor) + pure; Health -= demage; IUnitControl chpView = GameObject.View as IUnitControl; if (chpView != null) { chpView.ShowHealth(Health, MaxHealth); } if (GetDemageEvent != null) { GetDemageEvent(StaticVaribl.DemageAndArmor(phisic, Arrmor), StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor), pure, this); } IGameControl control = (this.GameObject.View as IGameControl); if (control != null) { ///Отображаем сколько урона получил юнит control.GetDemage("-" + demage); } if (Health <= 0) {///Значит объект унечтожен return(RemoveUnit(demagedUnit)); } return(null); }
// Use this for initialization void Start() { owner = GetComponent <BaseUnitControl>(); currentWeaponConfig = weapon.GetComponent <WeaponConfig>(); if (damagePopup != null) { damagePopupControl = damagePopup.GetComponent <DamagePopupControl>(); } audioSource = GetComponent <AudioSource>(); if (audioSource) { audioSource.clip = currentWeaponConfig.audioClip; } }
public override void GenerateBullet(IUnitControl owner, Vector2 position, Quaternion rotation, Vector2 direction) { var right = Vector2.Perpendicular(direction); var direction1 = direction * bulletForce + right * 1f; var direction2 = direction * bulletForce + right * 0.5f; var direction3 = direction * bulletForce; var direction4 = direction * bulletForce - right * 0.5f; var direction5 = direction * bulletForce - right * 1f; GenerateOneBullet(owner, position, rotation, direction1); GenerateOneBullet(owner, position, rotation, direction2); GenerateOneBullet(owner, position, rotation, direction3); GenerateOneBullet(owner, position, rotation, direction4); GenerateOneBullet(owner, position, rotation, direction5); }
protected void OnTriggerEnter2D(Collider2D other) { if (other.transform.CompareTag("Bullet")) { IUnitControl shooter = other.gameObject.GetComponent <BulletCollision>().getOwner(); var isOtherEnemy = shooter.getCharacterSystem().isEnemy(); var isMeEnemy = characterSystem.isEnemy(); if (isOtherEnemy && isMeEnemy) { return; } var enemyWeapon = shooter.getWeaponSystem(); var damage = enemyWeapon.CalculateDamage(this); healthSystem.TakeDamage(damage); } }
public float CalculateDamage(IUnitControl target) { if (!target.getCharacterSystem().canAttack) { return(0f); } bool isCriticalHit = UnityEngine.Random.Range(0f, 1f) <= criticalHitChance; float damageBeforeCritical = baseDamage + currentWeaponConfig.weaponDamage; float dmg = isCriticalHit ? damageBeforeCritical * criticalHitMultiplier : damageBeforeCritical; if (damagePopupControl != null) { damagePopupControl.ShowDamage(target.getStartPosition(), (int)dmg, isCriticalHit); } return(dmg); }
public override void GenerateBullet(Transform firePoint, IUnitControl owner) { var up = firePoint.up; var right = firePoint.right; var rotation = firePoint.rotation; var position = firePoint.position; var direction1 = -up * bulletForce + right * 2f; var direction2 = -up * bulletForce; var direction3 = -up * bulletForce - right * 2f; GenerateOneBullet(owner, position, rotation, direction1); GenerateOneBullet(owner, position, rotation, direction2); GenerateOneBullet(owner, position, rotation, direction3); }
public override void GenerateBullet(Transform firePoint, IUnitControl owner) { var direction = -firePoint.up * bulletForce; GenerateBullet(owner, firePoint.position, firePoint.rotation, direction); }
/// <summary> /// Получение урона /// </summary> /// <param name="phisic">физический</param> /// <param name="magic">магический</param> /// <param name="pure">чистый</param> public IUnit GatDamage(int phisic, int magic, int pure, IUnit demagedUnit) { IUnit removedUnit = null; if (!Invulnerability) { Player playerDemaged = demagedUnit as Player; int magicDemagePlus = magic; ///Действие аганима if (playerDemaged != null) { foreach (var item in playerDemaged.Items) { if (item.BonusMagicDemage > 0) { magicDemagePlus = magicDemagePlus + (int)(magic * item.BonusMagicDemage); } } } int demage = StaticVaribl.DemageAndArmor(phisic, Arrmor) + StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor) + pure; #region Statistic StatisticData.DemageSelfs += demage; if (playerDemaged != null) { playerDemaged.StatisticData.Demage += demage; } #endregion Health -= demage; IUnitControl chpView = GameObject.View as IUnitControl; if (chpView != null) { chpView.ShowHealth(Health, MaxHealth); } if (GetDemageEvent != null) { GetDemageEvent(StaticVaribl.DemageAndArmor(phisic, Arrmor), StaticVaribl.DemageAndArmor(magicDemagePlus, MagicArrmor), pure, this); } ///Отображаем сколько урона получил юнит (this.GameObject.View as IGameControl).GetDemage("-" + demage); if (Health <= 0) {///Значит объект унечтожен removedUnit = RemoveUnit(demagedUnit); } UpdateView(); } else { (this.GameObject.View as IGameControl).GetDemage("Invulnerability"); } return(removedUnit); }
public virtual void GenerateBullet(IUnitControl owner, Vector2 position, Quaternion rotation, Vector2 direction) { GenerateOneBullet(owner, position, rotation, direction); }
public virtual void GenerateBullet(Transform firePoint, IUnitControl owner) { throw new NotImplementedException("Please Use derived WeaponConfig"); }