private double calcDamage(double recieveDamage, TypeOfAttack Typeattack) { if (Typeattack == TypeOfAttack.Magic) { if (recieveDamage != 0) { return(CurrentHealth -= recieveDamage); } } if (Typeattack == TypeOfAttack.Melee) { if (recieveDamage != 0) { return(CurrentHealth -= recieveDamage); } } if (Typeattack == TypeOfAttack.Ranged) { if (recieveDamage != 0) { return(CurrentHealth -= recieveDamage); } } return(hitPoints); }
public virtual void takeDamage(float forceOfAttack, TypeOfAttack typeOfAttack) { if (!healthBar.gameObject.activeInHierarchy) { healthBar.gameObject.SetActive(true); } if (health > 0) { if (typeOfAttack == TypeOfAttack.magical) { health -= forceOfAttack * (1 - magicResist); } else if (typeOfAttack == TypeOfAttack.physical) { health -= forceOfAttack * (1 - physicalResist); } else if (typeOfAttack == TypeOfAttack.pure) { health -= forceOfAttack; } healthBar.localScale = new Vector3((health / maxHealth) * healthBarScale, healthBar.localScale.y, healthBar.localScale.z); if (health <= 0) { healthBar.localScale = new Vector3(healthBarScale, healthBar.localScale.y, healthBar.localScale.z); healthBar.gameObject.SetActive(false); death(); } } }
//Eksperimental method public Weapon RandomizeWeaponByAttackStyle(TypeOfAttack attackType) { Weapon weapon = new Weapon(); Random rand = new Random(); if (attackType == TypeOfAttack.Magic) { weapon.Damage = rand.Next(30, 60); weapon.WeaponDescription = "Random Wand"; weapon.TypeOfAttack = TypeOfAttack.Magic; return(weapon); } if (attackType == TypeOfAttack.Melee) { weapon.Damage = rand.Next(30, 60); weapon.WeaponDescription = "Random Sword"; weapon.TypeOfAttack = TypeOfAttack.Melee; return(weapon); } if (attackType == TypeOfAttack.Ranged) { weapon.Damage = rand.Next(30, 60); weapon.WeaponDescription = "Random Bow"; weapon.TypeOfAttack = TypeOfAttack.Ranged; return(weapon); } return(weapon); }
public Weapon(TypeOfAttack typeOfAttack, double damage, string weaponDescription, int positionX, int positionY) { TypeOfAttack = typeOfAttack; Damage = CantMakeLowDmgWeapon(damage); WeaponDescription = weaponDescription; _attackResDic = new Dictionary <TypeOfAttack, Armor>(); FixedPositionY = positionY; FixedPositionX = positionX; }
//Decorator factory, if type equals ranged. Simpler way of returning an object, instead of user typing a millin parameters. //Test public IWeapon makeBow(TypeOfAttack weaponType) { Random rand = new Random(); int posY = rand.Next(0, 25); int posX = rand.Next(0, 25); if (weaponType == TypeOfAttack.Ranged) { return(new Weapon(TypeOfAttack.Ranged, 30, "Bow", posX, posY)); } throw new ArgumentException("Weapon type wasn't bow"); }
// корутина выключит фичу public IEnumerator SetPlayerTrackingForFeature(TypeOfAttack feature, Delegate endAction = null) { FeaturesActivated++; AttackEnabled[feature] = true; while (DistanceFrom(Player.transform.position) <= RequiredDistanceFromPlayer) { yield return(null); } AttackEnabled[feature] = false; endAction?.Invoke(1); FeaturesActivated--; yield break; }
public void AddCreaturesToWorld(Entities entity, Weapon weapon, Armor armor, TypeOfAttack attackType, int positionX, int positionY, double hitPoints, string name) { CreatureList.Add(CreatureFactory.makeCreature(positionX, positionY, weapon, armor, attackType, hitPoints, name)); }
public void ChangeToRanged() { typeofAttack = TypeOfAttack.Ranged_Weapon; }
public TestTube() { Type = new TypeOfMagic(); AttackType = new TypeOfAttack(); crBox = new ColorBox(); }
public void AddWeapontoWorld(TypeOfAttack attackType, double damage, string description, int positionX, int positionY) { WeaponsList.Add(WeaponFactory.GenerateWeapon(attackType, damage, description, positionX, positionY)); OnEventChanged(EventArgs.Empty); }
public IWeapon GenerateWeapon(TypeOfAttack attackType, double damage, string description, int positinX, int positionY) { Weapon weapon = new Weapon(attackType, damage, description, positinX, positionY); return(weapon); }
//Decorator pattern? Calls parent implementation, instead of calling wrapped object directly. Simplifies extension of decorators. //Base. public Entities(int positionX, int positionY, Weapon weaponCreature, Armor armor, TypeOfAttack attackType, double hp, string name) : base(name, hp, weaponCreature, armor, positionX, positionY, attackType) { Direction = Direction.Up; IsDead = false; ShieldF = new ShieldF(); //Experiment if (AttackType == TypeOfAttack.Demonic) { weaponCreature.Damage = this.DemonicDamage; } }
public ICreature makeCreature(int positionX, int positionY, Weapon weapon, Armor armor, TypeOfAttack attackType, double hp, string name) { if (hp < 0) { throw new ArgumentException("HP has to above 0"); } ICreature entity = new Entities(positionX, positionY, weapon, armor, attackType, hp, name); return(entity); }
public override void takeDamage(float forceOfAttack, TypeOfAttack typeOfAttack) { this.forceOfAttack = forceOfAttack; this.typeOfAttack = typeOfAttack; }
public HumanPlayer(string desctription, double hitpoints, Weapon weapon, Armor armor, int fixedPositionX, int fixedPositionY, TypeOfAttack attackType) : base(desctription, hitpoints, weapon, armor, fixedPositionX, fixedPositionY, attackType) { Direction = Direction.Down; IsDead = false; CurrentHealth = 160; }
public void ChangeToMelee() { typeofAttack = TypeOfAttack.Melee_Weapon; }
public void ChangeToMMA() { typeofAttack = TypeOfAttack.No_Weapon; }
public double CheckDamagetoToArmorType(TypeOfAttack attackStyle, ArmorType armorType) { if (armorType == ArmorType.Plate) { //Defense against magic with Plate, LINQ if (attackStyle == TypeOfAttack.Magic) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Plate))); } //Defense against ranged with Plate, LINQ if (attackStyle == TypeOfAttack.Ranged) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Plate))); } //Defense against Mellee with Plate, LINQ if (attackStyle == TypeOfAttack.Ranged) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Plate))); } } if (armorType == ArmorType.Cloth) { //Defense against magic with Cloth, LINQ if (attackStyle == TypeOfAttack.Magic) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Cloth))); } //Defense against ranged with Cloth, LINQ if (attackStyle == TypeOfAttack.Ranged) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Cloth))); } //Defense against Mellee with Cloth, LINQ if (attackStyle == TypeOfAttack.Ranged) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Cloth))); } } if (armorType == ArmorType.Leather) { //Defense against magic with Leather, LINQ if (attackStyle == TypeOfAttack.Magic) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Leather))); } //Defense against ranged with Leather, LINQ if (attackStyle == TypeOfAttack.Ranged) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Leather))); } //Defense against Mellee with Cloth, LINQ if (attackStyle == TypeOfAttack.Melee) { return(_attackResDic.Values.Sum(damageDealth => damageDealth.adjustResistances(ArmorType.Leather))); } } return(Damage); }
void Start() { typeofAttack = TypeOfAttack.No_Weapon; anim = GetComponent <Animator>(); }