// Update is called once per frame void Update() { if (m_myTurn) { World.Cell mouseOverCell = GetMouseOverCell(); if (mouseOverCell != null && mouseOverCell.ContainsEntity) { ApplyLOS(); int x, y; Entity ent = mouseOverCell.GetEntity(); ent.GetPosition(out x, out y); if (!"Player".Equals(ent.GetType().ToString()) && ent.GetCell().IsVisible()) { SetCrosshair(x, y); } else { HideCrosshair(); } if (Input.GetMouseButtonDown(0)) { AttackingEntity.AttackResult res = CombatSolver.Fight(m_actor, mouseOverCell.GetEntity().Actor); if (res != null && res.Weapon != null) { Synchronizer.Continue(m_actor, res.Weapon.TimeCost); return; } else if (res.Result == AttackingEntity.AttackResult.ResultValue.NoEnergy) { Debug.Log(res.Weapon.Name + " Out of energy"); } } } else { HideCrosshair(); } Vector2 move = Vector2.zero; if (Input.GetButtonDown("Horizontal")) { float h = Input.GetAxis("Horizontal"); move.x = Mathf.Sign(h); } if (Input.GetButtonDown("Vertical")) { float h = Input.GetAxis("Vertical"); move.y = Mathf.Sign(h); } if (move != Vector2.zero) { //Debug.Log("Move: " + move); MovingEntity.MoveResult result = m_movingEntity.Move(move); switch (result.Result) { case MovingEntity.MoveResult.ResultValue.Ok: Synchronizer.Continue(m_actor, m_movingEntity.moveActionCost); if (m_levelBuilder.LevelType != LevelType.Ambush) { if (m_levelBuilder.EndPoint.X == result.Cell.X && m_levelBuilder.EndPoint.Y == result.Cell.Y) { if (OnPlayerMovedToEndEvent != null) { OnPlayerMovedToEndEvent(); } } if (m_levelBuilder.ObjectivePoint.X == result.Cell.X && m_levelBuilder.ObjectivePoint.Y == result.Cell.Y) { if (OnPlayerMovedToObjectiveEvent != null) { OnPlayerMovedToObjectiveEvent(); } } } break; case MovingEntity.MoveResult.ResultValue.TileBlocked: //Debug.Log("Tile blocked!"); break; case MovingEntity.MoveResult.ResultValue.TileOccupied: AttackingEntity.AttackResult res = CombatSolver.Fight(m_actor, result.Cell.GetEntity().Actor); Synchronizer.Continue(m_actor, res.Weapon.TimeCost); break; } } } }