Exemplo n.º 1
0
    void Update()
    {
        horizontal      = Input.GetAxis("Horizontal");
        player.velocity = new Vector2(horizontal * playerSpeed, player.velocity.y);

        if (Input.GetKeyDown(KeyCode.UpArrow) && grounded)
        {
            player.AddForce(new Vector2(0f, jumpPower), ForceMode2D.Impulse);
            AudioSource.PlayClipAtPoint(jumpSoundEffect, transform.position);
        }

        if (horizontal < 0)
        {
            transform.right = new Vector3(-1f, 0f, 0f);
        }
        else if (horizontal > 0)
        {
            transform.right = new Vector3(1f, 0f, 0f);
        }

        if (Input.GetKeyDown(KeyCode.Space) && !slimeballSpawnLocation.GetComponent <SpawnColliderScript>().GetIsCollision())
        {
            if (slimeballs.Count < maxProjectiles)
            {
                SlimeballProjectile newSlimeball = Instantiate <SlimeballProjectile>(slimeballPrefab, slimeballSpawnLocation.position, player.transform.rotation);
                AudioSource.PlayClipAtPoint(shootSoundEffect, transform.position);
                newSlimeball.transform.position = slimeballSpawnLocation.position;
                newSlimeball.player             = this;

                slimeballs.Add(newSlimeball);
            }
        }

        if (coins == 100)
        {
            lives += 1;
            coins  = 0;
        }

        Animation.SetBool("Running", Mathf.Abs(player.velocity.x) > runThreshold);
    }
Exemplo n.º 2
0
 public void ProjectileDestroyed(SlimeballProjectile destroyedProjectile)
 {
     slimeballs.Remove(destroyedProjectile);
 }