// Update is called once per frame void Update() { if (!turn) { return; } else if (attacking) { if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack1")) { attacking = false; AttackEnemy(target.GetComponent <TacticsMove>()); NewTurnManager.EndTurn(this); } } else if (hasMoved && !hasAttacked) { FindNearestTarget(); if (Vector3.Distance(transform.position, target.transform.position) <= attackRange) { anim.Play("Attack1"); attacking = true; } else { NewTurnManager.EndTurn(this); } } else if (!moving) { FindNearestTarget(); CalculatePath(); FindSelectableTiles(move); actualTargetTile.target = true; } else { anim.SetBool("Moving", true); Move(); } }
private void OnWaitClicked() { NewTurnManager.EndTurn(this); }
void CheckMouse() { if (Input.GetMouseButtonUp(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //Mouse was clicked on an object with a collider if (Physics.Raycast(ray, out hit)) { //A tile was clicked on if (hit.collider.tag == "Tile") { Tile clickedTile = hit.collider.GetComponent <Tile>(); if (choosingAttackTargets) { if (clickedTile.selectable) { TacticsMove attackTarget = clickedTile.GetUnitOnTile(); if (attackTarget != null) { AttackEnemy(attackTarget); hasAttacked = true; } } } //Tile was clicked on to move else if (!choosingAttackTargets) { //Display GUI info on the current moving unit classinfo.OnMouseDown(); //If the tile is a possible location to move to if (clickedTile.selectable) { //Target to move to MoveToTile(clickedTile); } } } //Player clicked on another unit of the same team else if (hit.collider.tag == "Player") { TacticsMove player = hit.collider.GetComponent <TacticsMove>(); if (!player.hasMoved || !player.hasAttacked) { RemoveSelectableTiles(); RemoveAttackableTiles(); this.turn = false; NewTurnManager.ExecuteTurn(player); } } else if (hit.collider.tag == "NPC" && !hasAttacked) { TacticsMove attackTarget = hit.collider.GetComponent <TacticsMove>(); //If our attack target exists and is within attack range if (attackTarget != null && attackTarget.GetCurrentTile().attackable) { choosingAttackTargets = false; enemy = attackTarget; PlayAttackAnimation(); } else { Debug.Log("This is the target tile " + attackTarget.GetCurrentTile()); } } } } }
private static void BeginTurn() { currentTeam = turnQueue.Dequeue(); NewTurnManager.StartTurn(currentTeam); }