// FinishAction is called whenever a unit will finish its actions for the round
    public void FinishAction()
    {
        if (this == null || gameObject == null)
        {
            return;
        }

        finished = true;

        // if the phase is not correct for this type of unit, return
        if (levelManagerScript.phaseCounter != 0 && gameObject.tag == "playerUnit")
        {
            return;
        }

        if (levelManagerScript.phaseCounter != 1 && gameObject.tag == "enemyUnit")
        {
            return;
        }

        if (levelManagerScript.phaseCounter != 2 && gameObject.tag == "alliedUnit")
        {
            return;
        }

        bool phaseOver = true;

        tilePrev = null;

        // check if all units of this type have finished, and if so if the phase should end
        foreach (GameObject unit in levelManagerScript.unitList)
        {
            if (!unit.GetComponent <UnitScript>().finished&& (unit.tag == gameObject.tag))
            {
                phaseOver = false;
            }
        }

        // if the phase should end, call NextPhase()
        if (phaseOver)
        {
            levelManagerScript.NextPhase();
        }
    }