void Bounce(IsMergeable mergeScript) { Vector3 mergepos = mergeScript.gameObject.transform.position; Vector3 distance = new Vector3(mergepos.x - transform.position.x, mergepos.y - transform.position.y, 0).normalized; transform.position = mergepos + distance; }
void OnCollisionEnter2D(Collision2D coll) { PlayerMerge mergeScript = null; try { mergeScript = coll.gameObject.GetComponent <PlayerMerge>(); } catch { } if (mergeScript != null) { Merge(); if (UpdatedSize != null) { UpdatedSize(size); } } if (UpdatedSize != null) { UpdatedSize(size); } if (HitObject != null) { IsMergeable.HitObject(this, coll.gameObject); } }
void StopRunning(IsMergeable mergeScript, GameObject hitObject) { if (mergeScript.gameObject.tag == "Bull") { stopRunning = true; } }
//public function that starts the camera shaking. public void Shake(PlayerMerge x = null, IsMergeable y = null) { if (!isShacking) { isShacking = true; StartCoroutine(CameraShaking()); } }
void Bounce(IsMergeable mergeScript) { Vector2 mergepos = (Vector2)mergeScript.gameObject.transform.position; Vector2 distance = (mergepos - (Vector2)transform.position); applyTranslation((Vector2)(mergepos + distance), -2); StartCoroutine(BounceCooldown()); }
void MergeHit(IsMergeable hitObj, GameObject gotHitObject) { if (hitObj.gameObject.tag == "Bull" && gotHitObject.gameObject == gameObject) { //play particles and stuff DestroyMe(); } }
void PlayerMerged(IsMergeable mergeScript) { if (mergeScript.mergeMesh != null) { GameObject mergeStuff = Instantiate(mergeScript.mergeMesh) as GameObject; mergeStuff.transform.rotation = Random.rotation; mergeStuff.transform.parent = gameObject.transform; mergeStuff.transform.position = Vector3.zero; } }
void MergeTexture(IsMergeable mergeScript) { Texture tex = mergeScript.tex; texType type = mergeScript.type; if (tex != null) { myMaterial.mainTexture = MergeNewTex( myMaterial.mainTexture as Texture2D, tex as Texture2D, highlightTextures[(int)type] as Texture2D ) as Texture; } }
void MergeHappend(IsMergeable mergeScript) { //if (CanMerge == true) { float otherSize = mergeScript.size; Texture2D otherTexture = mergeScript.tex; if (size >= otherSize) { if (size < maxSize) { size += otherSize; if (IMerged != null) { IMerged(mergeScript); } if (mergeScript.gameObject.tag == "HealthPack") { ChangeHealth(1); } } mergeScript.DestroyMe(); } //grow(), merge and destroy other else if (size > minSize) { if (IFailedToMerge != null) { ChangeHealth(-1); if (IFailedToMerge != null) { IFailedToMerge(this, mergeScript); } } } //Break into two() if (UpdatedSize != null) { UpdatedSize(size); foreach (Transform child in GetComponentInChildren <Transform>()) { if (child.tag == "Waste") { child.localScale = transform.localScale; } } } //} }
void SplitInTwo(PlayerMerge playerObject, IsMergeable otherMerge) { playerObject.size /= 2; GameObject playerWaste = Instantiate(playerObject.gameObject) as GameObject; StartCoroutine(CloneBall(playerWaste.GetComponent <CircleCollider2D>())); playerWaste.GetComponent <Rigidbody2D>().velocity = playerObject.GetComponent <Rigidbody2D>().velocity.normalized; foreach (MonoBehaviour script in playerWaste.GetComponents <MonoBehaviour>()) { Destroy(script); } foreach (Transform child in playerWaste.GetComponentsInChildren <Transform>()) { if (child.gameObject != playerWaste) { Destroy(child.gameObject); } } playerWaste.AddComponent <RotateAroundWorld>(); IsMergeable mergeScript = playerWaste.AddComponent <IsMergeable>(); mergeScript.size = playerObject.size; ChangeToSize sizeScript = playerWaste.AddComponent <ChangeToSize>(); sizeScript.SizeMultiplier = playerObject.gameObject.GetComponent <ChangeToSize>().SizeMultiplier; playerWaste.AddComponent <DisplaySize>(); sizeScript.UpdateSize(mergeScript.size); }
void Awake() { mergeScript = GetComponent <IsMergeable>(); }
void SucceedsToMerge(IsMergeable temp) { Instantiate(mergeParticle, transform.position, Quaternion.identity); }
void FailingToMerge(PlayerMerge temp, IsMergeable otherMerge) { Instantiate(mergeFailParticle, transform.position, Quaternion.identity); }
void Awake() { rb = GetComponent <Rigidbody2D>(); mergeScript = GetComponent <IsMergeable>(); }
public void PlayerMerged(PlayerMerge pMovement, IsMergeable mergeScript) { CancleDash(); Bounce(mergeScript); }
public void PlayerMerged(PlayerMerge pMerge, IsMergeable mergeScript) { Bounce(mergeScript); }