public override void begin() { if (_context.currentlyResetting) { _context.currentlyResetting = false; _context.ResetGround(); _context.groundScenery.active = false; _context.groundScenery.streetSegments[(_context.groundScenery.numOfSegments / 2) - 1].GetComponent <SpriteRenderer>().sprite = _context.groundScenery.houseSpriteUnbroken; } _context.music.time = GameMaster.instance.phase3Start; _context.groundPlayer = Object.Instantiate(_context.groundPlayerPrefab, new Vector2(-5.0f, 1.5f), Quaternion.identity); _context.groundPlayer.SetVelocity(MathEquations.CalculateLaunchVelocity(_context.groundPlayer.transform.position, Vector2.zero, _context.groundPlayer.gravity, 1f)); _context.groundPlayer.SetMovementType(GroundPlayer.MovementType.Intro); _context.groundScenery.active = true; _context.groundScenery.streetSegments[(_context.groundScenery.numOfSegments / 2) - 1].GetComponent <SpriteRenderer>().sprite = _context.groundScenery.houseSpriteBroken; for (int i = 0; i < 10; i++) { SimpleObject temp = Object.Instantiate(_context.housePlankPrefab); temp.transform.position = new Vector2(-5f.AddRandVal(-0.5f, 0.5f), 1f.AddRandVal(-1, 1)); temp.GetComponent <SpriteRenderer>().sprite = _context.debrisSprites[Random.Range(0, 4)]; temp.GetComponent <SimpleObject>().velocity += new Vector2(Random.Range(0f, 6f), Random.Range(0f, 10f)); if (Random.Range(0, 2) == 1) { temp.GetComponent <SpriteRenderer>().sortingLayerName = "In front of player"; } } LeanTween.delayedCall(_context.gameObject, 2, () => { Object.Instantiate(_context.truckPrefab); }); }
public void SetCliffJump() { gravity = -4f; SetVelocity(new Vector2(0f, MathEquations.CalculateLaunchVelocity(transform.position, Vector2.zero, gravity, GameMaster.instance.screenTopEdge).y - 1)); movementType = MovementType.HangGlideTransition; shadow.GetComponent <SpriteRenderer>().enabled = false; anim.Play("Shiba Double Jump"); }
void Update() { velocity.y -= GameMaster.instance.gravity * Time.deltaTime; transform.Translate(velocity * Time.deltaTime, Space.World); transform.Rotate(Vector3.forward * rotationAmount * Time.deltaTime); if (transform.position.y <= 0 && currentFlight < landingSpots.Length) { currentFlight++; transform.position = new Vector3(transform.position.x, 0, transform.position.z); velocity = MathEquations.CalculateLaunchVelocity(transform.position, landingSpots[currentFlight], -GameMaster.instance.gravity, flightHeights[currentFlight]); rotationAmount = Random.Range(400f, 2000f); if (velocity.x > 0) { rotationAmount = -rotationAmount; } } if (transform.position.x < GameMaster.instance.screenLeftEdge) { Destroy(gameObject); } }
void Start() { velocity = MathEquations.CalculateLaunchVelocity(transform.position, endPos, -4f, babyApex); }
void Start() { velocity = MathEquations.CalculateLaunchVelocity(transform.position, endPos, -GameMaster.instance.gravity, 4); }
void Start() { rotationAmount = Random.Range(400f, 2000f); velocity = MathEquations.CalculateLaunchVelocity(transform.position, landingSpots[0], -GameMaster.instance.gravity, flightHeights[0]); }
public void LaunchObject(Vector2 _endPos, float _maxHeight) { velocity = MathEquations.CalculateLaunchVelocity(transform.position, _endPos, -gravity, _maxHeight); }