//Activates the right skiers, sets materials, places skiers, and passes tether references to the plane private void SetupScene() { Tether[] tethers = new Tether[4]; //Array of tethers to pass onto the plane int place = 0; //Which place the skier will be spawned to, such as 0, 1, or 2, based on how many players for (int i = 0; i < m_playerCount; ++i) //For all current players, { if (i == (int)m_eCurrentPlaneState) //If this player is in the plane, { m_skiers[i].gameObject.SetActive(false); //Set their skier to inactive m_skiers[i].SetAlive(false); //Make sure they aren't considered alive //Set the material of the plane planeBody.GetComponent <Renderer>().material.SetTexture("Texture2D_C6055840", m_planeTextures[i]); } else //If this player isn't in the plane, { m_skiers[i].gameObject.SetActive(true); //Activate their skier m_skiers[i].SetAlive(true); //Set them to alive tethers[i] = m_skiers[i].tether; //Adds the tether to the references array //Put the skier in the right position m_skiers[i].transform.position = m_skierSpawnPos[m_playerCount - 2, place]; ++place; //Increment the place } } plane.SetTetherReferences(tethers); //Pass the tethers to the plane }
private static void appendEquipment(Animal animal, string[] choice) { IEquipment equipment = null; if ("Bridle".Equals(choice[2])) { equipment = new Bridle(); } else if ("Halter".Equals(choice[2])) { equipment = new Halter(); } else if ("Saddle".Equals(choice[2])) { equipment = new Saddle(); } else if ("Saddle Blanket".Equals(choice[2] + " " + choice[3])) { equipment = new SaddleBlanket(); } else if ("Tether".Equals(choice[2])) { equipment = new Tether(); } animal.Equipments.Add(equipment); }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "MazeWall") { Tether tether = (Tether)GetComponent("Tether"); Debug.Log("Collision"); Color wallColor = collision.gameObject.GetComponent <Renderer>().material.color; Color playerColor = GetComponent <Renderer>().material.color + tether.GetTetherTo().GetComponent <Renderer>().material.color; Debug.Log(wallColor); playerColor = ColorClamp(playerColor); Debug.Log(GetComponent <Renderer>().material.color); if (wallColor == playerColor) { Destroy(collision.gameObject); } } if (collision.gameObject.tag == "WinDoor") { Debug.Log("Win"); WinCondition winCondition = GameObject.FindObjectOfType(typeof(WinCondition)) as WinCondition; winCondition.Win(); } }
void Awake() { tether = GetComponent <Tether>(); Debug.Assert(tether != null, "Skier missing tether component"); m_coinParticles = coinCollectParticle.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in m_coinParticles) { p.Stop(); //Make sure the particle doesn't play immediately, has to be in awake } m_topScoreParticle = topScoreParticle.GetComponentInChildren <ParticleSystem>(); m_topScoreParticle.Stop(); bonkParticle = Instantiate(bonkParticle, transform); m_bonkParticles = bonkParticle.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in m_bonkParticles) { p.Stop(); //Make sure the particle doesn't play immediately, has to be in awake } obstacleParticle = Instantiate(obstacleParticle, transform); m_obstacleParticles = obstacleParticle.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in m_obstacleParticles) { p.Stop(); //Make sure the particle doesn't play immediately, has to be in awake } m_sequence = new XboxButton[6] { (XboxButton)1, (XboxButton)2, (XboxButton)3, (XboxButton)3, (XboxButton)2, 0 }; }
private void Start() { _animator = GetComponent <Animator>(); _rb2d = GetComponent <Rigidbody2D>(); _rb2d.drag = 1; _groundTrigger = GetComponentInChildren <PlayerGroundDetector>(); _tether = GetComponent <Tether>(); }
void Start() // KEEP THIS AS START OR I WILL PERSONALLY SMITE YOU. WE SPENT TOO LONG ON THIS. { mine.SetActive(false); // Disables the mine on startup. m_planeHatch = GetComponent <Transform>(); m_controller = planeRB.GetComponent <PlaneController>().controller; m_planeController = planeRB.GetComponent <PlaneController>(); planeSpeed = m_planeController.forwardSpeed; m_mineTether = mine.GetComponent <Tether>(); }
private void OnTriggerEnter(Collider other) { if (!m_invincible) //If the skier is not currently invincible, { if (other.CompareTag("Coin")) //If the other object is a coin, { m_score += coinScore; //Add a coin's worth of points to the score foreach (ParticleSystem p in m_coinParticles) { p.Play(); } } if (other.CompareTag("Rock")) //If the other object is a rock, { HurtSkier(); //Hurt the skier AudioManager.Play("PLayerHitObstacle"); // plays sound when hit obstacle } } if (other.CompareTag("Skier") && !bonkResolved) //If the other object is a skier and this collision hasn't been resolved yet, { Tether otherTether = other.GetComponent <Tether>(); //Get the other skier's tether if (tether.VelocityMagnitude() >= otherTether.VelocityMagnitude()) //If this skier is moving faster than the other skier, { float velocityForce = (tether.VelocityXMagnitude() / m_maxXVelocity) * bonkVelocityForce; //Proportion the force based on how close to max velocity this skier is Vector3 totalBonkForce = (bonkForce + velocityForce) * tether.Direction(); //Add the flat force and velocity-dependent force, then point them in the direction of movement otherTether.ForceOverTime(totalBonkForce, bonkForceDuration); //Apply the final force to the other skier tether.ReduceVelocity(2); //Halve the velocity of this skier other.GetComponent <SkierController>().bonkResolved = true; //For this frame, set the collision as resolved AudioManager.Play("Bonk3"); // plays bonk sound effect other.GetComponent <SkierController>().PlayBonkParticle(tether.Direction()); //Play the bonk particle on the other skier in the direction they are pushed } } if (other.CompareTag("Rock")) //Regardless of if invincible or not, if colliding with an obstacle, { float pushDirection = transform.position.x - other.transform.position.x; //Calculate if the skier should be pushed left or right if (pushDirection > 0) //If positive, { tether.ForceOverTime(new Vector3(obstacleForce, 0, 0), obstacleForceDuration); //Push right } else //If negative, { tether.ForceOverTime(new Vector3(-obstacleForce, 0, 0), obstacleForceDuration); //Push left } } if (other.CompareTag("River") && m_isAlive) //If the skier somehow touches the river, { //Reset their position and velocity tether.ResetVelocity(); transform.position = new Vector3(transform.position.x, 0.0f, transform.position.z); } }
public TetherNode(Tether tetherObject) { Debug.Log("New node"); network = GameObject.FindGameObjectWithTag("Planet").GetComponent <TetherNetwork>(); this.tetherObject = tetherObject; if (tetherObject != null) { tetherPos = tetherObject.gameObject.transform.position; } }
private LineRenderer lineRenderer = null; //Reference to the line renderer void Awake() { m_tether = GetComponentInParent <Tether>(); Debug.Assert(m_tether != null, "RopeLine failed accessing tether component of object parent"); lineRenderer = gameObject.GetComponent <LineRenderer>(); Debug.Assert(lineRenderer != null, "RopeLine missing LineRenderer component"); lineRenderer.useWorldSpace = true; lineRenderer.positionCount = m_numberOfPoints; //Set the number of lines to draw }
void Start() { material = GetComponent <Renderer>().material; proxyTether = transform.Find("ProxyTether").GetComponent <Tether>(); markTether = transform.Find("MarkTether").GetComponent <Tether>(); leap = GetComponent <InteractionBehaviour>(); leap.OnGraspBegin += OnGraspBegin; leap.OnGraspEnd += OnGraspEnd; leap.OnGraspStay += OnGraspStay; }
void Awake() { m_rb = gameObject.GetComponent <Rigidbody>(); GameObject hatch = GameObject.FindWithTag("PlaneHatch"); // Will search for the hatch with the tag. if (hatch != null) { m_tmAbility = hatch.GetComponent <TetheredMineAbility>(); // Will get the script from the hatch. } m_tether = GetComponent <Tether>(); Debug.Assert(explosionPrefab != null, "The explosion prefab hasn't been added to the mine script"); }
public Tether GetTether() { Tether tether = new Tether(); if (PsaFile.DataSection[MiscSectionLocation + 17] >= 8096 && PsaFile.DataSection[MiscSectionLocation + 17] < PsaFile.DataSectionSize) { tether.Offset = PsaFile.DataSection[MiscSectionLocation + 17]; int tetherLocation = PsaFile.DataSection[MiscSectionLocation + 17] / 4; tether.HangFrameCount = PsaFile.DataSection[tetherLocation]; tether.Unknown = PsaFile.DataSection[tetherLocation + 1]; } Console.WriteLine(tether); return(tether); }
public override void OnSpawn() { //Node.cloneNode(parent.Game1.ui.sidebar.ActiveDefaultNode, sword); //parent.body.texture = textures.orientedcircle; shovelNode.dataStore["shovelnodeparent"] = parent; shovelNode.body.pos = parent.body.pos; shovelNode.AffectExclusionCheck += (node) => node == parent; room.Groups.Items.IncludeEntity(shovelNode); Debug.WriteLine(room.Groups.Items.entities.Count); shovelNode.OnSpawn(); shovelNode.body.AddExclusionCheck(parent.body); Spring spring = new Spring(); spring.restdist = 0; spring.springMode = Spring.mode.PullOnly; spring.active = true; spring.multiplier = 1000; Tether tether = new Tether(); tether.mindist = 0; tether.maxdist = 20; tether.active = true; shovelLink = new Link(shovelNode, new HashSet <Node>(), spring); shovelLink.AddLinkComponent(tether); //to keep the shovel in reach for physics based control Tether rangeTether = new Tether(); rangeTether.mindist = 0; rangeTether.maxdist = (int)shovelReach; rangeTether.active = true; rangeLink = new Link(parent, shovelNode, rangeTether); if (modeShovelPosition == ModeShovelPosition.PhysicsBased) { rangeLink.active = true; } //exclusionDel = delegate(Collider c1, Collider c2) //{ // return shovelLink.active && shovelLink.targets.Contains(c2.parent); //}; //shovelNode.body.ExclusionCheck += exclusionDel; //parent.body.ExclusionCheck += exclusionDel; }
void AttemptConnection() { TetherNode closest = FindNearestNodeWithOxygen(!hasOxygen); if (closest != null && !supplies.Contains(closest)) { if (supplier != null) { supplier.supplies.Remove(this); } supplier = closest; supplierObject = closest.tetherObject; closest.supplies.Add(this); tetherObject.MakeConnection(closest.tetherObject, network.connectionPrefab); } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("River")) // Will be called if collision with the river occurs. { Vector3 explosionPos = transform.position; // explosion will occur at the impact site. explosionPos.y = 0; //Make sure that there is no y component Collider[] colliders = Physics.OverlapSphere(explosionPos, m_bbAbility.radius); // List of colliders within the radius. AudioManager.Play("BeachBomb POP"); foreach (Collider hit in colliders) //For all the objects in the radius, { if (hit.CompareTag("Skier")) //If this object is a skier, { Tether tether = hit.GetComponent <Tether>(); //Get their tether Vector3 distanceToHit = hit.transform.position - explosionPos; //Get the difference in position between the skier and the explosion point distanceToHit.y = 0; //Make sure there is no y compenent Vector3 extraForwardsForce = new Vector3(0, 0, m_bbAbility.extraForwardsPower); //Make an extra force up the river to account for always moving forwards Vector3 totalForce = m_bbAbility.power * distanceToHit.normalized + extraForwardsForce; //Total up the forces tether.ForceOverTime(totalForce, m_bbAbility.forceDuration); //Add a force on the skier, pushing away from the explosion point } else if (hit.CompareTag("Mine")) { Tether tether = hit.GetComponent <Tether>(); //Get their tether Vector3 distanceToHit = hit.transform.position - explosionPos; //Get the difference in position between the skier and the explosion point distanceToHit.y = 0; //Make sure there is no y compenent Vector3 extraForwardsForce = new Vector3(0, 0, m_bbAbility.extraForwardsPower); //Make an extra force up the river to account for always moving forwards Vector3 totalForce = m_bbAbility.minePower * distanceToHit.normalized + extraForwardsForce; //Total up the forces tether.ForceOverTime(totalForce, m_bbAbility.forceDuration); //Add a force on the mine, pushing away from the explosion point } } gameObject.SetActive(false); // Deactivates the beachball. m_rb.velocity = Vector3.zero; // Resets velocity. m_rb.angularVelocity = Vector3.zero; // Resets angular velocity. m_rb.transform.rotation = Quaternion.Euler(Vector3.zero); // Resets rotation. m_bbAbility.ToggleIsShooting(false); // Player isn't shooting anymore. m_bbAbility.ToggleMeshEnable(false); // Disabled target's mesh. explosionPrefab.transform.position = explosionPos; //Make the explosion happen at the right spot Instantiate(explosionPrefab); //Create the explosion ControllerVibrate.VibrateAll(0.2f, 0.5f); //Vibrate all controllers a meduim amount GameFreezer.Freeze(freezeAmount, freezeFrames); //Slow time very briefly for impact } }
public void SetTetherInstance(Tether instance) { m_tetherInstance = instance; }
void Start() { detectPlayer = GetComponent<DetectPlayerWithFollowBuffer>(); tether = GetComponent<Tether>(); movement = GetComponent<Movement>(); }
void Start() { detectPlayer = GetComponent <DetectPlayerWithFollowBuffer>(); tether = GetComponent <Tether>(); movement = GetComponent <Movement>(); }
private void Awake() { _rb = GetComponent <Rigidbody2D>(); _tether = GetComponent <Tether>(); }
public override void OnSpawn() { shootNode.dataStore["linknodeparent"] = parent; shootNode.body.pos = parent.body.pos; shootNode.addComponent <ColorChanger>(true); shootNode.AffectExclusionCheck += (node) => node == parent; room.Groups.Items.IncludeEntity(shootNode); shootNode.OnSpawn(); shootNode.body.AddExclusionCheck(parent.body); shootNode.active = false; shootNode.movement.maxVelocity.value = 50f; spring = new Spring(); spring.restdist = 0; spring.springMode = Spring.mode.PushOnly; spring.multiplier = 400; //Tether tether = new Tether(); //tether.mindist = 0; //tether.maxdist = 20; //tether.active = true; //shootNodeLink = new Link(parent, shootNode, spring); //shootNodeLink.IsEntangled = true; ////shovelLink.components.Add(tether); grav = new Gravity(); grav.mode = Gravity.Mode.ConstantForce; //grav.Repulsive = true; grav.multiplier = 100; shootLink = new Link(parent, shootNode, grav); shootLink.AddLinkComponent(spring, true); // Gravity attachGrav = new Gravity(); attachGrav.multiplier = 100; attachGrav.mode = Gravity.Mode.ConstantForce; Tether aTether = new Tether(); aTether.maxdist = 100; aTether.mindist = 0; aTether.activated = true; Spring aSpring = new Spring(); aSpring.springMode = Spring.mode.PushAndPull; aSpring.multiplier = 100; aSpring.restdist = 0; attachedNodesQueue = new Queue <Node>(); //attachLink = new Link(parent, new HashSet<Node>(), attachGrav); //targetsToSelf attachLink = new Link(new HashSet <Node>(), new HashSet <Node>(), aTether); //targetsChained attachLink.FormationType = formationtype.Chain; //attachLink.AddLinkComponent(aTether, true); //attachLink.AddLinkComponent(attachGrav, true); shootNode.body.OnCollisionEnter += (n, other) => { if (other == parent) { return; } if (linkMode == LinkMode.TargetsToSelf) { if (!attachLink.targets.Contains(other)) { attachLink.targets.Add(other); attachedNodesQueue.Enqueue(other); attachLink.active = true; } } else if (linkMode == LinkMode.TargetsToTargets) { if (!attachLink.sources.Contains(other)) { attachLink.sources.Add(other); attachLink.targets.Add(other); attachedNodesQueue.Enqueue(other); attachLink.active = true; } } else if (linkMode == LinkMode.TargetsChained) { if (!attachLink.sources.Contains(other)) { attachedNodesQueue.Enqueue(other); attachLink.formation.AddChainNode(other); attachLink.active = true; } } }; parent.body.ExclusionCheck += (c1, c2) => attachLink.targets.Contains(c2.parent); }
public void Reload() { loaded = true; tetherObject = Object.Instantiate(network.tetherPrefab, tetherPos, Quaternion.identity).GetComponent <Tether>(); tetherObject.tetherNode = this; }