当前位置: 首页>>代码示例>>C#>>正文


C# Entities.setHp方法代码示例

本文整理汇总了C#中Entities.setHp方法的典型用法代码示例。如果您正苦于以下问题:C# Entities.setHp方法的具体用法?C# Entities.setHp怎么用?C# Entities.setHp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entities的用法示例。


在下文中一共展示了Entities.setHp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: skillAction

	public void skillAction(Entities user, Entities[] tar, bool hit){
		
		if (MpCost > 0 && HpCost > 0) {
			if (user.getHp() >= HpCost) {
				user.setHp(-HpCost);
			} else {
				Debug.Log ("Not enough HP!");
				return;
			}
			if (user.getMp() >= MpCost) {
				user.setMp(-MpCost);
			} else {
				Debug.Log ("Not enough MP!");
				return;
			}
		} else if (HpCost > 0) {
			if (user.getHp() >= HpCost) {
				user.setHp(-HpCost);
			} else {
				Debug.Log ("Not enough HP!");
				return;
			}
		} else if (MpCost > 0) {
			if (user.getMp() >= MpCost) {
				user.setMp(-MpCost);
			} else {
				Debug.Log ("Not enough MP!");
				return;
			}
		}

		// If it hit, do damage.
		if (hit) {
			if (DamageType == damage_type.single) {
				if (DamageEffect == damage_effect.hp) {
					tar [0].setHp(-(Damage - (tar [0].End / 3)));
				} else if (DamageEffect == damage_effect.mp) {
					tar [0].setMp( -(Damage - (tar [0].End / 3)));
				} else {
					Debug.Log ("TURN DAMAGER NOT IMPLEMENTED YET");
				}
			} else if (DamageType == damage_type.aoe) {
				foreach (Entities e in tar) {
					if (DamageEffect == damage_effect.hp) {
						e.setHp(-(Damage - (e.End / 3)));
					} else if (DamageEffect == damage_effect.mp) {
						e.setMp( -(Damage - (e.End / 3)));
					} else {
						Debug.Log ("TURN DAMAGER NOT IMPLEMENTED YET");
					}
				}
			} else if (DamageType == damage_type.dot) {
				Debug.Log ("Turn based effects not implemented yet");	
			}
			user.Damage = Damage;
		}
	}
开发者ID:KingCrazy,项目名称:Relentless,代码行数:57,代码来源:Skill.cs

示例2: Heal

	public void Heal(Entities t){
		//GameObject tar = gm.localPlayer.GetComponent<PlayerHandler> ().Target;
		if (t != null) {
			//Entities t = tar.GetComponent<Entities> (); // Figure out how abstract works better
			
			// i.Special is to check if percentage is used. Special is a bool to indicate a special case.
			// This section checks what item type it is, then goes ahead and does the appropriate calculations.
			// t is the PlayerHandler script of the targeted player.
			// Maybe add healing enemy functionality?

			if ((ItemType)type == ItemType.HP) {
				if (Special) {
					// Divided by 100f because if it were only by 100 it would not work. It needs to be read as a float.
					t.setHp((int)((Amt / 100f) * t.MaxHp));
				} else {
					t.setHp(Amt);
				}
			} else if ((ItemType)type == ItemType.MP) {
				if (Special) {
					t.setMp((int)((Amt / 100f) * t.MaxMp));
				} else {
					t.setMp(Amt);
				}
			}
			Quantity -= 1;
		} else {
			Debug.Log("Target is not valid!");
		}
	}
开发者ID:KingCrazy,项目名称:Relentless,代码行数:29,代码来源:Item.cs

示例3: dealDamage

	public void dealDamage(int dmg, Entities tar){
		tar.setHp(-dmg);
	}
开发者ID:KingCrazy,项目名称:Relentless,代码行数:3,代码来源:Entities.cs


注:本文中的Entities.setHp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。