Esempio n. 1
0
		public void TakeDamage (GameObject unit, float p, float c, float k) {
			Damage damage = new Damage(p, c, k);
			ReceiveDamage(unit, damage);
		}
Esempio n. 2
0
		public void ReceiveDamage (GameObject fromUnit, Damage damage) {
			var args = new UnitStateEventArgs();
			args.unit = fromUnit;
			args.target = behavior.unit;
			args.damage = damage;
			OnReceiveDamage (args);
			damage = args.damage; // Превосходно! Урон изменяется!
			// ---
			damage.piercing = Damage.CalculateDamage (damage.piercing, defence.piercing, resistances.piercing);
			damage.cutting = Damage.CalculateDamage (damage.cutting, defence.cutting, resistances.cuttinge);
			damage.kick = Damage.CalculateDamage (damage.kick, defence.kick, resistances.kick);
			// ---
			if (!damage.unbloked)
				if (UnityEngine.Random.Range (0.0f, 1.0f) <= defence.evadeChance) {
					damage.piercing *= defence.evadeFactor;
					damage.cutting *= defence.evadeFactor;
					damage.kick *= defence.evadeFactor;
				}
			if (!damage.unevade)
				if (UnityEngine.Random.Range (0.0f, 1.0f) <= defence.blockChance+defence.blockBaseChance) {
					damage.piercing *= defence.blockFactor;
					damage.cutting *= defence.blockFactor;
					damage.kick *= defence.blockFactor;
				}
			float dmg = damage.piercing + damage.cutting + damage.kick;
			if (dmg <= 0f) return;
			AddHealth( -dmg );
			// ---
			args = new UnitStateEventArgs();
			args.unit = fromUnit;
			args.target = behavior.unit;
			args.damage = damage;
			OnApplyDamage(args);
			// ---
			if (body.health <= 0.0f) {
				Death();
			}
		}