コード例 #1
0
ファイル: Phase3State.cs プロジェクト: mperez83/Shiba-Run
    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);
        });
    }
コード例 #2
0
ファイル: GroundPlayer.cs プロジェクト: mperez83/Shiba-Run
 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");
 }
コード例 #3
0
ファイル: TruckFootball.cs プロジェクト: mperez83/Shiba-Run
 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);
     }
 }
コード例 #4
0
 void Start()
 {
     velocity = MathEquations.CalculateLaunchVelocity(transform.position, endPos, -4f, babyApex);
 }
コード例 #5
0
 void Start()
 {
     velocity = MathEquations.CalculateLaunchVelocity(transform.position, endPos, -GameMaster.instance.gravity, 4);
 }
コード例 #6
0
ファイル: TruckFootball.cs プロジェクト: mperez83/Shiba-Run
 void Start()
 {
     rotationAmount = Random.Range(400f, 2000f);
     velocity       = MathEquations.CalculateLaunchVelocity(transform.position, landingSpots[0], -GameMaster.instance.gravity, flightHeights[0]);
 }
コード例 #7
0
ファイル: SimpleObject.cs プロジェクト: mperez83/Shiba-Run
 public void LaunchObject(Vector2 _endPos, float _maxHeight)
 {
     velocity = MathEquations.CalculateLaunchVelocity(transform.position, _endPos, -gravity, _maxHeight);
 }