本文整理汇总了C#中Entity.getTargetLocation方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.getTargetLocation方法的具体用法?C# Entity.getTargetLocation怎么用?C# Entity.getTargetLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.getTargetLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: skillLogic
public override void skillLogic(Entity mob, Stats stats)
{
GameObject teleport = GameObject.Instantiate(Resources.Load<GameObject>("Skills/Teleport/Teleport"));
LineRenderer lineRenderer = teleport.AddComponent<LineRenderer>();
lineRenderer.material = Resources.Load<Material>("Skills/Teleport/blur");
lineRenderer.SetColors(new Color(1,1,0,0.5f), new Color(1,1,0,1));
lineRenderer.SetWidth(1, 1);
lineRenderer.SetPosition(0, mob.feetTransform.position);
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Skills/Teleport/teleport"), mob.feetTransform.position);
displayFlash(mob);
Vector3 teleportLocation;
if (Vector3.Distance(mob.feetTransform.position, mob.getTargetLocation()) > maxDistance)
teleportLocation = mob.feetTransform.position + ((mob.getTargetLocation() - mob.feetTransform.position).normalized * maxDistance);
else
teleportLocation = mob.getTargetLocation();
if (!Physics2D.OverlapPoint(teleportLocation))
mob.gameObject.transform.position = teleportLocation;
else {
RaycastHit2D[] hit = Physics2D.LinecastAll(mob.feetTransform.position, teleportLocation);
for (int x = hit.Length - 1; x >= 0; x--) {
teleportLocation = hit[x].point;
teleportLocation -= (mob.getTargetLocation() - mob.feetTransform.position).normalized * mob.gameObject.GetComponent<CircleCollider2D>().radius;
if (Physics2D.OverlapPointAll(teleportLocation).Length == 0) {
mob.gameObject.transform.position = hit[x].point;
break;
}
}
}
lineRenderer.SetPosition(1, (mob.getTargetLocation() - mob.feetTransform.position).normalized*mob.gameObject.GetComponent<CircleCollider2D>().radius*2 + mob.feetTransform.position);
displayFlash(mob);
}
示例2: skillLogic
public override void skillLogic(Entity mob, Stats stats)
{
// Debug.Log("chainlightning");
GameObject chainLightning = GameObject.Instantiate(Resources.Load<GameObject>("Skills/ChainLightning/Chainlightning"));
chainLightning.transform.position = mob.headTransform.position;
chainLightning.GetComponent<ChainLightning>().stats = stats;
chainLightning.GetComponent<ChainLightning>().chainTimes = (int)properties["chainCount"];
chainLightning.GetComponent<ChainLightning>().maxDistance = maxDistance;
Vector3 targetLocation;
if (Vector3.Distance(mob.headTransform.position, mob.getTargetLocation()) > maxDistance)
targetLocation = mob.headTransform.position + (mob.headTransform.up * maxDistance);
else
targetLocation = mob.getTargetLocation();
foreach (RaycastHit2D lineCast in Physics2D.LinecastAll(mob.headTransform.position, targetLocation)) {
if (lineCast.collider.CompareTag("Wall")) {
targetLocation = lineCast.point;
break;
}
}
GameObject enemy = FindClosestEnemy(mob, stats.tag, targetLocation);
if (enemy != null) {
chainLightning.GetComponent<ChainLightning>().enemy = enemy;
chainLightning.GetComponent<ChainLightning>().target = enemy.GetComponent<Mob>().feetTransform.position;
} else {
chainLightning.GetComponent<ChainLightning>().target = targetLocation;
}
}
示例3: skillLogic
public override void skillLogic(Entity entity, Stats stats)
{
Vector3 targetLocation = entity.getTargetLocation();
GameObject hitIndicator = GameObject.Instantiate(Resources.Load<GameObject>("Skills/Mortar/MortarHitIndicator"));
hitIndicator.transform.position = targetLocation;
hitIndicator.AddComponent<HitIndicator>();
hitIndicator.GetComponent<HitIndicator>().skill = this;
hitIndicator.GetComponent<HitIndicator>().stats = stats;
}
示例4: attack
void attack(Entity mob, Stats stats)
{
float spreadCalcDistance = 6;
float startDistance = 2;
float baseAngle = 5;
float ratio = (Mathf.Clamp(Vector3.Distance(mob.getTargetLocation(), mob.headTransform.position), startDistance, spreadCalcDistance + startDistance) - startDistance) / spreadCalcDistance;
float angleOfSpread = (((1 - ratio) * 4) + ratio) * baseAngle;
for (int i = 0; i < properties["projectileCount"]; i++) {
fireArrow(mob, stats, ((properties["projectileCount"] - 1) * angleOfSpread / -2) + i * angleOfSpread);
}
}
示例5: attack
void attack(Entity mob, Stats stats)
{
float y = Vector3.Distance(mob.getTargetLocation(), mob.feetTransform.position);
if (y > 6)
y = 6;
else if (y < 2)
y = 2;
float angleOfSpread = (((1 - (y - 2) / 4) * 3) + 1) * 5;
for (int i = 0; i < properties["projectileCount"]; i++) {
fireArrow(mob, stats, ((properties["projectileCount"] - 1) * angleOfSpread / -2) + i * angleOfSpread);
}
}