private void OnTriggerStay2D(Collider2D col)//InteractionBounds HitBox { //Debug.Log(LoopNum); //CircleCollider2D[] Colliders = col.GetComponents<CircleCollider2D>(); //if (col.GetComponent<CircleCollider2D>() == InteractionBounds) { Debug.Log("Interact Bounds"); } //if (col.GetComponent<CircleCollider2D>() == HitBox) { Debug.Log("Hit Box"); } if (col.gameObject.tag == "Obstacle" && GoalPosPath.Length != 0)//col.GetComponent<CircleCollider2D>() == InteractionBounds && { GFunction_Library.TravelPathTransform(gameObject, transform.position, ref GoalPosPath, ref DelUpdate, ref DelSub, 1); GameObject[] ToDelete; ToDelete = GameObject.FindGameObjectsWithTag("Path-Marker"); foreach (GameObject delete in ToDelete) { Destroy(delete); } } if (col.gameObject.tag == "Enemy")//col.GetComponent<CircleCollider2D>() == InteractionBounds && { Debug.Log("Enemy Encountered"); InCombat = true; if (!Combatants.Contains(col.gameObject)) { Combatants.Add(col.gameObject); } if (!UnitController.Contains(col.gameObject.GetComponent <Unit_Controller_Script>())) { UnitController.Add(col.gameObject.GetComponent <Unit_Controller_Script>()); } } }
void FixedUpdate() { DelSub = false; if (GoalPosPath.Length >= 1 && NoObstacle == true) { GFunction_Library.TravelPathTransform(gameObject, GoalPosPath[0], ref GoalPosPath, ref DelUpdate, ref DelSub, GoalAdvanceSpeed); } LoopNum++; //Debug.Log(LoopNum + " " + DelSub + " " + DelUpdate); }
void FixedUpdate() { DelSub = false; if (GoalPosPath.Length >= 1 && NoObstacle == true)//PathFind(GoalPosPath[0], true, GoalAdvanceSpeed) { GFunction_Library.TravelPathVelocity(gameObject, GoalPosPath[0], ref GoalPosPath, ref DelUpdate, ref DelSub, GoalAdvanceSpeed, UnitRB); } //PathFind(Perception); LoopNum++; }
void Update() { GlobalMousePos = Camera.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); //Transform.childCount Transform.GetChild UnitStatsUpdate(); if (Input.GetMouseButton(0) && Selected == false && Selectable == true) { SelectRay = Physics2D.GetRayIntersection(Camera.main.ScreenPointToRay(Input.mousePosition));//, layerMask if (SelectRay == gameObject && SelectRay.transform.name == transform.name) { Selected = true; } } else if (Selectable == false) { Selected = false; } if (Selected == true) { if (Input.GetMouseButtonDown(1)) { Selected = false; } if (Input.GetButton("Left Shift") && Input.GetMouseButtonDown(0)) { GoalPosPath = GFunction_Library.VectArrayAdd(GoalPosPath, GlobalMousePos); DelUpdate = GoalPosPath.Length; GameObject PathMarker = Instantiate(PrefabList[0]); PathMarker.transform.position = new Vector3(GlobalMousePos.x, GlobalMousePos.y, 0); } if (Input.GetButton("Left Shift") && Input.GetButton("Left Control") && Input.GetMouseButtonDown(0)) { } } }
private void OnTriggerStay2D(Collider2D col)//InteractionBounds HitBox { //Debug.Log(LoopNum); //CircleCollider2D[] Colliders = col.GetComponents<CircleCollider2D>(); //if (col.GetComponent<CircleCollider2D>() == InteractionBounds) { Debug.Log("Interact Bounds"); } //if (col.GetComponent<CircleCollider2D>() == HitBox) { Debug.Log("Hit Box"); } if (col.gameObject.tag == "Obstacle" && GoalPosPath.Length != 0)//col.GetComponent<CircleCollider2D>() == InteractionBounds && { //GoalPosPath = VectArraySubtract(GoalPosPath, 0); //DelUpdate = GoalPosPath.Length; DelSub = true; GFunction_Library.TravelPathVelocity(gameObject, transform.position, ref GoalPosPath, ref DelUpdate, ref DelSub, 1, UnitRB); //TravelPathVelocity(GameObject Object, Vector3 EndPosition, Vector3[] path, int pathLength, bool markerComplete, float goalAdvanceSpeed, Rigidbody2D RB) GameObject[] ToDelete; ToDelete = GameObject.FindGameObjectsWithTag("Path-Marker"); foreach (GameObject delete in ToDelete) { Destroy(delete); } } }