Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Targeting = GetComponent <ig_Targeting>();

        foreach (ig_DashNode node in Targeting.targetingNodes)
        {
            node.transform.localPosition *= dashRadius;
        }

        Health          = GetComponent <ig_Health>();
        Health.onDeath += Die;
        Health.onHit   += TakeHit;
    }
Ejemplo n.º 2
0
        public void CheckAbility(Vector3 leftStick, bool focusing)
        {
            if (focusing)
            {
                //Enable the targeting objects if using focus
                dashAroundMarker.SetActive(true);
                dashTargetMarker.SetActive(true);

                //Spherecast out from player to find a potential target
                RaycastHit hit;
                if (Physics.SphereCast(parent.transform.position, cc.radius * dashSearchArea, leftStick, out hit, dashDistance, dashMask))
                {
                    if (hit.transform.tag == "Target")
                    {
                        //Store the potential target of your dash
                        potentialTarget = hit.transform.gameObject;

                        //Get the nearest dash point around the target
                        ig_Targeting target = potentialTarget.GetComponent <ig_Targeting>();
                        potentialDashPoint = target.GetNearestNode(transform).position;
                    }
                }
                else
                {
                    //if the raycast hits nothing make the target nothing
                    potentialTarget = null;

                    //store the point to dash to at the dash distance
                    potentialDashPoint = new Vector3(parent.transform.position.x + (leftStick.x * dashDistance), parent.transform.position.y, parent.transform.position.z + (leftStick.z * dashDistance));
                }

                //Place the dash target markers or remove them
                if (potentialTarget != null)
                {
                    dashTargetMarker.transform.position = potentialTarget.transform.position;
                    dashAroundMarker.transform.position = potentialDashPoint;
                }
                else
                {
                    dashTargetMarker.transform.position = potentialDashPoint;
                    dashAroundMarker.transform.position = potentialDashPoint;
                }

                //lastDashPoint = potentialDashPoint;
            }

            //If not focusing
            else
            {
                if (dashTarget != null)
                {
                    if ((leftStick.x > 0.1f || leftStick.x < -0.1f) || (leftStick.z > 0.1f || leftStick.z < -0.1f))
                    {
                        //Get the point the left stick is being held
                        potentialDashPoint = dashTarget.transform.position;
                        potentialDashPoint = new Vector3(potentialDashPoint.x + (leftStick.x * dashTargetRadius), potentialDashPoint.y, potentialDashPoint.z + (leftStick.z * dashTargetRadius));
                        dashAroundMarker.transform.position = potentialDashPoint;

                        //Use that point to find the nearest node that can be dashed to
                        ig_Targeting targeting = dashTarget.GetComponent <ig_Targeting>();
                        potentialDashPoint = targeting.GetNearestNode(dashAroundMarker.transform).position;

                        //Enable and set the dash marker
                        if (dashAroundMarker.activeSelf == false)
                        {
                            dashAroundMarker.SetActive(true);
                        }
                        dashAroundMarker.transform.position = potentialDashPoint;
                    }
                    else
                    {
                        if (dashAroundMarker.activeSelf == true)
                        {
                            dashAroundMarker.SetActive(false);
                        }
                    }
                }
                else
                {
                    potentialDashPoint = parent.transform.position;
                    dashAroundMarker.SetActive(false);
                }
            }
        }