public GameObject GetOnPointer(FootController test, int direction) { Collider2D[] hits = Physics2D.OverlapBoxAll(test.position, new Vector2(test.width, test.height), 0, Utilities.GROUND_MASK); foreach (Collider2D hit in hits) { if (hit != null && hit.gameObject.tag == "pointer") { CellBehavior cc = hit.gameObject.GetComponent <CellBehavior>(); if (!cc.IsBlocked(direction)) { return(hit.gameObject); } } } foreach (Collider2D hit in hits) { if (hit != null && hit.gameObject.tag == "cell") { // does it have a parent that is a linked cell? Transform parentTransform = hit.gameObject.transform.parent; if (parentTransform != null && parentTransform.gameObject.tag == "linkedCell") { return(parentTransform.GetComponentInChildren <PointerController>().gameObject); } else { return(null); } } } return(null); }
virtual public void Start() { rigidbody = GetComponent <Rigidbody2D>(); foot = transform.Find("foot").GetComponent <FootController>(); isAirborne = true; otherPlayer = null; isLocked = false; }
private void MoveRubberBand(FootController foot) { Vector3 otherFootPosition = (foot.foot == Foot.Right) ? leftFootController.transform.position : rightFootController.transform.position; Vector3 stickDirection = (foot.foot == Foot.Right) ? inputThisFrame.rightStickVector.normalized : inputThisFrame.leftStickVector.normalized; Vector3 newDirection = Vector3.MoveTowards(movingTowards, stickDirection, footSmoothSpeed * Time.deltaTime); Vector3 nextPosition = foot.transform.position + newDirection * Time.deltaTime * footSpeed; float distanceFromOtherFoot = Vector3.Distance(otherFootPosition, nextPosition); float footSpeedThisFrame = footSpeed; foot.Move(newDirection * Time.deltaTime * footSpeedThisFrame); movingTowards = newDirection; }
void OnSceneGUI() { FootController foot = (FootController)target; Vector3[] vertices = { new Vector3(foot.position.x - foot.width * 0.5f, foot.position.y - foot.height * 0.5f, 0.0f), new Vector3(foot.position.x - foot.width * 0.5f, foot.position.y + foot.height * 0.5f, 0.0f), new Vector3(foot.position.x + foot.width * 0.5f, foot.position.y + foot.height * 0.5f, 0.0f), new Vector3(foot.position.x + foot.width * 0.5f, foot.position.y - foot.height * 0.5f, 0.0f), }; Handles.DrawSolidRectangleWithOutline(vertices, new Color(1, 1, 1, 0.2f), new Color(0, 0, 0, 1)); }
public GameObject GetOnCell(FootController test, int direction) { Collider2D[] hits = Physics2D.OverlapBoxAll(test.position, new Vector2(test.width, test.height), 0, Utilities.GROUND_MASK); foreach (Collider2D hit in hits) { if (hit != null && hit.gameObject.tag == "cell") { CellController cc = hit.gameObject.GetComponent <CellController>(); if (!cc.IsBlocked(direction)) { return(hit.gameObject); } } } return(null); }
virtual public void Start() { rigidbody = GetComponent <Rigidbody2D>(); foot = transform.Find("foot").GetComponent <FootController>(); loot = transform.Find("loot/canvas/text").GetComponent <Text>(); loot.text = ""; lootSprite = transform.Find("loot").GetComponent <SpriteRenderer>(); levelController = GameObject.Find("/TheLevel").GetComponent <LevelController>(); head = transform.Find("head").GetComponent <FootController>(); targetCell = null; basePointer = null; isAirborne = false; isLocked = false; }
private void Update() { LeftFoot = (FootController)GameObject.FindGameObjectWithTag("LeftFoot").GetComponent("FootController"); RightFoot = (FootController)GameObject.FindGameObjectWithTag("RightFoot").GetComponent("FootController"); //if (counter < 3) //{ // counter = counter + Time.deltaTime; //} //if (counter > 3) //{ // Destroy(ball); // ball.transform.position = spawn.position; // ball = Instantiate(ball); // startCounter = false; // counter = 0; //} }
private void Start() { foot = GetComponentInChildren <FootController>(); }
void Start() { controller = transform.parent.GetComponent <FootController>(); }
virtual public void Start() { rigidbody = GetComponent <Rigidbody2D>(); foot = transform.Find("foot").GetComponent <FootController>(); isLocked = false; }