public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility) { Vector3 dir = Camera.main.transform.forward; target.GetComponent <RootUnit>().Shove(15, dir); target.moveAbilityTimer = 0; }
public override void CastingTimeCheck() { if (currentAbility != null) { currentCastingTime += Time.deltaTime; if (currentCastingTime > currentAbility.enemyAbilityStats.castTime) { var newA = currentAbility.CreateWorldAbility(unitID); newA.gameObject.layer = 11; if (newA.enemyAbilityStats.behavior == EnemyAbilityStats.Behavior.Projectile) { newA.transform.position = transform.position; Vector3 leadPosition = UtilityService.FirstOrderIntercept(transform.position, new Vector3(), newA.enemyAbilityStats.speed, currentTarget.transform.position, currentTarget.GetComponent <Rigidbody>().velocity); newA.transform.LookAt(leadPosition + new Vector3(0, currentTarget.GetComponent <CapsuleCollider>().height / 2, 0)); } else if (newA.enemyAbilityStats.behavior == EnemyAbilityStats.Behavior.Area_Hit) { newA.transform.position = currentTargetPoint; } currentCastingTime = 0; currentAbility = null; return; } } }
public static Vector3 LineOfSightCheckRootUnit(Vector3 viewerEyes, RootUnit subject) { RaycastHit lineOfSightTop; RaycastHit lineOfSightCenter; RaycastHit lineOfSightBottom; RaycastHit lineOfSightFront; RaycastHit lineOfSightBack; RaycastHit lineOfSightLeft; RaycastHit lineOfSightRight; var mesh = subject.GetComponent <CapsuleCollider>(); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, 0), Color.red); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, 0), Color.green); Debug.DrawLine(viewerEyes, subject.transform.position, Color.blue); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, mesh.radius), Color.black); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, -mesh.radius), Color.white); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(-mesh.radius, mesh.height, 0), Color.gray); Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(mesh.radius, mesh.height, 0), Color.cyan); Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, 0) - viewerEyes, out lineOfSightCenter, 50); if (lineOfSightCenter.collider.GetComponent <RootUnit>()) { return(lineOfSightCenter.point); } Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, 0) - viewerEyes, out lineOfSightTop, 50); if (lineOfSightTop.collider.GetComponent <RootUnit>()) { return(lineOfSightTop.point); } Physics.Raycast(viewerEyes, subject.transform.position - viewerEyes, out lineOfSightBottom, 50); if (lineOfSightBottom.collider.GetComponent <RootUnit>()) { return(lineOfSightBottom.point); } Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, mesh.radius) - viewerEyes, out lineOfSightFront, 50); if (lineOfSightFront.collider.GetComponent <RootUnit>()) { return(lineOfSightFront.point); } Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, -mesh.radius) - viewerEyes, out lineOfSightBack, 50); if (lineOfSightBack.collider.GetComponent <RootUnit>()) { return(lineOfSightBack.point); } Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(-mesh.radius, mesh.height, 0) - viewerEyes, out lineOfSightLeft, 50); if (lineOfSightLeft.collider.GetComponent <RootUnit>()) { return(lineOfSightLeft.point); } Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(mesh.radius, mesh.height, 0) - viewerEyes, out lineOfSightRight, 50); if (lineOfSightRight.collider.GetComponent <RootUnit>()) { return(lineOfSightRight.point); } return(new Vector3()); }