コード例 #1
0
ファイル: BombScript.cs プロジェクト: alextavella/BomberGuy
 private void UpdateBombs(float step)
 {
     for (int i = 0; i < bombs.Count; i++)
     {
         BombItemScript bomb = bombs [i];
         if (step == i)
         {
             bomb.Show();
         }
         else
         {
             bomb.Hide();
         }
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        // Move
        float move_x = Input.GetAxisRaw("Horizontal") * speed * Time.deltaTime;

        transform.Translate(move_x, 0.0f, 0.0f);

        // Animator running
        animator.SetFloat("pRunning", Math.Abs(move_x));

        // Limit
        float position_x = transform.position.x;

        position_x         = Math.Min(position_x, maxRight);
        position_x         = Math.Max(position_x, maxLeft);
        transform.position = new Vector2(position_x, transform.position.y);

        // Verify collision with 'piso'
        isColliderPiso = Physics2D.Linecast(
            transform.position,
            chaoVerificador.position,
            1 << LayerMask.NameToLayer(LayerUtils.BLOCK)
            );

        // Orientation view
        if (move_x > 0)
        {
            normalBombSpriteRenderer.flipX = false;
            spriteRenderer.flipX           = false;
        }
        else if (move_x < 0)
        {
            normalBombSpriteRenderer.flipX = true;
            spriteRenderer.flipX           = true;
        }

        // Jump
        animator.SetBool("pJumping", !isColliderPiso);

        if (Input.GetButtonDown(ButtonUtils.JUMP) && isColliderPiso)
        {
            rb.velocity = new Vector2(0.0f, weight);
        }

        // Fire
        animator.SetBool("pHold", Input.GetButton(ButtonUtils.HOLD));

        // Dead
//		if (life <= 0) {
//			Destroy (gameObject);
//		}

        // Dead
        if (transform.position.y <= -6)
        {
            Destroy(gameObject);
            Application.LoadLevel(SceneUtils.FINISH);
        }

        // Hold bomb
        if (Input.GetButtonDown(ButtonUtils.HOLD) && isColliderBomb)
        {
            Destroy(bombCollision);
            normalBombScript.Show();
        }
    }