void Update() { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePosition = Iso.MapToIso(mousePos); mouseTile = Iso.Snap(mousePosition); }
void DrawDebugPath() { Vector3 targetPosition; if (MouseSelection.instance.HotEntity != null) { targetPosition = Iso.MapToIso(MouseSelection.instance.HotEntity.transform.position); } else { targetPosition = IsoInput.mousePosition; } var path = Pathing.BuildPath(iso.pos, targetPosition, size: character.size, self: iso.gameObject); Pathing.DebugDrawPath(iso.pos, path); }
void ControlCharacter() { if (player == null) { return; } DrawDebugPath(); if (player.HandsItem != null) { if (Input.GetMouseButtonDown(0)) { Pickup.Create(player.transform.position, player.HandsItem); FlushInput(); player.HandsItem = null; } return; } usingSkills = false; for (int i = 0; i < hotSkills.Count; ++i) { SkillInfo skill = hotSkills[i]; KeyCode key = hotSkillsBindings[i]; if (skill == null || !Input.GetKey(key)) { continue; } usingSkills = true; if (MouseSelection.instance.HotEntity != null) { var targetCharacter = MouseSelection.instance.HotEntity.GetComponent <Character>(); if (targetCharacter != null) { player.character.UseSkill(skill, targetCharacter); } else { player.character.UseSkill(skill, Iso.MapToIso(MouseSelection.instance.HotEntity.transform.position)); } } else { player.character.UseSkill(skill, IsoInput.mousePosition); } } if (!usingSkills) { if (Input.GetMouseButton(1) || (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButton(0))) { player.character.UseSkill(rightSkill, IsoInput.mousePosition); } else if (Input.GetMouseButton(0)) { if (MouseSelection.instance.HotEntity != null) { var targetCharacter = MouseSelection.instance.HotEntity.GetComponent <Character>(); if (targetCharacter != null) { if (targetCharacter.monStat != null && targetCharacter.monStat.npc) { // todo interact with npc } else { player.character.UseSkill(leftSkill, targetCharacter); } } else { player.character.Use(MouseSelection.instance.HotEntity); } } else { player.character.GoTo(IsoInput.mousePosition); } } } player.character.run = run; }
void ControlCharacter() { if (character == null) { return; } DrawDebugPath(); if (_mouseItem != null) { if (Input.GetMouseButtonDown(0)) { Pickup.Create(character.transform.position, _mouseItem); FlushInput(); mouseItem = null; } return; } usingSkills = false; for (int i = 0; i < hotSkills.Count; ++i) { SkillInfo skill = hotSkills[i]; KeyCode key = hotSkillsBindings[i]; if (skill == null || !Input.GetKey(key)) { continue; } usingSkills = true; if (MouseSelection.current != null) { var targetCharacter = MouseSelection.current.GetComponent <Character>(); if (targetCharacter != null) { character.UseSkill(skill, targetCharacter); } else { character.UseSkill(skill, Iso.MapToIso(MouseSelection.current.transform.position)); } } else { character.UseSkill(skill, IsoInput.mousePosition); } } // move to PlayerController members once Datasheets loading done not in static section SkillInfo leftSkill = SkillInfo.Attack; SkillInfo rightSkill = SkillInfo.Attack; if (!usingSkills) { if (Input.GetMouseButton(1) || (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButton(0))) { character.UseSkill(rightSkill, IsoInput.mousePosition); } else if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject()) { if (MouseSelection.current != null) { var targetCharacter = MouseSelection.current.GetComponent <Character>(); if (targetCharacter != null) { if (targetCharacter.monStat != null && targetCharacter.monStat.npc) { // todo interact with npc } else { character.UseSkill(leftSkill, targetCharacter); } } else { character.Use(MouseSelection.current); } } else { character.GoTo(IsoInput.mousePosition); } } else { character.LookAt(IsoInput.mousePosition); } } character.run = run; }