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


C# Entity.getTargetLocation方法代码示例

本文整理汇总了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);
 }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:31,代码来源:SkillTeleport.cs

示例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;
     }
 }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:27,代码来源:SkillChainLightning.cs

示例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;
    }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:10,代码来源:SkillMortar.cs

示例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);
     }
 }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:11,代码来源:SkillBasicAttack.cs

示例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);
     }
 }
开发者ID:rwbysafire,项目名称:DemonHeart,代码行数:12,代码来源:SkillScattershot.cs


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