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); }
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; } }
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; }
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); } }
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); } }