public override void ReactToNode(SeasonEmitter node) { if (!iceBlocks.ContainsKey(node)) { iceBlocks.Add(node, Instantiate <BoxCollider2D>(icePrefab)); } }
public void DropNode() { //Only drop a node if you have one in the first place if (eHeldNode != null) { eHeldNode.transform.parent = null; eHeldNode.Activate(); eHeldNode = null; } }
public void DropNode() { //Only drop a node if you have one in the first place if (eHeldNode != null) { eHeldNode.transform.parent = null; eHeldNode.Activate(); eHeldNode = null; } }
public void PickUpNode() { SeasonEmitter nodeToPickUp = GameManager.GetNearestNode(gameObject.transform.position); //If the node is within pickup range, parent it to the player character and disable it if (Vector3.Distance(nodeToPickUp.transform.position, gameObject.transform.position) < nodePickupRange) { nodeToPickUp.gameObject.transform.parent = gameObject.transform; nodeToPickUp.Deactivate(); eHeldNode = nodeToPickUp; } }
//SeasonEmitters register themselves in the sceneNodes list in their Start() function, so all nodes in the scene are tracked //Returns the index of the node registered public static int RegisterNode(SeasonEmitter node) { if (instance.sceneNodes.Count < kMaxNodes) { instance.sceneNodes.Add(node); return(instance.sceneNodes.Count - 1); } else { //Cleans up nodes that are not being used by the scene Debug.LogWarning("Too many nodes in scene! (Max = " + kMaxNodes + ")"); GameObject.Destroy(node.gameObject); return(-1); } }
public override void ReactToNode(SeasonEmitter node) { }
public abstract void ReactToNode(SeasonEmitter node);
private Bounds FindIntersectionBounds(SeasonEmitter node) { Bounds results = new Bounds(); List<Vector3> corners = new List<Vector3>(); List<Vector3> candidatePoints = new List<Vector3>(); List<Vector3> intersects; List<Vector3> selectedPoints = new List<Vector3>(); Vector3 resultMin; Vector3 resultMax; //Add corners of collider corners.Add(new Vector3(waterCollider.bounds.max.x, waterCollider.bounds.max.y, 0)); corners.Add(new Vector3(waterCollider.bounds.max.x, waterCollider.bounds.min.y, 0)); corners.Add(new Vector3(waterCollider.bounds.min.x, waterCollider.bounds.max.y, 0)); corners.Add(new Vector3(waterCollider.bounds.min.x, waterCollider.bounds.min.y, 0)); //Add quadrants of node candidatePoints.Add(new Vector3(node.transform.position.x, node.transform.position.y + node.radius, 0)); candidatePoints.Add(new Vector3(node.transform.position.x, node.transform.position.y - node.radius, 0)); candidatePoints.Add(new Vector3(node.transform.position.x + node.radius, node.transform.position.y, 0)); candidatePoints.Add(new Vector3(node.transform.position.x - node.radius, node.transform.position.y, 0)); //Add intersects with top of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.max.y, false); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with bottom of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.min.y, false); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with left side of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.min.x, true); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with right side of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.max.x, true); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Adds non-corner points that are within the bounds of the water foreach (Vector3 p in candidatePoints) { if (waterCollider.OverlapPoint(p)) { selectedPoints.Add(p); } } //Adds corner points that are within the node foreach (Vector3 corner in corners) { if (Vector3.Distance(corner, node.transform.position) <= node.radius) { selectedPoints.Add(corner); } } //Find the bounding rectangle of the selectedPoints if (selectedPoints.Count >= 1) { resultMax = selectedPoints[0]; resultMin = selectedPoints[0]; for (int i = 1; i < selectedPoints.Count; i++) { //Set Minimum if (selectedPoints[i].x < resultMin.x) { resultMin.x = selectedPoints[i].x; } if (selectedPoints[i].y < resultMin.y) { resultMin.y = selectedPoints[i].y; } //Set Maximum if (selectedPoints[i].x > resultMax.x) { resultMax.x = selectedPoints[i].x; } if (selectedPoints[i].y > resultMax.y) { resultMax.y = selectedPoints[i].y; } } if (resultMin != resultMax) { results.SetMinMax(resultMin, resultMax); } else { results.SetMinMax(Vector3.zero, Vector3.zero); } } else { results.SetMinMax(Vector3.zero, Vector3.zero); } return results; }
public override void ReactToNode(SeasonEmitter node) { if (!iceBlocks.ContainsKey(node)) { iceBlocks.Add(node, Instantiate<BoxCollider2D>(icePrefab)); } }
private Bounds FindIntersectionBounds(SeasonEmitter node) { Bounds results = new Bounds(); List <Vector3> corners = new List <Vector3>(); List <Vector3> candidatePoints = new List <Vector3>(); List <Vector3> intersects; List <Vector3> selectedPoints = new List <Vector3>(); Vector3 resultMin; Vector3 resultMax; //Add corners of collider corners.Add(new Vector3(waterCollider.bounds.max.x, waterCollider.bounds.max.y, 0)); corners.Add(new Vector3(waterCollider.bounds.max.x, waterCollider.bounds.min.y, 0)); corners.Add(new Vector3(waterCollider.bounds.min.x, waterCollider.bounds.max.y, 0)); corners.Add(new Vector3(waterCollider.bounds.min.x, waterCollider.bounds.min.y, 0)); //Add quadrants of node candidatePoints.Add(new Vector3(node.transform.position.x, node.transform.position.y + node.radius, 0)); candidatePoints.Add(new Vector3(node.transform.position.x, node.transform.position.y - node.radius, 0)); candidatePoints.Add(new Vector3(node.transform.position.x + node.radius, node.transform.position.y, 0)); candidatePoints.Add(new Vector3(node.transform.position.x - node.radius, node.transform.position.y, 0)); //Add intersects with top of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.max.y, false); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with bottom of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.min.y, false); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with left side of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.min.x, true); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Add intersects with right side of collider intersects = FindCircleLineIntersect(node.transform.position, node.radius, waterCollider.bounds.max.x, true); foreach (Vector3 p in intersects) { candidatePoints.Add(p); } //Adds non-corner points that are within the bounds of the water foreach (Vector3 p in candidatePoints) { if (waterCollider.OverlapPoint(p)) { selectedPoints.Add(p); } } //Adds corner points that are within the node foreach (Vector3 corner in corners) { if (Vector3.Distance(corner, node.transform.position) <= node.radius) { selectedPoints.Add(corner); } } //Find the bounding rectangle of the selectedPoints if (selectedPoints.Count >= 1) { resultMax = selectedPoints[0]; resultMin = selectedPoints[0]; for (int i = 1; i < selectedPoints.Count; i++) { //Set Minimum if (selectedPoints[i].x < resultMin.x) { resultMin.x = selectedPoints[i].x; } if (selectedPoints[i].y < resultMin.y) { resultMin.y = selectedPoints[i].y; } //Set Maximum if (selectedPoints[i].x > resultMax.x) { resultMax.x = selectedPoints[i].x; } if (selectedPoints[i].y > resultMax.y) { resultMax.y = selectedPoints[i].y; } } if (resultMin != resultMax) { results.SetMinMax(resultMin, resultMax); } else { results.SetMinMax(Vector3.zero, Vector3.zero); } } else { results.SetMinMax(Vector3.zero, Vector3.zero); } return(results); }
//SeasonEmitters register themselves in the sceneNodes list in their Start() function, so all nodes in the scene are tracked //Returns the index of the node registered public static int RegisterNode(SeasonEmitter node) { if (instance.sceneNodes.Count < kMaxNodes) { instance.sceneNodes.Add(node); return instance.sceneNodes.Count - 1; } else { //Cleans up nodes that are not being used by the scene Debug.LogWarning("Too many nodes in scene! (Max = " + kMaxNodes + ")"); GameObject.Destroy(node.gameObject); return -1; } }
public void PickUpNode() { SeasonEmitter nodeToPickUp = GameManager.GetNearestNode(gameObject.transform.position); //If the node is within pickup range, parent it to the player character and disable it if (Vector3.Distance(nodeToPickUp.transform.position, gameObject.transform.position) < nodePickupRange) { nodeToPickUp.gameObject.transform.parent = gameObject.transform; nodeToPickUp.Deactivate(); eHeldNode = nodeToPickUp; } }
public abstract void ReactToNode(SeasonEmitter node);
protected void DropNode() { if (IsGrounded(groundedLookAhead, false)) { //Checks for colliders beneath the player in the "No Node Drop" Layer, which prevent placing nodes int layermask = 1 << 11; if (Physics2D.Raycast(gameObject.transform.position, Vector3.down, 1.0f, layermask, -1.0f, 1.0f).collider == null) { eHeldNode.transform.parent = null; eHeldNode.Activate(); eHeldNode = null; } } }
public override void ReactToNode(SeasonEmitter node) { }