private void HandleClick(Vector3 position) { Sound.PlayMapCLick(); //TODO Move this to a routine and insert a pause here and a shout from the Chief Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000, HitMask)) { if (hit.collider && hit.collider.GetComponent <Lootable>()) { var loot = hit.collider.GetComponent <Lootable>(); if (loot.InArea && loot.InArea.Visible()) { Team.Leader.Search(loot); } } else if (hit.collider && hit.collider.GetComponent <Character>()) //TODO:check visibility else just move there { var c = hit.collider.GetComponent <Character>(); if (c) { //Debug.Log("Clicked charaacter " + c.name); if (c.tag == "Enemy" && c.Alive()) { if (c.InArea.Visible()) { Team.Attack(c); } else { //ClickedArea(c.InArea); } } else if (c as Goblin) { CharacterView.ShowCharacter(c as Goblin); ChangeZoomLevel(ZoomLevel.GoblinView); } else { //ClickedArea(c.InArea); } } } //TODO use parent class for these else if (hit.collider && hit.collider.GetComponent <GoblinWarrens>()) { var v = hit.collider.GetComponent <GoblinWarrens>(); if (v.InArea.Visible()) { VillageView.OpenVillageView(v, Team); } else { //ClickedArea(v.InArea); } } //TODO use parent class for these else if (hit.collider && hit.collider.GetComponent <HumanSettlement>()) { var v = hit.collider.GetComponent <HumanSettlement>(); if (v.InArea.Visible()) { PlayerChoice.CreateDoChoice(() => v.AttackSettlement(), "Do you want to attack the Human " + v.Name); } //else // ClickedArea(v.InArea); } //TODO: handle the point of interest click generally. Replace BigstoneView and CaveView with a Poi view? else if (hit.collider && hit.collider.GetComponent <Monument>()) { var monument = hit.collider.GetComponent <Monument>(); if (monument.InArea.Visible()) { BigStoneView.OpenStoneView(monument, Team); } //else // ClickedArea(monument.InArea); } else if (hit.collider && hit.collider.GetComponent <Cave>()) { var cave = hit.collider.GetComponent <Cave>(); if (cave.InArea.Visible()) { CaveView.OpenCaveView(cave, Team); } //else // ClickedArea(cave.InArea); } else if (hit.collider && hit.collider.GetComponent <WitchHut>()) { var hut = hit.collider.GetComponent <WitchHut>(); if (hut.InArea.Visible()) { WitchHutView.OpenWitchView(hut, Team); } //else // ClickedArea(hut.InArea); } else if (hit.collider && hit.collider.GetComponent <Area>()) { var a = hit.collider.GetComponent <Area>(); //Debug.Log("Clicked Area : " + (a.name)); //ClickedArea(a); } else { Debug.LogWarning("Not a valid hit: " + hit.point); } } }