Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        menuLoader     = FindObjectOfType <MenuLoader>();
        spriteHandler  = FindObjectOfType <SpriteHandler>();
        rb             = GetComponent <Rigidbody2D>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        //need to check which skin the player picked on menu screen
        //create a class that manages sprites (SpriteManager), make a static class object internally (see AccountManager as example), then use this to determine what the player sprite should be upon start
        //OR just use WalletManager to manage checks for wallet balance specific to the skin token id
        spriteRenderer.sprite = playSkins[spriteHandler.GetActiveSkinIndex()];

        screenWidth = Screen.width;
    }
Beispiel #2
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Cactus"))
     {
         //create a class that manages sprites (SpriteManager), make a static class object internally (see AccountManager as example), then use this to determine what the player death sprite should be upon game over
         spriteRenderer.sprite = deathSkins[spriteHandler.GetActiveSkinIndex()];
         rb.velocity           = new Vector2(0, 0);
         FindObjectOfType <GameStatus>().SetGameOver(true);
         menuLoader.LoadGameOver();
     }
     else if (other.gameObject.CompareTag("Coin"))
     {
         FindObjectOfType <GameStatus>().AddToScore();
         Destroy(other.gameObject);
     }
 }