public void Pop() { if (!this.m_popped) { this.m_popped = true; AudioSource effectSource; if (this.m_ghostBalloon) { effectSource = WPFMonoBehaviour.gameData.commonAudioCollection.ghostBalloonPop[UnityEngine.Random.Range(0, WPFMonoBehaviour.gameData.commonAudioCollection.ghostBalloonPop.Length)]; } else { effectSource = WPFMonoBehaviour.gameData.commonAudioCollection.balloonPop; } Singleton <AudioManager> .Instance.SpawnOneShotEffect(effectSource, base.transform.position); WPFMonoBehaviour.effectManager.CreateParticles(WPFMonoBehaviour.gameData.m_ballonParticles, base.transform.position, false); base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), -1); if (this.m_balancer) { this.m_balancer.RemoveBalloon(); } this.CheckBalloonPopperAchievement(); base.contraption.RemovePart(this); UnityEngine.Object.Destroy(base.gameObject); } }
public void FixedUpdate() { float d = this.LimitForceForSpeed(this.m_force, this.m_direction); base.rigidbody.AddForce(d * this.m_direction, ForceMode.Force); if (this.m_springJoint && !this.m_springJoint.connectedBody) { UnityEngine.Object.Destroy(this.m_rope.GetComponent <LineRenderer>()); UnityEngine.Object.Destroy(this.m_rope); UnityEngine.Object.Destroy(this.m_springJoint); base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), -1); } }
public static BasePart.PartType CombinedTypeForGadgetButtonOrdering(BasePart.PartType originalType) { BasePart.PartType partType = BasePart.BaseType(originalType); if (partType == BasePart.PartType.EngineBig) { partType = BasePart.PartType.Engine; } else if (partType == BasePart.PartType.EngineSmall) { partType = BasePart.PartType.Engine; } return(partType); }
public override void Initialize() { if (this.RightPart && this.RightPart.GetComponent <Rope>()) { Rope.Node node = this.m_nodes[this.m_nodes.Count - 1]; node.gameObject.transform.position = this.RightPart.GetComponent <Rope>().FirstSegment.transform.position; this.CreateJoint(node.gameObject, this.RightPart.GetComponent <Rope>().FirstSegment.GetComponent <Rigidbody>()); } base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), 1); if (this.m_gridVisualizationNode) { this.m_gridVisualizationNode.SetActive(false); } }
private void Cut(int nodeIndex) { if (!this.m_ropeCut) { base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), -1); this.m_ropeCut = true; this.m_cutIndex = nodeIndex; this.CreateSecondLineRenderer(); int num = this.m_cutIndex; this.m_lineRenderer.material.mainTextureScale = new Vector2(20f * (float)(num - 1) / (float)(this.m_nodes.Count - 1), 1f); num = this.m_nodes.Count - num; this.m_lineRenderer2.material.mainTextureScale = new Vector2(20f * (float)(num - 1) / (float)(this.m_nodes.Count - 1), 1f); base.contraption.FindComponentsConnectedByRope(); } }
private void Update() { if (this.m_removeTimerStarted) { this.m_timer += Time.deltaTime; if (this.m_timer > this.m_removeTime) { this.m_removeTimerStarted = false; this.m_removePhase = true; this.m_timer = 0f; this.m_contraption.DestroyAllJoints(); this.m_contraption.ActivateParts((BasePart part) => BasePart.BaseType(part.m_partType) == BasePart.PartType.Balloon || BasePart.BaseType(part.m_partType) == BasePart.PartType.Sandbag); this.m_partsToRemove = new Queue <BasePart>(this.m_contraption.Parts); } } else if (this.m_removePhase) { if (this.m_partsToRemove.Count > 0) { this.m_timer += Time.deltaTime; if (this.m_timer > 0.05f) { this.m_timer -= 0.05f; BasePart basePart = this.m_partsToRemove.Dequeue(); if (basePart) { WPFMonoBehaviour.effectManager.CreateParticles(this.m_gameData.m_dustParticles.GetComponent <ParticleSystem>(), basePart.transform.position, false); basePart.transform.position += 1000f * Vector3.right; } } } else { UnityEngine.Object.Destroy(base.gameObject); UnityEngine.Object.Destroy(this.m_contraption.gameObject); } } }
public void Drop() { if (!this.m_dropped) { this.m_dropped = true; SpringJoint component = base.GetComponent <SpringJoint>(); base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), -1); base.gameObject.layer = LayerMask.NameToLayer("DroppedSandbag"); if (component && component.connectedBody) { component.connectedBody.AddForce(5f * Vector3.up, ForceMode.Impulse); base.rigidbody.AddForce(-4f * Vector3.up, ForceMode.Impulse); } if (component) { UnityEngine.Object.Destroy(component); } LineRenderer component2 = base.GetComponent <LineRenderer>(); if (component2) { UnityEngine.Object.Destroy(component2); } } }
public override void Initialize() { if (this.m_actualVisualizationNode && this.m_gridVisualizationNode) { this.m_gridVisualizationNode.SetActive(false); this.m_actualVisualizationNode.SetActive(true); } this.m_connectedPart = base.contraption.FindPartAt(this.m_coordX, this.m_coordY + 1); if (this.m_connectedPart && !this.m_connectedPart.IsPartOfChassis() && this.m_connectedPart.m_partType != BasePart.PartType.Pig) { this.m_connectedPart = null; } if (this.m_connectedPart) { this.m_dropped = false; base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), 1); } else { this.m_dropped = true; base.gameObject.layer = LayerMask.NameToLayer("DroppedSandbag"); } this.m_partType = BasePart.PartType.Sandbag; if (this.m_numberOfBalloons > 1) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(base.gameObject); gameObject.transform.position = base.transform.position; Sandbag component = gameObject.GetComponent <Sandbag>(); component.m_numberOfBalloons = this.m_numberOfBalloons - 1; base.contraption.AddRuntimePart(component); gameObject.transform.parent = base.contraption.transform; } if (!base.gameObject.GetComponent <SphereCollider>()) { SphereCollider sphereCollider = base.gameObject.AddComponent <SphereCollider>(); sphereCollider.radius = 0.13f; sphereCollider.center = new Vector3(0f, -0.1f, 0f); } if (!base.rigidbody) { base.rigidbody = base.gameObject.AddComponent <Rigidbody>(); } base.rigidbody.mass = this.m_mass; base.rigidbody.drag = 1f; base.rigidbody.angularDrag = 10f; base.rigidbody.constraints = (RigidbodyConstraints)56; if (this.m_connectedPart) { Vector3 position = base.transform.position; base.transform.position = this.m_connectedPart.transform.position - Vector3.up * 0.5f; SpringJoint springJoint = base.gameObject.AddComponent <SpringJoint>(); springJoint.connectedBody = this.m_connectedPart.rigidbody; this.m_connectedLocalPos = this.m_connectedPart.transform.InverseTransformPoint(base.transform.position); int numberOfBalloons = this.m_numberOfBalloons; Vector3 b; float maxDistance; if (numberOfBalloons != 1) { if (numberOfBalloons != 2) { b = new Vector3(0f, -0.35f, -0.03f); maxDistance = 0.65f; } else { b = new Vector3(0.35f, -0.3f, -0.02f); maxDistance = 0.55f; } } else { b = new Vector3(-0.15f, -0.15f, -0.01f); maxDistance = 0.5f; } springJoint.minDistance = 0f; springJoint.maxDistance = maxDistance; springJoint.anchor = Vector3.up * 0.5f; springJoint.spring = 100f; springJoint.damper = 10f; base.transform.position = position + b; LineRenderer lineRenderer = base.gameObject.AddComponent <LineRenderer>(); lineRenderer.material = this.m_stringMaterial; lineRenderer.SetVertexCount(2); lineRenderer.SetWidth(0.05f, 0.05f); lineRenderer.SetColors(Color.black, Color.black); } else { int numberOfBalloons2 = this.m_numberOfBalloons; Vector3 b2; if (numberOfBalloons2 != 1) { if (numberOfBalloons2 != 2) { b2 = new Vector3(0f, -0.35f, -0.03f); } else { b2 = new Vector3(0.35f, -0.3f, -0.02f); } } else { b2 = new Vector3(-0.15f, -0.15f, -0.01f); } base.transform.position += b2; } }
public override void Initialize() { if (this.m_actualVisualizationNode && this.m_gridVisualizationNode) { this.SetRenderersInChildred(this.m_gridVisualizationNode, false); this.SetRenderersInChildred(this.m_actualVisualizationNode, true); } int num = 1; while (num < 6 && !this.m_connectedPart) { this.m_connectedPart = base.contraption.FindPartAt(this.m_coordX, this.m_coordY - num); if (this.m_connectedPart && !this.m_connectedPart.IsPartOfChassis() && this.m_connectedPart.m_partType != BasePart.PartType.Pig && this.m_connectedPart.m_partType != BasePart.PartType.Kicker) { this.m_connectedPart = null; } num++; } this.m_partType = BasePart.PartType.Balloon; base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), 1); if (this.m_numberOfBalloons > 1) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(base.gameObject); gameObject.transform.position = base.transform.position; Balloon component = gameObject.GetComponent <Balloon>(); component.m_numberOfBalloons = this.m_numberOfBalloons - 1; base.contraption.AddRuntimePart(component); gameObject.transform.parent = base.contraption.transform; } if (!base.gameObject.GetComponent <SphereCollider>()) { SphereCollider sphereCollider = base.gameObject.AddComponent <SphereCollider>(); sphereCollider.radius = 0.5f; } if (!base.rigidbody) { base.gameObject.AddComponent <Rigidbody>(); } base.rigidbody.mass = 0.1f; base.rigidbody.drag = 2f; base.rigidbody.angularDrag = 0.5f; base.rigidbody.constraints = (RigidbodyConstraints)48; if (this.m_connectedPart) { this.m_connectedPart.EnsureRigidbody(); Vector3 position = base.transform.position; float num2 = Vector3.Distance(this.m_connectedPart.transform.position, position) - 0.5f; float num3 = 0f; Vector3 b; if (this.m_connectedPart.m_partType == BasePart.PartType.Pig) { b = Vector3.zero; num3 = 0.3f; } else { b = Vector3.up * 0.5f; } base.transform.position = this.m_connectedPart.transform.position + b; this.m_springJoint = base.gameObject.AddComponent <SpringJoint>(); this.m_springJoint.connectedBody = this.m_connectedPart.rigidbody; base.contraption.AddJointToMap(this, this.m_connectedPart, this.m_springJoint); float maxDistance = UnityEngine.Random.Range(0.8f, 1.2f) * num2 + num3; this.m_springJoint.minDistance = 0f; this.m_springJoint.maxDistance = maxDistance; this.m_springJoint.anchor = Vector3.up * -0.5f; this.m_springJoint.spring = 100f; this.m_springJoint.damper = 10f; this.m_springJoint.enablePreprocessing = false; this.m_balancer = this.m_connectedPart.gameObject.GetComponent <BalloonBalancer>(); if (!this.m_balancer) { this.m_balancer = this.m_connectedPart.gameObject.AddComponent <BalloonBalancer>(); } this.m_balancer.AddBalloon(); Transform transform = base.transform; if (this.m_actualVisualizationNode) { transform = this.m_actualVisualizationNode.transform; } this.m_rope = transform.gameObject.AddComponent <RopeVisualization>(); this.m_connectedLocalPos = this.m_connectedPart.transform.InverseTransformPoint(base.transform.position); this.m_springJoint.autoConfigureConnectedAnchor = false; this.m_springJoint.connectedAnchor = this.m_connectedLocalPos; this.m_rope.m_stringMaterial = this.m_stringMaterial; this.m_rope.m_pos1Anchor = Vector3.up * -0.5f + 1.1f * Vector3.forward; this.m_rope.m_pos2Transform = this.m_connectedPart.transform; this.m_rope.m_pos2Anchor = this.m_connectedLocalPos + 1.1f * Vector3.forward; base.transform.position = position + UnityEngine.Random.Range(-1f, 1f) * Vector3.forward + UnityEngine.Random.Range(-1f, 1f) * Vector3.right * 0.5f; } }