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


C# GameObject.?.GetComponent方法代码示例

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


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

示例1: mod_AdjustDamageDealt

		public void mod_AdjustDamageDealt(GameObject enemy, DamageInfo damage, bool testing) {
			if (IEModOptions.DisableFriendlyFire && gameObject && enemy?.GetComponent<Faction>()?.IsFriendly(gameObject) == true && base.IsPartyMember) {
				damage.IsCriticalHit = damage.Interrupts = damage.IsGraze =damage.IsKillingBlow = false;
				damage.IsMiss = true;
				return;
			}
			orig_AdjustDamageDealt(enemy, damage, testing);
		}
开发者ID:Bigtuna00,项目名称:IEMod.pw,代码行数:8,代码来源:mod_CharacterStats.cs

示例2: FriendlyRightNowAndAlsoWhenConfused

		public static bool FriendlyRightNowAndAlsoWhenConfused(GameObject target, GameObject caster) {
			var targetFaction = target?.GetComponent<Faction>();
			var casterFaction = caster?.GetComponent<Faction>();
			var targetAiController = GameUtilities.FindActiveAIController(target);
			if (IEModOptions.TargetTurnedEnemies && targetAiController != null && casterFaction != null) {
				var targetOriginallyFriendly = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction.CurrentTeam)
					== Faction.Relationship.Friendly;
				if (!targetOriginallyFriendly) {
					return false;
				}
			}
			return targetFaction?.IsFriendly(caster) == true || casterFaction?.IsFriendly(target) == true;
		}
开发者ID:tjayharvey,项目名称:IEMod.pw,代码行数:13,代码来源:mod_AttackBase.cs

示例3: mod_CanActivate

		public bool mod_CanActivate(GameObject victim) {
			if (!this.m_trap_initialized)
			{
				Debug.LogError("Cannot activate uninitialized trap!");
				return false;
			}
			if (IEModOptions.DisableFriendlyFire) {
				Faction victimFaction = victim?.GetComponent<Faction>();
				if (victimFaction?.isPartyMember == true && this.IsPlayerOwnedTrap)
				{
					return false;
				}
			}
			return orig_CanActivate(victim);
		}
开发者ID:Bigtuna00,项目名称:IEMod.pw,代码行数:15,代码来源:mod_Trap.cs

示例4: HostileEvenIfConfused

		public static bool HostileEvenIfConfused(GameObject target, GameObject caster) {
			var targetFaction = target?.GetComponent<Faction>();
			var casterFaction = caster?.GetComponent<Faction>();
			var targetAiController = GameUtilities.FindActiveAIController(target);
			if (targetFaction?.IsHostile(caster) == true || casterFaction?.IsHostile(target) == true) {
				//they're actually hostile
				return true;
			}
			if (targetAiController == null) {
				//not AI controller. Can never be confused.
				return false;
			}
			if (!IEModOptions.TargetTurnedEnemies) {
				//no more checks if the option is disabled.
				return false;
			}
		
			var targetOriginal = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction?.CurrentTeam)
				== Faction.Relationship.Hostile;

			return targetOriginal;
		}
开发者ID:tjayharvey,项目名称:IEMod.pw,代码行数:22,代码来源:mod_AttackBase.cs


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