bool ReachCollectible(Node node) { WaterBubble w = LevelManager.inst.IsAWaterBubble(node); if (w != null) { w.PickUp(); return(true); } return(false); }
IEnumerator HitAnim(Node node, float speed, bool isApit) { //float dst; bool checkWaterBubble = false; Vector2 nodePos = new Vector2(node.worldPosition.x, node.worldPosition.z); Vector2 rockPos; Vector2 startRockPos = new Vector2(m_transform.position.x, m_transform.position.z); float totalDistance = (startRockPos - nodePos).sqrMagnitude - .1f; bool forward = true; while (forward) { rockPos = new Vector2(m_transform.position.x, m_transform.position.z); if ((startRockPos - rockPos).sqrMagnitude > totalDistance) { forward = false; } if (!checkWaterBubble && (rockPos - nodePos).sqrMagnitude < .5f) { WaterBubble w = LevelManager.inst.IsAWaterBubble(node); if (w) { w.Spread(); } } if (isApit) { float d = (nodePos - rockPos).magnitude; if (d < .3f) { float y = Mathf.Lerp(m_transform.position.y, -1.0f, 1 - (d / .3f)); m_transform.position = new Vector3(m_transform.position.x, y, m_transform.position.z); } } m_transform.position += ((node.worldPosition - m_transform.position).normalized * Time.deltaTime * speed); yield return(null); } //m_transform.position = node.worldPosition; m_transform.position = new Vector3(node.worldPosition.x, isApit ? -1.0f : 0, node.worldPosition.z); LevelManager.inst.UpdateRockNode(crtNode, this, isApit ? null : node); crtNode = isApit ? null : node; }