// Update is called once per frame void Update() { horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); Vector2 move = new Vector2(horizontal, vertical); if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f)) { lookDirection.Set(move.x, move.y); lookDirection.Normalize(); } animator.SetFloat("Look X", lookDirection.x); animator.SetFloat("Look Y", lookDirection.y); animator.SetFloat("Speed", move.magnitude); if (Input.GetKeyDown(KeyCode.C)) { if (hasUnlimitedPower) { ThrowFireball(); } if (!hasUnlimitedPower && ammoNumber > 0) { Launch(); } } if (Input.GetKeyDown(KeyCode.F)) { RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f, LayerMask.GetMask("NPC")); if (hit.collider != null) { NPC jambi = hit.collider.GetComponent <NPC>(); Crow crow = hit.collider.GetComponent <Crow>(); ClosedChest chest = hit.collider.GetComponent <ClosedChest>(); WizardNPC wizard = hit.collider.GetComponent <WizardNPC>(); Sheep sheep = hit.collider.GetComponent <Sheep>(); if (jambi != null) { jambi.DisplayDialog(itemsClefs["cheese"]); } if (crow != null) { crow.DeliverItem(); } if (chest != null) { chest.OpenChest(); } if (wizard != null) { wizard.DisplayDialog(isWorthy()); } if (sheep != null) { sheep.DeliverItem(itemsClefs["key"]); } } } if (Input.GetKeyDown(KeyCode.Escape)) { menuPause.SetActive(true); } if (hasFinishedTheGame) { float time = 10; time -= Time.deltaTime; if (time <= 0) { menuPause.SetActive(true); } } }