Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     text.text        = tmm.GetTilemap().GetPressedRedButtonCount() + "/" + tmm.GetTilemap().buttonsToWin;
     catTimer.enabled = enableTimer.isOn;
     timerOn          = enableTimer.isOn;
     timerText.gameObject.SetActive(enableTimer.isOn);
 }
Esempio n. 2
0
    void Update()
    {
        if (!winCoroutineStarted && tilemapRenderer.GetTilemap().isWon())
        {
            StartCoroutine(WinInSeconds(3f));
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            RestartLevel();
        }

        if (Input.GetKeyDown(KeyCode.N))
        {
            StartCoroutine(WinInSeconds(0f));
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            StartCoroutine(WinInSeconds(0f, false));
        }
    }
 private void HandleInput()
 {
     movementForce = Input.GetAxisRaw("Horizontal") * movementSpeedMultipler;
     if (Input.GetButtonDown("Jump"))
     {
         jump = true;
     }
     if (Input.GetButton("Fire1") && canShoot)
     {
         Shoot();
     }
     if (!canShoot && !shootingBlockade)
     {
         timeLeft -= Time.deltaTime;
         reloadProgress.fillAmount = timeLeft / weapon.timeBetweenShoots;
         if (timeLeft <= 0)
         {
             canShoot = true;
             timeLeft = weapon.timeBetweenShoots;
             reloadProgress.fillAmount = 0;
         }
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Cursor.visible = !Cursor.visible;
     }
     if (Input.GetButtonDown("Fire2") && Coins > 0 && !isDashing)
     {
         Dash();
         //if (tileManager.GetTilemap(0).SetTile(lookPos, TileType.White))
         //{
         //    Coins--;
         //    coinsText.text = Coins.ToString();
         //}
     }
     if (Input.GetKeyDown(KeyCode.F))
     {
         if (tileManager.GetTilemap(0).RemoveTile(lookPos))
         {
             effectHandler.InstantiateCoin(new Vector3(lookPos.x, lookPos.y, 0) + transform.position);
         }
     }
 }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     if (!active)
     {
         anim.SetBool("Walking", false);
         return;
     }
     anim.SetBool("Walking", Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f);
     transform.Translate(Vector2.right * Input.GetAxis("Horizontal") * Time.deltaTime * speed);
     pawHitCooldownTimer -= Time.deltaTime;
     if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f)
     {
         transform.localScale = new Vector3((Input.GetAxis("Horizontal") < 0) ? 1 : -1, 1f, 1f);
     }
     if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.W))
     {
         if (CanJump())
         {
             Jump();
         }
     }
     if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.X) || Input.GetKey(KeyCode.F))
     {
         if (pawHitCooldownTimer <= 0f)
         {
             pawHitCooldownTimer = pawHitCooldown;
             foreach (Collider2D other in Physics2D.OverlapCircleAll(paw.transform.position, pawSize))
             {
                 if (other.transform.tag == "Movable")
                 {
                     TilemapManager tmm    = other.transform.parent.GetComponent <TilemapManager>();
                     Vector2Int     boxPos = tmm.GetTilePosFromTransformPos(other.transform.position);
                     if (tmm.GetTilemap().PushBox(boxPos.x, boxPos.y, other.transform.position.x > transform.position.x))
                     {
                         GetComponent <AudioSource> ().clip = moveSound;
                         GetComponent <AudioSource> ().Play();
                     }
                     break;
                 }
             }
         }
     }
 }