// Update is called once per frame void Update() { if (game_over_canvas != null && game_over_canvas.activeSelf) { return; } //Resource/health regen if (curr_health < variables_stats[(int)StatId.MaxHealth].Buffed_value) { curr_health += variables_stats[(int)StatId.HealthRegen].Buffed_value * Time.deltaTime; if (curr_health > variables_stats[(int)StatId.MaxHealth].Buffed_value) { curr_health = variables_stats[(int)StatId.MaxHealth].Buffed_value; } } if (curr_resource < variables_stats[(int)StatId.MaxResource].Buffed_value) { curr_resource += variables_stats[(int)StatId.ResourceRegen].Buffed_value * Time.deltaTime; if (curr_resource > variables_stats[(int)StatId.MaxResource].Buffed_value) { curr_resource = variables_stats[(int)StatId.MaxResource].Buffed_value; } } if (Input.GetKeyUp(KeyCode.Escape)) { if (skill_controller.GetSkillSelectionUIStatus()) { skill_controller.ForceSkillSelectioUIStatus(false); return; } if (inventory_canvas.activeSelf) { inventory_canvas.SetActive(false); return; } if (character_stats_canvas.activeSelf) { character_stats_canvas.SetActive(false); return; } if (main_menu_canvas != null) { main_menu_canvas.SetActive(!main_menu_canvas.activeSelf); } } if (main_menu_canvas.activeSelf) { return; } if (Input.GetKeyUp(KeyCode.I)) { inventory_canvas.SetActive(!inventory_canvas.activeSelf); } if (Input.GetKeyUp(KeyCode.C)) { character_stats_canvas.SetActive(!character_stats_canvas.activeSelf); } //Don't read inputs if UI active if (inventory_canvas.activeSelf || character_stats_canvas.activeSelf || skill_controller.skill_selection_UI.activeSelf) { return; } //Read game inputs if (Input.GetMouseButton(0) && !Input.GetKey(KeyCode.LeftShift)) { Debug.Log("Processing Left Click"); int mask = LayerMask.GetMask("Floor", "Enemy", "Item"); RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, mask); if (ray_hit.hitted) { if (ray_hit.layer_hit == LayerMask.NameToLayer("Floor")) { Debug.Log("moving with the floor"); move_controller.MoveToPosition(ray_hit.hit_point); } else if (ray_hit.layer_hit == LayerMask.NameToLayer("Enemy")) { Debug.Log("Enemy Attacked"); if (!skill_controller.UseBaseAttack(ray_hit)) { move_controller.MoveToEnemy(ray_hit.go_hit.transform); } } else if (ray_hit.layer_hit == LayerMask.NameToLayer("Item")) { Debug.Log("picking the item"); ray_hit.go_hit.GetComponent <ItemWorld>().to_pick = true; move_controller.MoveToPosition(ray_hit.hit_point); } } } if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftShift)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.LMB, ray_hit); } } if (Input.GetMouseButtonDown(1)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.RMC, ray_hit); } } if (Input.GetKeyUp(KeyCode.Alpha1)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.NUM_1, ray_hit); } } if (Input.GetKeyUp(KeyCode.Alpha2)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.NUM_2, ray_hit); } } if (Input.GetKeyUp(KeyCode.Alpha3)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.NUM_3, ray_hit); } } if (Input.GetKeyUp(KeyCode.Alpha4)) { RayHitInfo ray_hit = RayCastHandle(Input.mousePosition, LayerMask.GetMask("Floor", "Enemy")); if (ray_hit.hitted) { skill_controller.CastSkill(SkillButton.NUM_4, ray_hit); } } if (Input.GetKeyDown(KeyCode.F1)) { invincible = !invincible; invincible_display.SetActive(invincible); } if (Input.GetKeyDown(KeyCode.F2)) { no_mana_cost = !no_mana_cost; no_mana_display.SetActive(no_mana_cost); } }