using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using TMPro;
using System.Linq;
using UnityEngine.SceneManagement;


/*
    This script handles all the Missions. It uses listeners which are optimized for the current week
*/


public class MissionHandler : MonoBehaviour{
    //Access the missions list
    GameStatsManager game_statsManager;
    Missions missions;
    private bool MissionPopupShown = false; // Flag to track completion

    // Reference to the popup UI element
    public GameObject popup;
    public GameObject completed_missions_canvas;

    // Time when the scene started
    private float sceneStartTime;

    [HideInInspector]
    public MissionProgress Player_missionProgress;


    void OnEnable(){
        popup.SetActive(false);

        missions = GetComponent<Missions>();
        missionInfox = missions.getAllWeeklyMissions();

    }


    public List<MissionInfo> missionInfox;
    private void Start(){
        Player_missionProgress = LoadPlayer_MissionData();

        // Assuming you have a reference to the MissionsManager script
        game_statsManager = GetComponent<GameStatsManager>();

        // Record the time when the scene starts
        sceneStartTime = Time.time;

        StartCoroutine(ShowPopupsContinuously());
        
    }
    

    private void Update(){
        //Continuously check for Mission Progress
        Player_missionProgress = LoadPlayer_MissionData();

        int count = Player_missionProgress.completed_missions.Count();

        //Weekly missions completed
        if (count == 5){

            //End of month
            if (Player_missionProgress.current_week == 4){
                Player_missionProgress.current_month = Player_missionProgress.current_month + 1;
                Player_missionProgress.current_week = 1;

            }else{
                Player_missionProgress.current_week = Player_missionProgress.current_week + 1;
            }

            SavePlayer_MissionData(Player_missionProgress);
        }


        string result_ids1 = ListToString(Player_missionProgress.completed_missions);
        //Debug.LogWarning("CM's: " + result_ids1);


        // Check for mission completion continuously
        CheckMissions();
    }


    /* Function that calls functions for missions in the current week, only the current week missions 
        which are not already completed are considered, for Optimization */
    public static List<int> weeklyMissions_ID;
    public static List<int> static_weeklyMissionsID = new List<int>(){ 0 };
    
    private void CheckMissions(){
    // Create a new empty list of integers
    weeklyMissions_ID = new List<int>();

    playerData = LoadPlayerData();
    Player_missionProgress = LoadPlayer_MissionData();

    //Change this part to call missions where month and week from the player data are same as those in the recorded missions 
    foreach(MissionInfo mission_info1 in missionInfox){
        if ((mission_info1.month == Player_missionProgress.current_month) && (mission_info1.week == Player_missionProgress.current_week)){
            if (!(Player_missionProgress.completed_missions.Contains(mission_info1.missionID))){  //If Mission is not completed   
                CallWeeklyMissionFunction(mission_info1.missionID);
                weeklyMissions_ID.Add(mission_info1.missionID);
            }
        }
    }

    // Only update static_weeklyMissionsID if it contains the default value and weeklyMissions_ID has items
    if (static_weeklyMissionsID.Count == 1 && static_weeklyMissionsID[0] == 0 && weeklyMissions_ID.Count > 0){
        static_weeklyMissionsID = new List<int>(weeklyMissions_ID);
    }

    string result_ids = ListToString(weeklyMissions_ID);
}



    // Call Function Dynamically, based on current week's missions
    void CallWeeklyMissionFunction(int missionID){
        string functionName = "mission" + missionID + "_weekly";
        
        // Use reflection to dynamically invoke the function
        System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
        
        if (methodInfo != null){
            methodInfo.Invoke(this, null);
        }
    }


    string ListToString<T>(List<T> list){
        // Use string.Join to concatenate the elements of the list into a string
        return string.Join(", ", list);
    }

    
    // Gets the mission's value, checking that missions's progress
    public string getMissionValue(string mission22_MissionSearch_Result){
        string[] parts = mission22_MissionSearch_Result.Split(':');
        string missionID_StoredFound = parts[1].Trim();    //Get the value (num value), Trim() removes removes whitespaces if any, then Parses to int value
        return missionID_StoredFound;
    }


    //Plug Functions (PFS)
    #region
        //N.B: The 9 Functions below are called in other scripts so as to Track/Check missions
        /*
            1. StartOfEachMatch()
            2. EndOfEachMatch()
            3. StartOfEachRound()
            4. EndOfEachRound()
            5. PlayerHasHitEnemy()
            6. EnemyHasHitPlayer()
            7. CharacterUnlocked()
            8. AdsWatched()
            9. PlayerHasMoved()         ***
        */

        Completed_Missions_toAnimate completedMissionsToAnimate;

        //Function for START OF A MATCH, Call this function at the START of Match
        public static List<int> weeklyMatchStarted = new List<int>(){ 5, 14, 21, 25, 26 };
        public void StartOfEachMatch(){
            // CallWeeklyMissionFunction("MatchHasStarted");
            completedMissionsToAnimate = LoadPlayerData_CompletedMission_toAnimate();
            completedMissionsToAnimate.animation_status = 0;
            SaveCompleted_Missions_toAnimate(completedMissionsToAnimate);

            Debug.Log($"Start of Every Match {completedMissionsToAnimate.animation_status}");


            StartCoroutine(Execute_WeeklyMissionFunctions(weeklyMatchStarted, "_MatchHasStarted"));


            // foreach (int mID in weeklyMissions_ID){
            //     if (weeklyMatchStarted.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
            //         string functionName = "mission" + mID + "_MatchHasStarted";

            //         // Use reflection to dynamically invoke the function
            //         System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
            //         if (methodInfo != null){
            //             methodInfo.Invoke(this, null); //null refers to no arguments
            //         }
            //     }
            // }

            // mission5_MatchHasStarted();
            // mission14_MatchHasStarted();
            // mission21_MatchHasStarted();
            // mission25_MatchHasStarted();
            // mission26_MatchHasStarted();
        }


        int round = 0;
        public void a_bStartRound(){
            //Debug.LogError("R = " + round.ToString());
            StartOfEachRound(round);

            round++;
        }

        public void scene1(){
            SceneManager.LoadSceneAsync(2);
        }

        public void scene2(){
            SceneManager.LoadSceneAsync(3);
        }



        //Function for END OF A MATCH, Call this function at the END of Match
        public static List<int> weeklyMatchEnd = new List<int>(){ 7, 14, 17, 21, 25, 26, 33, 46, 47, 51, 56 };
        public void EndOfEachMatch(){

            foreach (int mID in weeklyMissions_ID){
                if (weeklyMatchEnd.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
                    string functionName = "mission" + mID + "_MatchHasEnded";

                    // Use reflection to dynamically invoke the function
                    System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
                    if (methodInfo != null){
                        methodInfo.Invoke(this, null); //null refers to no arguments
                    }
                }
            }

            // mission7_MatchHasEnded();
            // mission14_MatchHasEnded();
            // mission17_MatchHasEnded();
            // mission21_MatchHasEnded();
            // mission25_MatchHasEnded();
            // mission26_MatchHasEnded();
            // mission33_MatchHasEnded();
            // mission46_MatchHasEnded();
            // mission47_MatchHasEnded();
            // mission51_MatchHasEnded();
        }


        //Function for START OF A ROUND, Call this function at the START of each round
        public static List<int> weeklyRoundStarted = new List<int>(){ 1, 2, 3, 4, 11, 13, 15, 21, 23, 24, 25, 27, 31, 38, 41, 42, 51, 56, 57 };
        public void StartOfEachRound(int roundNum){
            //Match has started
            if (roundNum == 1){
                StartOfEachMatch();
            }

            StartCoroutine(Execute_WeeklyMissionFunctions(weeklyRoundStarted, "_RoundHasStarted"));

            // foreach (int mID in weeklyMissions_ID){
            //     if (weeklyRoundStarted.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
            //         string functionName = "mission" + mID + "_RoundHasStarted";

            //         // Use reflection to dynamically invoke the function
            //         System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
            //         if (methodInfo != null){
            //             methodInfo.Invoke(this, null); //null refers to no arguments
            //         }
            //     }
            // }

            // mission1_RoundHasStarted();
            // mission2_RoundHasStarted();
            // mission3_RoundHasStarted();
            // mission4_RoundHasStarted();
            // mission11_RoundHasStarted();
            // mission13_RoundHasStarted();
            // mission15_RoundHasStarted();
            // mission21_RoundHasStarted();
            // mission23_RoundHasStarted();
            // mission24_RoundHasStarted();
            // mission25_RoundHasStarted();
            // mission27_RoundHasStarted();
            // mission38_RoundHasStarted();
            // mission41_RoundHasStarted();
            // mission42_RoundHasStarted();
            // mission51_RoundHasStarted();
            // mission57_RoundHasStarted();
        }


        public IEnumerator Execute_WeeklyMissionFunctions(List<int> Mission_List, string Mission_FunctionSuffix, params object[] Mission_Params){
            foreach (int mID in weeklyMissions_ID){
                if (Mission_List.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
                    string functionName = "mission" + mID + Mission_FunctionSuffix;

                    // string functionName = "mission" + mID + "_RoundHasEnded";

                    // Use reflection to dynamically invoke the function
                    System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
                    if (methodInfo != null){
                        methodInfo.Invoke(this, Mission_Params ); //null refers to no arguments
                    yield return new WaitForSeconds(20f);//3f,5f works for pc not mobile, mobile 
                }
                }
            }
        }


        //Function for END OF A ROUND
        //(int roundNum, string round_status, int player_health, int player_points, string player_CharacterName, int enemy_health)
        public static List<int> weeklyRoundEnd = new List<int>(){ 5, 7, 8, 12, 13, 15, 16, 17, 21, 23, 24, 25, 26, 31, 32, 33, 34, 42, 46, 47, 51, 56, 57 };
        public void EndOfEachRound(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
            //Debug.LogWarning("PH = " + playerHealth.ToString() + " XR Status = " + round_status + " CharName = " + player_CharacterName);
            // PH = 62 XR Status = player_won CharName = Cheetah(Clone)

            StartCoroutine(Execute_WeeklyMissionFunctions(weeklyRoundEnd, "_RoundHasEnded", roundNum, round_status, playerHealth, playerPoints, player_CharacterName, enemyHealth));

            // foreach (int mID in weeklyMissions_ID){
            //     if (weeklyRoundEnd.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
            //         string functionName = "mission" + mID + "_RoundHasEnded";

            //         // Use reflection to dynamically invoke the function
            //         System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
            //         if (methodInfo != null){
            //             methodInfo.Invoke(this, new object[] { roundNum, round_status, playerHealth, playerPoints, player_CharacterName, enemyHealth }); //null refers to no arguments
            //         }
            //     }
            // }





            // mission5_RoundHasEnded(round_status);               //Win status
            // mission7_RoundHasEnded(round_status);               //Win status
            // mission8_RoundHasEnded(round_status, playerHealth);     //Win status and Player health
            // mission12_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission13_RoundHasEnded(round_status);              //Win status
            // mission15_RoundHasEnded(round_status);              //Win status
            // mission16_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission17_RoundHasEnded(round_status);              //Win status
            // mission21_RoundHasEnded(round_status);              //Win status
            // mission23_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission24_RoundHasEnded(round_status);              //Win status
            // mission25_RoundHasEnded(round_status);              //Win status
            // mission26_RoundHasEnded(round_status, roundNum, playerHealth);    //Round number, Win status, Player health
            // mission32_RoundHasEnded(round_status, player_CharacterName);     //Win status and Winner Character name
            // mission33_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission34_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission42_RoundHasEnded(round_status);              //Win status, Player and Opponent's health
            // mission46_RoundHasEnded(round_status);              //Win status
            // mission47_RoundHasEnded(round_status, playerHealth);              //Win status and Player health
            // mission51_RoundHasEnded();
            // mission57_RoundHasEnded(round_status);              //Win Status



            //End of Match
            int TotalRounds = 3;
            if (roundNum == TotalRounds){   //Last Round
                EndOfEachMatch();
            }
        }


        //Function for when Player hits Enemy
        public static List<int> weeklyPlayerHitEnemy = new List<int>(){ 2, 3, 4, 11, 15, 23, 25, 27, 38, 41, 57 };
        public void PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
            StartCoroutine(Execute_WeeklyMissionFunctions(weeklyPlayerHitEnemy, "_PlayerHasHitEnemy", action_type, action_source, enemyHealth));

            // foreach (int mID in weeklyMissions_ID){
            //     if (weeklyEnemyHitPlayer.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
            //         string functionName = "mission" + mID + "_PlayerHasHitEnemy";

            //         // Use reflection to dynamically invoke the function
            //         System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
            //         if (methodInfo != null){
            //             methodInfo.Invoke(this, new object[] { action_type, action_source, enemyHealth }); //null refers to no arguments
            //         }
            //     }
            // }


            // mission2_PlayerHasHitEnemy(action_type, action_source); //Player Hit Enemy
            // mission3_PlayerHasHitEnemy(action_type, action_source);
            // mission4_PlayerHasHitEnemy(action_type, action_source);
            // mission11_PlayerHasHitEnemy(action_type, action_source);
            // mission15_PlayerHasHitEnemy(action_type, action_source);
            // mission23_PlayerHasHitEnemy(action_type, action_source);
            // mission25_PlayerHasHitEnemy(action_type, action_source);
            // mission27_PlayerHasHitEnemy(action_type, action_source);
            // mission38_PlayerHasHitEnemy(action_type, action_source);
            // mission57_PlayerHasHitEnemy(action_type, action_source);
            // mission41_PlayerHasHitEnemy(enemyHealth);  //Requires Enemy health
        }


        //Function for when Enemy hits Player
        public static List<int> weeklyEnemyHitPlayer = new List<int>(){ 1, 2, 3, 4, 11, 24, 27, 41 };
        public void EnemyHasHitPlayer(string action_type, string action_source){
            StartCoroutine(Execute_WeeklyMissionFunctions(weeklyEnemyHitPlayer, "_EnemyHasHitPlayer"));

            // foreach (int mID in weeklyMissions_ID){
            //     if (weeklyEnemyHitPlayer.Contains(mID)){    //If Character Unlock mission function contain current week missions ID
                    
            //         string functionName = "mission" + mID + "_EnemyHasHitPlayer";

            //         // Use reflection to dynamically invoke the function
            //         System.Reflection.MethodInfo methodInfo = GetType().GetMethod(functionName);
                    
            //         if (methodInfo != null){
            //             methodInfo.Invoke(this, null); //null refers to no arguments
            //         }
            //     }
            // }

            // mission1_EnemyHasHitPlayer(); //Does not need any params
            // mission2_EnemyHasHitPlayer();
            // mission3_EnemyHasHitPlayer();
            // mission4_EnemyHasHitPlayer();
            // mission11_EnemyHasHitPlayer();
            // mission24_EnemyHasHitPlayer();
            // mission27_EnemyHasHitPlayer();
            // mission41_EnemyHasHitPlayer();  //Requires Enemy health
        }


        //Character has been Unlocked
        public static List<int> weeklyCharacter_Unlock = new List<int>(){ 31, 56 };
        public void CharacterUnlocked(string characterName){
            Start();
            Debug.LogWarning("Char = " + characterName);

            string result3xr = ListToString(static_weeklyMissionsID);
            //Debug.LogWarning("Completed Missions: " + result3xr);

            foreach (int CharUnlock_ID in static_weeklyMissionsID){
                if (weeklyCharacter_Unlock.Contains(CharUnlock_ID)){    //If Character Unlock mission function contain current week missions ID
                    
                    string CharacterUnlock_functionName = "mission" + CharUnlock_ID + "_CharacterUnlocked";
                    //Debug.LogWarning("XM " + CharacterUnlock_functionName);

                    // Use reflection to dynamically invoke the function
                    System.Reflection.MethodInfo CharacterUnlock_methodInfo = GetType().GetMethod(CharacterUnlock_functionName);
                    
                    if (CharacterUnlock_methodInfo != null){
                        if (CharUnlock_ID == 31){ //Invoke the method with arguments passed in
                            CharacterUnlock_methodInfo.Invoke(this, new object[] { characterName });    //Pass Character Name
                            //Debug.LogWarning("Char31 = " + characterName);

                        }else{
                            CharacterUnlock_methodInfo.Invoke(this, null); //null refers to no arguments
                        }
                        
                    }
                }
            }

            // mission31_CharacterUnlocked();  //Character Name
            // mission56_CharacterUnlocked();
        }


        //Ads have been Watched
        public static List<int> weeklyMissions_Ads = new List<int>(){ 18, 22, 32, 37, 52 };
        public void AdsWatched(){

            //Invoke all Ad missions in the current month and week
            foreach (int Ad_ID in weeklyMissions_ID){
                if (weeklyMissions_Ads.Contains(Ad_ID)){    //If Ads missions function contain current week missions ID
                    
                    // mission22_AdsWatchedIncrement
                    string AdfunctionName = "mission" + Ad_ID + "_AdsWatchedIncrement";
                    //Debug.LogWarning("XM " + AdfunctionName);

                    // Use reflection to dynamically invoke the function
                    System.Reflection.MethodInfo AdmethodInfo = GetType().GetMethod(AdfunctionName);
                    
                    if (AdmethodInfo != null){
                        AdmethodInfo.Invoke(this, null);
                    }
                }
            }

            // mission18_AdsWatchedIncrement();
            // mission22_AdsWatchedIncrement();
            // mission37_AdsWatchedIncrement();
            // mission52_AdsWatchedIncrement();
        }


        //Player has Moved
        public static List<int> weeklyMissions_Move = new List<int>(){ 21 };
        public void PlayerHasMoved(){

            foreach (int Move_ID in weeklyMissions_ID){
                if (weeklyMissions_Move.Contains(Move_ID)){    //If Ads missions function contain current week missions ID
                    //Debug.LogWarning("21 Called");
                    
                    // mission22_AdsWatchedIncrement
                    string AdfunctionName = "mission" + Move_ID + "_PlayerHasWalked";

                    //Debug.LogWarning("21 Called " + AdfunctionName);

                    // Use reflection to dynamically invoke the function
                    System.Reflection.MethodInfo AdmethodInfo = GetType().GetMethod(AdfunctionName);
                    
                    if (AdmethodInfo != null){
                        AdmethodInfo.Invoke(this, null);
                    }
                }
            }

            // mission21_PlayerHasWalked();
        }

    #endregion

    

    //START OF WEEKLY MISSIONS
    #region
        //1, 9, 5, 19, 3, 28, 21, 24, 26, 39, 42, 43, 48, 53, 58
        //3, 9, 1, 19, 2, 28, 11, 39, 43, 48, 53, 58, 5, 13, 21, 24, 26, 42, 51, 57

        //MONTH 1,  ID 1 - 20
        #region

            //Weekly Mission ID = 1         || Survive the first 20 seconds of the game without taking a hit.
            #region
                //Functions used: mission1_RoundHasStarted(), mission1_EnemyHasHitPlayer()
                public bool mission1_RoundIsStarted = false, mission1_PlayerWasHit = false, mission1_20SecondsPassed = false;

                //INSTRUCTIONS: Creates a timer for 20 seconds, within that time checks if any collisions happened
                public void mission1_weekly(){
                    // Debug.LogWarning("Mission1 Called");

                    //Checks if round has started, Counts for 20 seconds, After those 20 seconds, checks if hit occured
                    //Debug.LogWarning("Round = " + mission1_RoundIsStarted + " 20Secs = " + mission1_20SecondsPassed +  " PlayerHit = " + mission1_PlayerWasHit);


                    if ((mission1_RoundIsStarted == true) && (mission1_20SecondsPassed == true)){   //If Round has started, 20 Seconds have passed and Player was NOT HIT
                        if (mission1_PlayerWasHit == false){ //Player has not taken a hit after 20 seconds a round has started
                            instantiate_completedMissionCanvas(1);
                            game_statsManager.updateMission(1);

                            // Debug.LogWarning("Mission1 Completed!");
                        }
                    }
                }


                //Called at the Start of each Round after the Countdown (3 2 1 Fight!), Then counts 20 seconds
                public void mission1_RoundHasStarted(){
                    mission1_20SecondsPassed = false;
                    mission1_PlayerWasHit = false;
                    mission1_RoundIsStarted = false;

                    //Debug.LogWarning("Round Mission1 Started");
                    if (mission1_RoundIsStarted == false){
                        mission1_RoundIsStarted = true;
                    }
                    
                    StartCoroutine(mission1_Delay20SecCountdown(20f));  //Count for 20 seconds
                }

                //Counts for 20 seconds time Parameters are (delaytime in seconds)
                IEnumerator mission1_Delay20SecCountdown(float delaytime){

                    //Wait for 20 seconds
                    yield return new WaitForSeconds(delaytime);

                    //After 20 seconds, create flag that 20 seconds have passed
                    if (mission1_20SecondsPassed == false){
                        mission1_20SecondsPassed = true;
                    }
                }

                public void mission1_EnemyHasHitPlayer(){
                    //For Mission 1
                    mission1_PlayerWasHit = true;
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission1_RoundStarted(){
                        // startOfEachRound(1);
                        mission1_RoundHasStarted();
                    }

                    public void a_mission1_EnemyHasHitPlayer(){
                        EnemyHasHitPlayer("kick", "Player(Clone)");
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 1



            //Weekly Mission ID = 2         || Punch opponent 5 times in a row
            #region
                //Functions used: mission2_RoundHasStarted(), mission2_EnemyHasHitPlayer(), mission2_PlayerHasHitEnemy()
                public static bool mission2_RoundIsStarted = false;
                public static int mission2_PunchCounter = 0, mission2_KickCounter = 0;

                public void mission2_weekly(){
                    // Debug.LogWarning("Mission2 Called");

                    // Debug.LogWarning("2PUNCH " + mission2_PunchCounter.ToString());

                    string result3r = ListToString(Player_missionProgress.completed_missions);
                    //Debug.LogWarning("Completed Missions: " + result3r);

                    //If round has started
                    if (mission2_RoundIsStarted == true){
                        //Debug.LogWarning("Mission2 Start of Round");
                        // if (mission2_PunchCounter == 5){    //If Punch Counter reaches 5


                        //Colliders register punch as 2
                        // if (mission2_PunchCounter == 5){    //10, If Punch Counter reaches 5
                        if ((mission2_PunchCounter > 5) && (mission2_PunchCounter < 13)){    //10, If Punch Counter reaches 5
                            instantiate_completedMissionCanvas(2);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(2);

                            // Debug.Log("Mission2 Completed");
                        }
                    }
                }

                public void mission2_RoundHasStarted(){
                    mission2_RoundIsStarted = false;
                    mission2_PunchCounter = 0;
                    mission2_KickCounter = 0;

                    if (mission2_RoundIsStarted == false){
                        mission2_RoundIsStarted = true;
                    }
                }


                //If Enemy has Hit Player, Reset Punch Counter
                public void mission2_EnemyHasHitPlayer(){
                    //For Mission 2
                    mission2_PunchCounter = 0;
                    mission2_KickCounter = 0;
                    //Debug.LogWarning("PUNCH " + mission2_PunchCounter.ToString());
                }

                public void mission2_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    if (action_type == "punch"){
                        mission2_PunchCounter = mission2_PunchCounter + 1;  //Increment number of punches

                        //For Mission 2
                        mission2_KickCounter = 0;
                    }

                    if (action_type == "kick"){
                        mission2_KickCounter = mission2_KickCounter + 1;  //Increment number of punches
                        // Debug.LogWarning("2KICK " + mission2_KickCounter.ToString());

                        //For Mission 2
                        mission2_PunchCounter = 0;
                    }

                    // Debug.LogWarning("****** 2PUNCH " + mission2_PunchCounter.ToString());
                    // Debug.LogWarning("****** 2KICK " + mission2_KickCounter.ToString());
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission2_RoundStarted(){
                        mission2_RoundHasStarted();
                    }

                    public void a_mission2_EnemyHitPlayer(){
                        mission2_EnemyHasHitPlayer();
                        // EnemyHasHitPlayer("kick", "Player(Clone)");
                    }

                    public void a_mission2_PlayerKick(){
                        mission2_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                        // playerHasHitEnemy("kick", "Player(Clone)");
                    }

                    public void a_mission2_PlayerPunch(){
                        mission2_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                        // playerHasHitEnemy("punch", "Player(Clone)");
                    }
                #endregion               

            #endregion
            //END OF Weekly Mission ID = 2



            //Weekly Mission ID = 3         || Kick opponent 3 times in a row.
            #region
                //Functions used: mission3_RoundHasStarted(), mission3_EnemyHasHitPlayer(), mission3_PlayerHasHitEnemy()
                public static int mission3_KickCounter = 0;
                public static bool mission3_RoundIsStarted = false;

                public void mission3_weekly(){
                    // Debug.LogWarning("Mission3 Called");

                    // Debug.LogWarning("3KICK " + mission3_KickCounter.ToString());

                    //If round has started
                    if (mission3_RoundIsStarted == true){
                        // if (mission3_KickCounter == 3){

                        // if (mission3_KickCounter == 3){  //12, Kick collider registers as 4
                        if ((mission3_KickCounter > 9) && (mission3_KickCounter < 15)){  //12, Kick collider registers as 4
                            instantiate_completedMissionCanvas(3);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(3);

                            // Debug.Log("Mission3 Completed");
                        }
                    }
                }

                public void mission3_RoundHasStarted(){
                    mission3_RoundIsStarted = false;
                    mission3_KickCounter = 0;

                    if (mission3_RoundIsStarted == false){
                        mission3_RoundIsStarted = true;
                    }
                }


                public void mission3_EnemyHasHitPlayer(){
                    //For Mission 2
                    mission3_KickCounter = 0;
                }

                public void mission3_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    //Debug.LogError("player_HasHitEnemy_detected");

                    if (action_type == "punch"){
                        mission3_KickCounter = 0;
                    }

                    if (action_type == "kick"){
                        mission3_KickCounter = mission3_KickCounter + 1;  //Increment number of punches
                    }

                    //Debug.LogWarning("3KICK " + mission3_KickCounter.ToString());
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission3_RoundStarted(){
                        // startOfEachRound(1);
                        mission3_RoundHasStarted();
                    }

                    public void a_mission3_EnemyHitPlayer(){
                        mission3_EnemyHasHitPlayer();
                    }

                    public void a_mission3_PlayerKick(){
                        mission3_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }

                    public void a_mission3_PlayerPunch(){
                        mission3_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }
                #endregion               

            #endregion
            //END OF Weekly Mission ID = 3



            //Weekly Mission ID = 4         || Perform Kick-Punch-Kick combo (KPK)
            #region
                //Functions used: mission4_RoundHasStarted(), mission4_EnemyHasHitPlayer(), mission4_PlayerHasHitEnemy()
                public static string kick_punch_kick_Combo = "";
                public static bool mission4_RoundIsStarted = false;

                public void mission4_weekly(){
                    // Debug.LogWarning("Mission4 Called");

                    //Debug.LogWarning("KPK value = " + kick_punch_kick_Combo);

                    if (mission4_RoundIsStarted == true){   //Round has started
                        if (kick_punch_kick_Combo == "KPK"){
                            instantiate_completedMissionCanvas(4);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(4);

                            // Debug.Log("Mission4 Completed");

                            //Debug.LogWarning("KPK Combo achieved!");                        
                        }
                    }
                }

                public void mission4_RoundHasStarted(){
                    mission4_RoundIsStarted = false;
                    kick_punch_kick_Combo = "";

                    if (mission4_RoundIsStarted == false){
                        mission4_RoundIsStarted = true;
                    }
                }

                public void mission4_EnemyHasHitPlayer(){
                    kick_punch_kick_Combo = "";
                }

                public void mission4_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    mission4_CheckCombo(action_type);
                }

                public void mission4_CheckCombo(string action_performed){  //Looking for KPK
                    string action_done_initial = (action_performed == "punch") ? "P" : "K";

                    switch(kick_punch_kick_Combo){
                        //First letter
                        case "":
                            if (action_done_initial == "P"){
                                kick_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the first "K"
                                kick_punch_kick_Combo += "K";
                                break;
                            }

                        //Second letter
                        case "K":
                            if (action_done_initial == "K"){
                                kick_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the "P"
                                kick_punch_kick_Combo += "P";
                                break;
                            }
                            
                        //Third letter
                        case "KP":
                            if (action_done_initial == "P"){
                                kick_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the last "K"
                                kick_punch_kick_Combo += "K";
                                break;
                            }
                    }
                    // Debug.LogWarning("Combo val = " + kick_punch_kick_Combo);
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission4_RoundStarted(){
                        StartOfEachRound(1);
                    }

                    public void a_mission4_EnemyHitPlayer(){
                        EnemyHasHitPlayer("kick", "Player(Clone)");
                    }

                    public void a_mission4_PlayerKick(){
                        PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }

                    public void a_mission4_PlayerPunch(){
                        PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }
                #endregion               



                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void addletters(){
                        mission4_CheckCombo("kick");
                    }

                    public void addletters_ruin(){
                        mission4_CheckCombo("punch");
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 4



            //Weekly Mission ID = 5         || Win 2 rounds in a row.
            #region
                //Functions used: mission5_RoundHasEnded(), mission5_MatchHasStarted()
                public static int roundsWon_counter = 0;

                public void mission5_weekly(){
                    // Debug.LogWarning("Mission5 Called");
                    //Debug.LogWarning("Mission5stat = " + roundsWon_counter.ToString() + " Total Rounds = " + total_rounds.ToString());

                    //If Rounds Won are 2 or more
                    if (roundsWon_counter >= 2){
                        instantiate_completedMissionCanvas(5);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(5);

                        // Debug.LogWarning("Mission5 completed");    
                    }
                }

                //Call each time a Round is Over, Params are (round_status: player_won or player_lost, currentRound: 1 or other)
                // public void mission5_RoundHasEnded(int currentRound, string round_status){ //XTParam: Param required for winning status
                public void mission5_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){ //XTParam: Param required for winning status
                    if (round_status == "player_won"){
                        roundsWon_counter++;
                        // playerHasWon = true;
                    }

                    //Reset Win counter if Player loses a round
                    if (round_status == "player_lost"){
                        roundsWon_counter = 0;
                    }
                }

                public void mission5_MatchHasStarted(){
                    roundsWon_counter = 0;
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int total_rounds = 5;
                    public void a_mission5_btn_playerWon(){
                        roundsWon_counter++;
                        total_rounds--;
                    }

                    public void a_mission5_btn_playerLost(){
                        roundsWon_counter = 0;
                        total_rounds--;
                    }

                    public void a_bmission5test(){
                        instantiate_completedMissionCanvas(5);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(5);
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 5



            //Weekly Mission ID = 6         || Complete any 2 missions
            #region
                public void mission6_weekly(){
                    //Debug.LogWarning("Mission6 Called");

                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3 = ListToString(Player_missionProgress.completed_missions);
                    //Debug.LogWarning("Completed Missions: " + result3);

                    //Count how many completed missions are between 7 to 10
                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 7 && mission <= 10);

                    //Debug.LogWarning("missionID6_counter " + count.ToString());

                    if (count >= 2){
                        instantiate_completedMissionCanvas(6);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(6);

                        //Debug.LogWarning("Mission6 Completed");
                    }
                }


                //DLT
                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int missID = 7;
                    public void a_mission6_missionDone(){
                        instantiate_completedMissionCanvas(missID);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(missID);

                        missID++;
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 6



            //Weekly Mission ID = 7         || Win 2 matches in a row
            //Winning a Match means Winning Each Round
            //Functions used: mission7_RoundHasEnded(), mission7_MatchHasEnded()
            #region
                public static int mission7_WinStreakOf2Matches = 0, mission7_MissionSearch_Index = 0, mission7_TotalRounds = 3, mission7_CountRoundWins = 0;
                public static string mission7_MissionSearch = "", mission7_SearchTerm = "Mission7";
                public static bool mission7_MatchIsEnded = false;

                public void mission7_weekly(){
                    //Debug.LogWarning("RoundWin = " + mission7_CountRoundWins.ToString() + " Matchwin = " + mission7_WinStreakOf2Matches.ToString());

                    Player_missionProgress = LoadPlayer_MissionData();

                    mission7_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission7_SearchTerm));
                    mission7_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission7_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission7_MissionSearch != null){
                        mission7_WinStreakOf2Matches = int.Parse(getMissionValue(mission7_MissionSearch));

                        Debug.LogWarning("Miss7 " + mission7_WinStreakOf2Matches.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission7: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }


                    if (mission7_WinStreakOf2Matches == 2){
                        instantiate_completedMissionCanvas(7);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(7);

                        Debug.LogWarning("Mission7 Completed!");
                    }
                }

                public void mission7_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //If Won
                    if (round_status == "player_won"){
                        mission7_CountRoundWins++;
                    }
                }

                public void mission7_MatchHasEnded(){
                    // mission7_MatchIsEnded = true;

                    //If all Rounds are Won in 1 Match
                    if (mission7_CountRoundWins == mission7_TotalRounds){
                        mission7_WinStreakOf2Matches++;

                        Player_missionProgress.completed_missions_inprogress[mission7_MissionSearch_Index] = "Mission7: " + mission7_WinStreakOf2Matches.ToString();
                        SavePlayer_MissionData(Player_missionProgress);
                        Debug.LogWarning("Total WinStreak Mission7 = " + mission7_WinStreakOf2Matches.ToString());
                    }
                    else{
                        //Reset the Win Streak if all rounds are not won in a match
                        mission7_WinStreakOf2Matches = 0;

                        Player_missionProgress.completed_missions_inprogress[mission7_MissionSearch_Index] = "Mission7: 0";
                        SavePlayer_MissionData(Player_missionProgress);
                        Debug.LogWarning("Total WinStreak Mission7 = " + mission7_WinStreakOf2Matches.ToString());
                    }

                    mission7_CountRoundWins = 0;
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission7_MatchEnd(){
                        mission7_MatchHasEnded();
                    }

                    public void a_mission7_RoundEnd(){
                        mission7_RoundHasEnded(1, "player_won", 100, 50, "C", 100);
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 7



            //Weekly Mission ID = 8         || Win a round with health not less than 50%
            #region
                //Functions used: mission8_RoundHasEnded()
                public static bool mission8_PlayerHealthMoreThan50 = false;
                public void mission8_weekly(){
                    Debug.LogWarning("Mission8 Called");

                    if (mission8_PlayerHealthMoreThan50 == true){
                        instantiate_completedMissionCanvas(8);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(8);     //For registering the completed mission with the ID

                        Debug.LogWarning("Mission8 done"); 
                    }
                }

                public static int mission8_PlayerHealth = 5;
                public void mission8_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){   //Round has Ended, Param should be Player's final health, and Current Round
                    mission8_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission8_PlayerHealth > 50)){     //Check if final round and the health is not less than 60
                        mission8_PlayerHealthMoreThan50 = true;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission8_RoundOver(){
                        Debug.LogWarning("CLICK");
                        mission8_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }
                #endregion


            #endregion
            //END OF Weekly Mission ID = 8



            //Weekly Mission ID = 9     || Reach 200 XP
            #region
                public void mission9_weekly(){
                    //Debug.Log("Mission9 Called");

                    //Debug.LogError((playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 1000){
                        instantiate_completedMissionCanvas(9);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(9);     //For registering the completed mission with the ID
                        //Debug.Log("Mission9 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 9



            //Weekly Mission ID = 10        || Rank up to Level 2 Bronze
            #region
                public void mission10_weekly(){
                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 2) && (playerData.rank == "Bronze")){
                        instantiate_completedMissionCanvas(10);
                        game_statsManager.updateMission(10);
                        
                        Debug.Log("Mission10 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 10



            //Weekly Mission ID = 11            || Land a 5-hit punch combo
            #region
                //Functions used: mission11_RoundHasStarted(), mission11_EnemyHasHitPlayer(), mission11_PlayerHasHitEnemy()
                public static string punch_Combo = "";
                public void mission11_weekly(){
                    Debug.LogWarning("P value = " + punch_Combo);

                    if (punch_Combo == "PPPPP"){
                        instantiate_completedMissionCanvas(11);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(11);

                        Debug.LogWarning("5P Combo achieved!");
                    }
                }

                public void mission11_RoundHasStarted(){
                    punch_Combo = "";   //Reset Punch Combo at the start of each round
                }

                public void mission11_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    mission11_CheckCombo(action_type);
                }

                public void mission11_EnemyHasHitPlayer(){
                    punch_Combo = "";
                }

                public void mission11_CheckCombo(string action_performed){  //Looking for KPK
                    string action_done_initial = (action_performed == "punch") ? "P" : "K";

                    if (action_done_initial == "P"){
                        punch_Combo += "P";
                    }

                    if (action_done_initial == "K"){
                        punch_Combo = "";
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission11_add11letters(){
                        mission11_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }

                    public void a_mission11_add11letters_ruin(){
                        mission11_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }

                    public void a_mission11_enemyHit(){
                        mission11_EnemyHasHitPlayer();
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 11



            //Weekly Mission ID = 12        || Win a round without taking damage 
            #region
                //Functions used: mission12_RoundHasEnded()
                public static bool mission12_PlayerPerfectHealth = false;

                //Check if the player has won and health is at a certain amount
                public void mission12_weekly(){
                    if (mission12_PlayerPerfectHealth == true){
                        instantiate_completedMissionCanvas(12);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(12);
                        
                        Debug.LogWarning("Mission12 Completed");
                    }
                }

                public static int mission12_PlayerHealthEndOfRound = 100;
                public void mission12_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    mission12_PlayerHealthEndOfRound = playerHealth;
                    if ((round_status == "player_won") && (mission12_PlayerHealthEndOfRound >= 98)){    //Check if the Player's health at the end of a round is above 98 (Perfect Health)
                        mission12_PlayerPerfectHealth = true;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission12_RoundOver(){
                        mission12_RoundHasEnded(1, "player_won", 100, 50, "C", 100);
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 12



            //Weekly Mission ID = 13        || Complete a round in under 30 seconds.
            #region
                //Functions used: mission13_RoundHasStarted, mission13_RoundHasEnded()
                public static bool mission13_RoundIsStarted = false, mission13_RoundIsOver = false, mission13_count30seconds = false;

                //Check if a round has started
                public void mission13_weekly(){
                    Debug.LogWarning("RoundStarted = " + mission13_RoundIsStarted + " RoundOver = " + mission13_RoundIsOver + " 30Sec = " + mission13_count30seconds);

                    if (mission13_RoundIsStarted == true){    //Round has started
                        if ((mission13_RoundIsOver == true) && (mission13_count30seconds == false)){     //Round has Ended, Before 30 second count
                            instantiate_completedMissionCanvas(13);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(13);     //For registering the completed mission with the ID

                            Debug.Log("Mission13 Completed!");
                        }
                    }
                }

                public void mission13_RoundHasStarted(){
                    mission13_RoundIsStarted = false;
                    mission13_RoundIsOver = false;
                    mission13_count30seconds = false;

                    if (mission13_RoundIsStarted == false){
                        mission13_RoundIsStarted = true;
                    }

                    StartCoroutine(mission13_Delay30SecCountdown(5f));   //Count the 30 seconds
                }

                public void mission13_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){
                        if (mission13_RoundIsOver == false){
                            mission13_RoundIsOver = true;
                        }
                    }
                }

                IEnumerator mission13_Delay30SecCountdown(float delaytime){

                    //Wait for 30 seconds
                    yield return new WaitForSeconds(delaytime);

                    if (mission13_count30seconds == false){
                        mission13_count30seconds = true;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartRound(), RoundOver()
                #region
                    public void a_mission13_RoundStarted(){
                        StartOfEachRound(1);
                    }

                    public void a_mission13_RoundOver(){
                        mission13_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 13



            //Weekly Mission ID = 14        || Complete 3 missions in a single match
            #region
                //Functions used: mission14_MatchHasStarted(), mission14_MatchHasEnded()
                public static bool mission14_MatchIsStarted = false, mission14_MatchIsEnded = false;
                public void mission14_weekly(){
                    Debug.LogWarning("MatchStarted = " + mission14_MatchIsStarted + " MatchEnded = " + mission14_MatchIsEnded);
                    if ((mission14_MatchIsStarted == true) && (mission14_MatchIsEnded == true)){    //If Match has started and Match has ended
                        Player_missionProgress = LoadPlayer_MissionData();

                        string result3 = ListToString(Player_missionProgress.completed_missions);
                        Debug.LogWarning("Completed Missions: " + result3);

                        int count = Player_missionProgress.completed_missions.Count(mission => (mission >= 11 && mission <= 15) && mission != 14);

                        Debug.LogWarning("missionID14_counter " + count.ToString());

                        if (count >= 3){    //Check if 3 missions have been completed
                            instantiate_completedMissionCanvas(14);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(14);

                            Debug.LogWarning("Mission14 Completed");
                        }
                    }
                }

                public void mission14_MatchHasStarted(){
                    mission14_MatchIsStarted = false;
                    mission14_MatchIsEnded = false;

                    if (mission14_MatchIsStarted == false){
                        mission14_MatchIsStarted = true;
                    }
                    Debug.LogWarning("Mission14 Match Started");
                }

                public void mission14_MatchHasEnded(){
                    if (mission14_MatchIsEnded == false){
                        mission14_MatchIsEnded = true;
                    }
                }



                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission14_MatchStarted(){
                        StartOfEachMatch();
                    }

                    public static int mission_comp = 11;
                    public void a_mission14_MissionCompleted(){
                        Debug.LogWarning("Missions Done " + mission_comp.ToString());

                        if (mission_comp != 14){
                            instantiate_completedMissionCanvas(mission_comp);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(mission_comp);
                        }
                        mission_comp++;
                    }

                    public void a_mission14_MatchEnded(){
                        EndOfEachMatch();
                    }
                #endregion


            #endregion
            //END OF Weekly Mission ID = 14



            //Weekly Mission ID = 15        || Win a round using only punches
            #region
                //Functions used: mission15_RoundHasStarted(), mission15_RoundHasEnded(), mission15_PlayerHasHitEnemy()
                public static int mission15_PunchCounter = 0, mission15_KickCounter = 0;
                public static bool mission15_RoundIsStarted = false, mission15_RoundIsOver = false;
                public void mission15_weekly(){
                    Debug.LogWarning("15Kick = " + mission15_KickCounter.ToString() + " Punch = " + mission15_PunchCounter.ToString());

                    if (mission15_RoundIsOver == true){ //Player has Won
                        if (mission15_KickCounter == 0){    //No Kicks were used, Only Punches
                            instantiate_completedMissionCanvas(15);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(15);

                            Debug.LogWarning("Mission15 Completed!");
                        }
                    }
                }

                public void mission15_RoundHasStarted(){
                    mission15_RoundIsStarted = true;

                    //Restarts variables for a new round
                    mission15_PunchCounter = 0;
                    mission15_KickCounter = 0;
                    mission15_RoundIsOver = false;
                }


                public void mission15_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){
                        mission15_RoundIsOver = true;   
                    }
                }


                public void mission15_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    if (action_type == "kick"){
                        mission15_KickCounter++;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission15_RoundOver(){
                        mission15_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a_mission15_punch(){
                        mission15_PunchCounter++;
                    }

                    public void a_mission15_kick(){
                        mission15_KickCounter++;
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 15



            //Weekly Mission ID = 16        || Win a round with less than 10% health remaining
            #region
                //Functions used: mission16_RoundHasEnded()
                public static bool mission16_PlayerHealthLessThan10 = false;
                public void mission16_weekly(){
                    Debug.LogWarning("Mission16 Called");

                    if (mission16_PlayerHealthLessThan10 == true){
                        instantiate_completedMissionCanvas(16);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(16);     //For registering the completed mission with the ID

                        Debug.Log("Mission16 done"); 
                    }
                }

                public static int mission16_PlayerHealth = 5;
                public void mission16_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){   //Round has Ended, Param should be Player's final health, and Current Round
                    mission16_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission16_PlayerHealth < 10)){     //Check if final round and the health is not less than 60
                        mission16_PlayerHealthLessThan10 = true;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission16_RoundOver(){
                        mission16_RoundHasEnded(1, "player_won", 5, 50, "C", 100);
                    }
                #endregion                                    

            #endregion
            //END OF Weekly Mission ID = 16



            //Weekly Mission ID = 17        || Achieve a win streak of 5 matches in a row
            #region
                //Functions used: mission17_RoundHasEnded(), mission17_MatchHasEnded()
                public static int mission17_WinStreakOf5Matches = 0, mission17_MissionSearch_Index = 0, mission17_TotalRounds = 3, mission17_CountRoundWins = 0;
                public static string mission17_MissionSearch = "", mission17_SearchTerm = "Mission17";
                public static bool mission17_MatchIsEnded = false;

                public void mission17_weekly(){
                    Debug.LogWarning("Mission17 Called");
                    Player_missionProgress = LoadPlayer_MissionData();

                    mission17_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission17_SearchTerm));
                    mission17_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission17_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission17_MissionSearch != null){
                        mission17_WinStreakOf5Matches = int.Parse(getMissionValue(mission17_MissionSearch));

                        Debug.LogWarning("Miss17 " + mission17_WinStreakOf5Matches.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission17: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }


                    if (mission17_WinStreakOf5Matches == 5){
                        instantiate_completedMissionCanvas(17);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(17);

                        Debug.LogWarning("Mission17 Completed!");
                    }
                }

                public void mission17_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //If Won
                    if (round_status == "player_won"){
                        mission17_CountRoundWins++;
                    }
                }

                public void mission17_MatchHasEnded(){
                    // mission17_MatchIsEnded = true;

                    //If all Rounds are Won in 1 Match
                    if (mission17_CountRoundWins == mission17_TotalRounds){
                        mission17_WinStreakOf5Matches++;

                        Player_missionProgress.completed_missions_inprogress[mission17_MissionSearch_Index] = "Mission17: " + mission17_WinStreakOf5Matches.ToString();
                        SavePlayer_MissionData(Player_missionProgress);
                        Debug.LogWarning("Total WinStreak Mission17 = " + mission17_WinStreakOf5Matches.ToString());
                    }
                    else{
                        //Reset the Win Streak if all rounds are not won in a match
                        mission17_WinStreakOf5Matches = 0;

                        Player_missionProgress.completed_missions_inprogress[mission17_MissionSearch_Index] = "Mission17: 0";
                        SavePlayer_MissionData(Player_missionProgress);
                        Debug.LogWarning("Total WinStreak Mission17 = " + mission17_WinStreakOf5Matches.ToString());
                    }

                    mission17_CountRoundWins = 0;
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission17_MatchEnd(){
                        mission17_MatchHasEnded();
                    }

                    public void a_mission17_RoundEnd(){
                        mission17_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                #endregion

            #endregion
            //END OF Weekly Mission ID = 17



            //Weekly Mission ID = 18        || Watch 2 Ads
            #region
                //Functions used: mission18_AdsWatchedIncrement
                public static string mission18_MissionSearch = "", mission18_SearchTerm = "Mission18";
                public static int mission18_AdsWatchedCount, mission18_MissionSearch_Index;
                public void mission18_weekly(){
                    Debug.LogWarning("Mission18 Called");

                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3dx = ListToString(Player_missionProgress.completed_missions_inprogress);
                    Debug.LogWarning("Completed Missions18 In Progress: " + result3dx);

                    mission18_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission18_SearchTerm));
                    mission18_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission18_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission18_MissionSearch != null){
                        mission18_AdsWatchedCount = int.Parse(getMissionValue(mission18_MissionSearch));

                        Debug.LogWarning("Miss " + mission18_AdsWatchedCount.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission18: 0");
                        SavePlayer_MissionData(Player_missionProgress);
                    }

                    if (mission18_AdsWatchedCount == 2){
                        instantiate_completedMissionCanvas(18);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(18);

                        Debug.LogWarning("Mission18 Completed!");
                    }
                }

                public void mission18_AdsWatchedIncrement(){
                    mission18_AdsWatchedCount++;
                    Player_missionProgress.completed_missions_inprogress[mission18_MissionSearch_Index] = "Mission18: " + mission18_AdsWatchedCount.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total Ads Watched Mission18 = " + mission18_AdsWatchedCount.ToString());
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission18_AddAds(){
                        AdsWatched();
                        // mission18_AdsWatchedIncrement();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 18



            //Weekly Mission ID = 19        || Reach 300 XP
            #region
                public void mission19_weekly(){
                    //Retrieve XP of the player, then check if reaches the expected value, i.e 300 XP

                    Debug.LogError("Mission19 " + (playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    if ((playerData.xp >= 3000) && (playerData.xp <= 4000)){
                        instantiate_completedMissionCanvas(19);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(19);     //For registering the completed mission with the ID
                        Debug.Log("Mission19 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 19



            //Weekly Mission ID = 20        || Rank up to Level 2 Silver.
            #region
                public void mission20_weekly(){
                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 2) && (playerData.rank == "Silver")){
                        instantiate_completedMissionCanvas(20);
                        game_statsManager.updateMission(20);
                        
                        Debug.Log("Mission20 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 20

        #endregion
        //END OF MONTH 1




        //MONTH 2,  ID 21 - 40
        #region

            //Weekly Mission ID = 21        || Win a match without walking around
            #region
                //Functions used: mission21_RoundHasStarted, mission21_RoundHasEnded(), mission21_MatchHasStarted, mission21_MatchHasEnded(), mission21_PlayerHasWalked()
                public static bool mission21_PlayerWalkStatus = false, mission21_MatchIsEndedWonMatch = false;
                public static int mission21_TotalRounds = 3, mission21_CountRoundWins = 0;
                    
                public void mission21_weekly(){
                    Debug.LogWarning("Mission21x PlayerMovedStatus = " + mission21_PlayerWalkStatus);

                    if ((mission21_MatchIsEndedWonMatch == true) && (mission21_PlayerWalkStatus == false)){     //If match was won and player has not walked
                        instantiate_completedMissionCanvas(21);
                        game_statsManager.updateMission(21);
                        
                        Debug.Log("Mission21 done");             //Show which mission is done   
                    }
                }

                public void mission21_RoundHasStarted(){
                    mission21_PlayerWalkStatus = false;   
                }

                public void mission21_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //If Won
                    if (round_status == "player_won"){
                        mission21_CountRoundWins++;
                    }
                }

                //Player has moved
                public void mission21_PlayerHasWalked(){
                    mission21_PlayerWalkStatus = true;
                }

                public void mission21_MatchHasStarted(){
                    mission21_MatchIsEndedWonMatch = false;
                    mission21_CountRoundWins = 0;
                } 

                public void mission21_MatchHasEnded(){
                    if (mission21_CountRoundWins == mission21_TotalRounds){ //A match has been Won
                        mission21_MatchIsEndedWonMatch = true;  //If match has been Won
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission21_PlayerMoved(){
                        PlayerHasMoved();
                    }

                    public void a_mission21_MatchEnd(){
                        mission21_MatchHasEnded();
                    }

                    public void a_mission21_RoundOver(){
                        mission21_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 21



            //Weekly Mission ID = 22        || Watch 10 Ads
            #region
                public static string mission22_MissionSearch = "", mission22_SearchTerm = "Mission22";
                public static int mission22_AdsWatchedCount, mission22_MissionSearch_Index;
                public void mission22_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3d = ListToString(Player_missionProgress.completed_missions_inprogress);
                    Debug.LogWarning("Completed Missions In Progress: " + result3d);

                    mission22_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission22_SearchTerm));
                    mission22_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission22_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission22_MissionSearch != null){
                        mission22_AdsWatchedCount = int.Parse(getMissionValue(mission22_MissionSearch));

                        Debug.LogWarning("Miss " + mission22_AdsWatchedCount.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission22: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }

                    if (mission22_AdsWatchedCount == 10){
                        instantiate_completedMissionCanvas(22);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(22);

                        Debug.LogWarning("Mission22 Completed!");
                    }

                }

                public void mission22_AdsWatchedIncrement(){
                    mission22_AdsWatchedCount++;
                    Player_missionProgress.completed_missions_inprogress[mission22_MissionSearch_Index] = "Mission22: " + mission22_AdsWatchedCount.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total Ads Watched Mission22 = " + mission22_AdsWatchedCount.ToString());
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission22_AddAds(){
                        AdsWatched();
                        // mission22_AdsWatchedIncrement();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 22



            //Weekly Mission ID = 23        || Achieve a perfect round using only kicks
            #region
                //Functions used: mission23_RoundHasStarted(), mission23_RoundHasEnded(), mission23_PlayerHasHitEnemy()
                public static int mission23_PunchCounter = 0, mission23_KickCounter = 0, mission23_PlayerHealth = 100;
                public static bool mission23_RoundIsOverPerfectWin = false;
                public void mission23_weekly(){
                    Debug.LogWarning("23Kick = " + mission23_KickCounter.ToString() + " Punch = " + mission23_PunchCounter.ToString());

                    if (mission23_RoundIsOverPerfectWin == true){    //If Round is Over and Player has Perfect Health
                        if (mission23_PunchCounter == 0){    //Only Kicks were used, No Punches
                            instantiate_completedMissionCanvas(23);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(23);

                            Debug.LogWarning("Mission23 Completed!");
                        }
                    }
                }

                public void mission23_RoundHasStarted(){
                    mission23_PunchCounter = 0;
                    mission23_KickCounter = 0;
                    mission23_RoundIsOverPerfectWin = false;
                }



                public void mission23_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    mission23_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission23_PlayerHealth >= 95)){
                        mission23_RoundIsOverPerfectWin = true;
                    }
                }


                public void mission23_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    if (action_type == "punch"){
                        mission23_PunchCounter++;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission23_RoundOver(){
                        mission23_RoundHasEnded(1, "player_won", 100, 50, "C", 100);
                    }

                    public void a_mission23_punch(){
                        mission23_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }

                    public void a_mission23_kick(){
                        mission23_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 23



            //Weekly Mission ID = 24        || Win a round sustaining less than 5 hits from opponent
            #region
                //Functions used: mission24_RoundHasStarted(), mission24_RoundHasEnded(), mission24_EnemyHasHitPlayer()
                public static bool mission24_RoundIsOverWon = false;
                public static int mission24_EnemyHitsPlayer_Counter = 0;
                public void mission24_weekly(){
                    Debug.LogWarning("EnemyHits = " + mission24_EnemyHitsPlayer_Counter.ToString());

                    if ((mission24_RoundIsOverWon == true) && (mission24_EnemyHitsPlayer_Counter < 5)){
                        instantiate_completedMissionCanvas(24);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(24);

                        Debug.LogWarning("Mission24 Completed!");
                    }
                }

                public void mission24_RoundHasStarted(){
                    mission24_RoundIsOverWon = false;
                    mission24_EnemyHitsPlayer_Counter = 0;
                }

                public void mission24_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){
                        mission24_RoundIsOverWon = true;
                    }
                }

                public void mission24_EnemyHasHitPlayer(){
                    mission24_EnemyHitsPlayer_Counter++;
                }


                #region
                    public void a_mission24_RoundOver(){
                        mission24_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a_mission24_EnemyHit(){
                        mission24_EnemyHitsPlayer_Counter++;
                    }

                #endregion

            #endregion
            //END OF Weekly Mission ID = 24



            //Weekly Mission ID = 25        || Win a match using only punches
            #region
                //Functions used: mission25_RoundHasStarted(), mission25_RoundHasEnded(), mission25_MatchHasStarted(), mission25_MatchHasEnded(), mission25_PlayerHasHitEnemy()
                public static int mission25_PunchCounter = 0, mission25_KickCounter = 0, mission25_TotalRounds = 3, mission25_CountRoundWins = 0;
                public static bool mission25_MatchIsEndedWonMatch = false;
                public void mission25_weekly(){
                    Debug.LogWarning("25Kick = " + mission25_KickCounter.ToString() + " Punch = " + mission25_PunchCounter.ToString());

                    if (mission25_MatchIsEndedWonMatch == true){    //If Match is Over
                        instantiate_completedMissionCanvas(25);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(25);

                        Debug.LogWarning("Mission25 Completed!");
                    }
                }

                public void mission25_RoundHasStarted(){
                    mission25_PunchCounter = 0;
                    mission25_KickCounter = 0;
                }


                public void mission25_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //If Won
                    if ((round_status == "player_won") && (mission25_KickCounter == 0)){
                        mission25_CountRoundWins++;
                    }
                }

                public void mission25_MatchHasStarted(){
                    mission25_MatchIsEndedWonMatch = false;
                    mission25_CountRoundWins = 0;
                } 

                public void mission25_MatchHasEnded(){
                    // mission25_MatchIsEnded = true;

                    if (mission25_CountRoundWins == mission25_TotalRounds){ //A match has been Won
                        mission25_MatchIsEndedWonMatch = true;  //If match has been Won
                    }
                }

                public void mission25_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    if (action_type == "kick"){
                        mission25_KickCounter++;
                    }
                }



                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission25_RoundOver(){
                        mission25_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a_mission25_MatchOver(){
                        mission25_MatchHasEnded();
                    }

                    public void a_mission25_punch(){
                        mission25_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }

                    public void a_mission25_kick(){
                        mission25_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 25



            //Weekly Mission ID = 26        || Win a match with not less than 60% health in the final round
            #region
                //Functions used: mission26_RoundHasEnded(), mission26_MatchHasStarted(), mission26_MatchHasEnded()
                public static bool mission26_LastRoundPlayerHealthOver60 = false, mission26_CompleteFlag = false;
                public static int mission26_TotalRounds = 3, mission26_CountRoundWins = 0;    //Total Rounds in each Match
                public void mission26_weekly(){
                    if (mission26_CompleteFlag == true){
                        instantiate_completedMissionCanvas(26);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(26);     //For registering the completed mission with the ID

                        Debug.Log("Mission26 done"); 
                    }
                }

                public void mission26_MatchHasStarted(){
                    mission26_CountRoundWins = 0;
                    mission26_LastRoundPlayerHealthOver60 = false;
                }

                public static int mission26_PlayerHealth = 60;
                public void mission26_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){   //Round has Ended, Param should be Player's final health, and Current Round
                    mission26_PlayerHealth = playerHealth;

                    if (round_status == "player_won"){
                        mission26_CountRoundWins++;
                    }

                    //If current number is the final round and the health is greater than 60
                    if ((roundNum == mission26_TotalRounds) && (mission26_PlayerHealth >= 60)){     //Check if final round and the health is not less than 60
                        mission26_LastRoundPlayerHealthOver60 = true;
                    }
                }

                public void mission26_MatchHasEnded(){
                    if (mission26_CountRoundWins == mission26_TotalRounds){ //If all rounds were Won
                        if (mission26_LastRoundPlayerHealthOver60 == true){ //If won last round with 60 health
                            mission26_CompleteFlag = true;
                        }
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission26_RoundOver(){
                        mission26_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 26



            //Weekly Mission ID = 27        || Perform Punch-Kick-Kick combo (PKK)
            #region
                //Functions used: mission27_RoundHasStarted(), mission27_EnemyHasHitPlayer(), mission27_PlayerHasHitEnemy()
                public static string punch_kick_kick_Combo = "";

                public void mission27_weekly(){
                    Debug.LogWarning("PKK value = " + punch_kick_kick_Combo);

                    if (punch_kick_kick_Combo == "PKK"){
                        instantiate_completedMissionCanvas(27);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(27);

                        Debug.LogWarning("PKK Combo achieved!");                  
                    }
                }

                public void mission27_RoundHasStarted(){
                    punch_kick_kick_Combo = "";
                }

                public void mission27_EnemyHasHitPlayer(){
                    punch_kick_kick_Combo = "";
                }

                public void mission27_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    mission27_CheckCombo(action_type);
                }



                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission27_Player_kick(){
                        mission27_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }

                    public void a_mission27_Player_punch(){
                        mission27_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }

                    public void a_mission27_Enemy_punch(){
                        mission27_EnemyHasHitPlayer();
                    }
                #endregion


                public void mission27_CheckCombo(string action_performed){  //Looking for PKK
                    string action_done_initial = (action_performed == "punch") ? "P" : "K";

                    switch(punch_kick_kick_Combo){
                        //First letter
                        case "":
                            if (action_done_initial == "K"){
                                punch_kick_kick_Combo = "";
                                break;
                            }else{
                                // Add the first "K"
                                punch_kick_kick_Combo += "P";
                                break;
                            }

                        //Second letter
                        case "P":
                            if (action_done_initial == "P"){
                                punch_kick_kick_Combo = "";
                                break;
                            }else{
                                // Add the "P"
                                punch_kick_kick_Combo += "K";
                                break;
                            }
                            
                        //Third letter
                        case "PK":
                            if (action_done_initial == "P"){
                                punch_kick_kick_Combo = "";
                                break;
                            }else{
                                // Add the last "K"
                                punch_kick_kick_Combo += "K";
                                break;
                            }
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 27



            //Weekly Mission ID = 28        || Reach 500 XP
            #region
                public void mission28_weekly(){
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 5000){
                        instantiate_completedMissionCanvas(28);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(28);     //For registering the completed mission with the ID

                        Debug.Log("Mission28 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 28



            //Weekly Mission ID = 29        || Rank up to Level 2 Gold
            #region
                public void mission29_weekly(){
                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 2) && (playerData.rank == "Gold")){
                        instantiate_completedMissionCanvas(29);
                        game_statsManager.updateMission(29);
                        
                        Debug.Log("Mission29 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 29



            //Weekly Mission ID = 30        || Complete this week�s missions
            #region
                public void mission30_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 26 && mission <= 29);
                    if (count >= 4){
                        instantiate_completedMissionCanvas(30);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(30);

                        Debug.LogWarning("Mission30 Completed");
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int missID2 = 26;
                    public void a_mission30_missionDone(){
                        instantiate_completedMissionCanvas(missID2);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(missID2);

                        missID2++;
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 30



            //Weekly Mission ID = 31        || Complete a round in under 30 seconds
            #region
                //Functions used: mission31_RoundHasStarted(), mission31_RoundHasEnded(), mission31_MatchHasEnded()
                public static bool mission31_RoundUnder30Seconds = false;
                public static float mission31_RoundTime = 0, mission31_RoundStartTime = 0, mission31_RoundEndTime = 0;   // Time when the scene started

                public void mission31_weekly(){
                    Debug.LogWarning("RStT = " + mission31_RoundStartTime + " REndT = " + mission31_RoundEndTime + " OvTM = " + mission31_RoundUnder30Seconds);

                    if (mission31_RoundUnder30Seconds == true){
                        instantiate_completedMissionCanvas(31);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(31);

                        Debug.LogWarning("Mission31 Completed");
                    }
                }

                public void mission31_RoundHasStarted(){
                    // Record the time when the scene starts
                    mission31_RoundStartTime = Time.time;
                    // Debug.LogWarning("StartTime =");
                }

                public void mission31_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //Stop Time Count
                    //Take Start and Stop Time, Add this time to see time used in Each Round
                    mission31_RoundEndTime = Time.time;
                    mission31_RoundTime = mission31_RoundEndTime - mission31_RoundStartTime;    //Total Time Used in Round

                    if (mission31_RoundTime < 30){
                        mission31_RoundUnder30Seconds = true;
                    }
                }

                #region
                    public void aa_mission31_RoundStart(){
                        mission31_RoundHasStarted();
                    }

                    public void aa_mission31_RoundEnd(){
                        mission31_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    // public void aa_mission51_MatchEnd(){
                    //     mission31_MatchHasEnded();
                    // }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 31



            //Weekly Mission ID = 32        || Watch 5 Ads
            #region
                //Functions used: mission32_AdsWatchedIncrement()
                public static string mission32_MissionSearch = "", mission32_SearchTerm = "Mission32";
                public static int mission32_AdsWatchedCount, mission32_MissionSearch_Index;
                public void mission32_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3dx = ListToString(Player_missionProgress.completed_missions_inprogress);
                    Debug.LogWarning("Completed Missions32 In Progress: " + result3dx);

                    mission32_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission32_SearchTerm));
                    mission32_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission32_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission32_MissionSearch != null){
                        mission32_AdsWatchedCount = int.Parse(getMissionValue(mission32_MissionSearch));

                        Debug.LogWarning("Miss " + mission32_AdsWatchedCount.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission32: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }

                    if (mission32_AdsWatchedCount == 5){
                        instantiate_completedMissionCanvas(32);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(32);

                        Debug.LogWarning("Mission32 Completed!");
                    }
                }

                public void mission32_AdsWatchedIncrement(){
                    mission32_AdsWatchedCount++;
                    Player_missionProgress.completed_missions_inprogress[mission32_MissionSearch_Index] = "Mission32: " + mission32_AdsWatchedCount.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total Ads Watched Mission32 = " + mission32_AdsWatchedCount.ToString());
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a1_mission32_AddAds(){
                        AdsWatched();
                        // mission52_AdsWatchedIncrement();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 32



            //Weekly Mission ID = 33        || Achieve a win with less than 5% health remaining in each round
            #region
                //Functions used: mission33_RoundHasEnded(), mission33_MatchHasEnded()
                public static int mission33_TotalRounds = 3, mission33_RoundsCountWinWithLessThan5Health = 0;
                public static bool mission33_WinLess5EachRound = false;
                public void mission33_weekly(){
                    if (mission33_WinLess5EachRound == true){
                        instantiate_completedMissionCanvas(33);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(33);     //For registering the completed mission with the ID
                        Debug.Log("Mission33 done");             //Show which mission is done
                    }
                }


                public static int mission33_PlayerHealth = 4;
                public void mission33_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    mission33_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission33_PlayerHealth < 5)){
                        mission33_RoundsCountWinWithLessThan5Health++;
                    }
                }

                public void mission33_MatchHasEnded(){
                    if (mission33_RoundsCountWinWithLessThan5Health == mission33_TotalRounds){
                        mission33_WinLess5EachRound = true;
                    }else{  //If not all rounds are won
                        mission33_RoundsCountWinWithLessThan5Health = 0;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission33_RoundEnd(){
                        mission33_RoundHasEnded(1, "player_won", 3, 50, "Cheetah(Clone)", 100);
                    }

                    public void a_mission33_MatchEnd(){
                        mission33_MatchHasEnded();
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 33



            //Weekly Mission ID = 34        || Win a round with more 75% health remaining
            #region
                //Functions used: mission34_RoundHasEnded()
                public static bool mission34_PlayerHealthMoreThan75 = false;
                public void mission34_weekly(){
                    if (mission34_PlayerHealthMoreThan75 == true){
                        instantiate_completedMissionCanvas(34);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(34);     //For registering the completed mission with the ID
                        Debug.Log("Mission34 done");             //Show which mission is done
                    }
                }

                public static int mission34_PlayerHealth = 80;
                public void mission34_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    mission34_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission34_PlayerHealth > 75)){
                        if (mission34_PlayerHealthMoreThan75 == false){
                            mission34_PlayerHealthMoreThan75 = true;
                        }
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission34_RoundOver(){
                        mission34_RoundHasEnded(1, "player_won", 80, 50, "Cheetah(Clone)", 100);
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 34



            //Weekly Mission ID = 35        || Complete this week�s missions
            #region
                public void mission35_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 31 && mission <= 34);
                    if (count >= 4){
                        instantiate_completedMissionCanvas(35);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(35);

                        Debug.LogWarning("Mission35 Completed");
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int missID3 = 31;
                    public void a_mission35_missionDone(){
                        instantiate_completedMissionCanvas(missID3);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(missID3);

                        missID3++;
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 35



            //Weekly Mission ID = 36        || Play different matches for a total of 30 minutes
            #region
                //Count time here
                // public static bool mission36_MatchesTotalOf30Minutes = false;
                public static float mission36_MatchStartTime = 0, mission36_MatchEndTime = 0, mission36_CalculatedMatchTime = 0, mission36_OverallTimeInMatch = 0;
                public static string mission36_MissionSearch = "", mission36_SearchTerm = "Mission36";
                public static int mission36_TimeRetrieved, mission36_MissionSearch_Index;

                public void mission36_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    Debug.LogWarning("RStT = " + mission36_MatchStartTime + " REndT = " + mission36_MatchEndTime + " TDiff = " + mission36_CalculatedMatchTime);

                    // string result3dx = ListToString(Player_missionProgress.completed_missions_inprogress);
                    // Debug.LogWarning("Completed Missions37 In Progress: " + result3dx);

                    mission36_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission36_SearchTerm));
                    mission36_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission36_SearchTerm));

                    //If the Mission exists, value has been saved
                    if (mission36_MissionSearch != null){
                        mission36_OverallTimeInMatch = float.Parse(getMissionValue(mission36_MissionSearch));

                        Debug.LogWarning("Miss36 " + mission36_OverallTimeInMatch.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission36: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL2 No Results");
                    }

                    if (mission36_OverallTimeInMatch >= 1800){     //30 minutes
                        instantiate_completedMissionCanvas(36);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(36);

                        Debug.LogWarning("Mission36 Completed!");
                    }

                }

                public void mission36_MatchHasStarted(){
                    mission36_MatchStartTime = Time.time;
                }

                public void mission36_MatchHasEnded(){
                    mission36_MatchEndTime = Time.time;
                    mission36_CalculatedMatchTime = mission36_MatchEndTime - mission36_MatchStartTime;
                    mission36_OverallTimeInMatch = mission36_OverallTimeInMatch + mission36_CalculatedMatchTime;

                    Player_missionProgress.completed_missions_inprogress[mission36_MissionSearch_Index] = "Mission36: " + mission36_OverallTimeInMatch.ToString();
                    SavePlayer_MissionData(Player_missionProgress);
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission36_MatchStart(){
                        mission36_MatchHasStarted();
                    }


                    public void a_mission36_MatchOver(){
                        mission36_MatchHasEnded();
                    }

                #endregion

            #endregion
            //END OF Weekly Mission ID = 36



            //Weekly Mission ID = 37        || Watch 15 Ads
            #region
                //Functions used: mission37_AdsWatchedIncrement()
                public static string mission37_MissionSearch = "", mission37_SearchTerm = "Mission37";
                public static int mission37_AdsWatchedCount, mission37_MissionSearch_Index;
                public void mission37_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3dx = ListToString(Player_missionProgress.completed_missions_inprogress);
                    Debug.LogWarning("Completed Missions37 In Progress: " + result3dx);

                    mission37_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission37_SearchTerm));
                    mission37_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission37_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission37_MissionSearch != null){
                        mission37_AdsWatchedCount = int.Parse(getMissionValue(mission37_MissionSearch));

                        Debug.LogWarning("Miss " + mission37_AdsWatchedCount.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission37: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }

                    if (mission37_AdsWatchedCount == 15){
                        instantiate_completedMissionCanvas(37);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(37);

                        Debug.LogWarning("Mission37 Completed!");
                    }
                }

                public void mission37_AdsWatchedIncrement(){
                    mission37_AdsWatchedCount++;
                    Player_missionProgress.completed_missions_inprogress[mission37_MissionSearch_Index] = "Mission37: " + mission37_AdsWatchedCount.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total Ads Watched Mission37 = " + mission37_AdsWatchedCount.ToString());
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission37_AddAds(){
                        AdsWatched();
                        // mission37_AdsWatchedIncrement();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 37



            //Weekly Mission ID = 38        || Perform Punch-Punch-Kick attack (PPK)
            #region
                //Functions used: mission38_RoundHasStarted(), mission38_EnemyHasHitPlayer(), mission38_PlayerHasHitEnemy()
                public static string punch_punch_kick_Combo = "";

                public void mission38_weekly(){
                    Debug.LogWarning("PPK value = " + punch_punch_kick_Combo);

                    if (punch_punch_kick_Combo == "PPK"){
                        instantiate_completedMissionCanvas(38);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(38);

                        Debug.LogWarning("PPK Combo achieved!");                  
                    }
                }

                public void mission38_RoundHasStarted(){
                    punch_punch_kick_Combo = "";
                }

                public void mission38_EnemyHasHitPlayer(){
                    punch_punch_kick_Combo = "";
                }

                public void mission38_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    mission38_CheckCombo(action_type);
                }



                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission38_Player_kick(){
                        mission38_PlayerHasHitEnemy("kick", "Player(Clone)", 100);
                    }

                    public void a_mission38_Player_punch(){
                        mission38_PlayerHasHitEnemy("punch", "Player(Clone)", 100);
                    }

                    public void a_mission38_Enemy_punch(){
                        mission38_EnemyHasHitPlayer();
                    }
                #endregion


                public void mission38_CheckCombo(string action_performed){  //Looking for PPK      KPK
                    string action_done_initial = (action_performed == "punch") ? "P" : "K";

                    switch(punch_punch_kick_Combo){
                        //First letter
                        case "":
                            if (action_done_initial == "K"){
                                punch_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the first "K"
                                punch_punch_kick_Combo += "P";
                                break;
                            }

                        //Second letter
                        case "P":
                            if (action_done_initial == "K"){
                                punch_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the "P"
                                punch_punch_kick_Combo += "P";
                                break;
                            }
                            
                        //Third letter
                        case "PP":
                            if (action_done_initial == "P"){
                                punch_punch_kick_Combo = "";
                                break;
                            }else{
                                // Add the last "K"
                                punch_punch_kick_Combo += "K";
                                break;
                            }
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 38



            //Weekly Mission ID = 39        || Reach 700 XP
            #region
                public void mission39_weekly(){
                    //Retrieve XP of the player, then check if reaches the expected value, i.e 300 XP

                    Debug.LogError("Mission39 " + (playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    if (playerData.xp >= 7000){
                        instantiate_completedMissionCanvas(39);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(39);     //For registering the completed mission with the ID
                        Debug.Log("Mission39 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 39



            //Weekly Mission ID = 40        || Rank up to Level 1 Platinum
            #region
                public void mission40_weekly(){
                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 1) && (playerData.rank == "Platinum")){
                        instantiate_completedMissionCanvas(40);
                        game_statsManager.updateMission(40);
                        
                        Debug.Log("Mission40 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 40

        #endregion
        //END OF MONTH 2



        //MONTH 3,  ID 41 - 60
        #region

            //Weekly Mission ID = 41        || Perform a combo that does at least 30% damage
            #region
                //Functions used: mission41_PlayerHasHitEnemy(), mission41_EnemyHasHitPlayer()
                public static int mission41_EnemyHealthBeforeCombo = 0, mission41_EnemyHealthAfterCombo = 0, mission41_30DamageFromCombo = 0, mission41_EnemyHealthFirstContact = 0;
                public static bool mission41_firstContact = false; 
                public void mission41_weekly(){
                    Debug.LogWarning("M41 || BC = " + mission41_EnemyHealthFirstContact.ToString() + " AC = " + mission41_EnemyHealthAfterCombo.ToString() + 
                        " ComboDamage = " + mission41_30DamageFromCombo.ToString());

                    if (mission41_30DamageFromCombo >= 30){ //Damage of 30 from combo
                        instantiate_completedMissionCanvas(41);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(41);     //For registering the completed mission with the ID
                        Debug.Log("Mission41 done");
                    }
                }

                public void mission41_RoundHasStarted(){
                    mission41_EnemyHealthBeforeCombo = 0;
                    mission41_EnemyHealthAfterCombo = 0;
                    mission41_30DamageFromCombo = 0;

                }

                // public void mission41_PlayerHasHitEnemy(string action_type, string action_source, int playerHealth)
                public void mission41_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){  //Get Enemy Health before Player starts to hit Enemy
                    
                    //First contact with enemy
                    if (mission41_firstContact == false){
                        mission41_EnemyHealthFirstContact = enemyHealth;
                        mission41_firstContact = true; //Not first contact anymore
                    }else{
                        mission41_EnemyHealthAfterCombo = enemyHealth;
                    }

                    mission41_30DamageFromCombo = mission41_EnemyHealthFirstContact - mission41_EnemyHealthAfterCombo;
                }

                public void mission41_EnemyHasHitPlayer(){  //Get Enemy Health at this instant
                    mission41_firstContact = false;

                    // mission41_EnemyHealthAfterCombo = enemyHealth_end;
                    // mission41_30DamageFromCombo = mission41_EnemyHealthBeforeCombo - mission41_EnemyHealthAfterCombo;
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public static List<int> enemyH_before = new List<int>(){ 100, 90, 70, 50  };
                    public static List<int> enemyH_after = new List<int>(){ 90, 85, 50, 20 };
                    public static int incr = 0;

                    public void a_mission41_PlayerHit(){
                        // mission41_PlayerHasHitEnemy(80);
                        // mission41_PlayerHasHitEnemy(enemyH_before[incr]);
                        incr++;
                    }

                    public void a_mission41_EnemyHit(){
                        // mission41_EnemyHasHitPlayer(30);
                        mission41_EnemyHasHitPlayer();

                        // mission41_EnemyHasHitPlayer(enemyH_after[incr]);
                        // incr++;
                    }

                    public void a_mission41_RoundStart(){
                        mission41_RoundHasStarted();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 41



            //Weekly Mission ID = 42        || Win a round with a health difference of less than 10% between you and your opponent.
            #region
                //Functions used: mission42_RoundHasStarted(), mission42_RoundHasEnded()
                public static int mission42_HealthDifference = 0;
                public void mission42_weekly(){
                    Debug.LogWarning("HDiff = " + mission42_HealthDifference.ToString());

                    if ((mission42_HealthDifference >= 7) && (mission42_HealthDifference <= 10)){  //If health difference at the end of round is  btn 7 and 10
                        instantiate_completedMissionCanvas(42);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(42);     //For registering the completed mission with the ID
                        Debug.Log("Mission42 done");
                    }
                }

                public static void mission42_RoundHasStarted(){
                    mission42_HealthDifference = 0;
                }

                public static int mission42_PlayerHealth = 10, mission42_EnemyHealth = 0;
                public void mission42_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){  //Player has Won
                        mission42_HealthDifference = mission42_PlayerHealth - mission42_EnemyHealth;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission42_RoundOver(){
                        mission42_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                        // endOfEachRound(1, "player_won");
                    }

                    public void a_mission42_RoundStart(){
                        mission42_RoundHasStarted();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 42



            //Weekly Mission ID = 43        || Reach 800 XP
            #region
                public void mission43_weekly(){
                    Debug.Log("Mission43 Called");

                    // Debug.LogError((playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 8000){
                        instantiate_completedMissionCanvas(43);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(43);     //For registering the completed mission with the ID
                        Debug.Log("Mission43 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 43



            //Weekly Mission ID = 44        || Rank up to Level 3 Platinum
            #region
                public void mission44_weekly(){
                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 3) && (playerData.rank == "Platinum")){
                        instantiate_completedMissionCanvas(44);
                        game_statsManager.updateMission(44);
                        
                        Debug.Log("Mission44 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 44



            //Weekly Mission ID = 45        || Complete week 1 missions
            #region
                public void mission45_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3 = ListToString(Player_missionProgress.completed_missions);
                    Debug.LogWarning("Completed Missions: " + result3);

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 41 && mission <= 44);

                    Debug.LogWarning("missionID45_counter " + count.ToString());

                    if (count >= 4){
                        instantiate_completedMissionCanvas(45);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(45);

                        Debug.LogWarning("Mission45 Completed");
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 45



            //Weekly Mission ID = 46        || Achieve a win streak of 7 matches in a row
            #region
                //Functions used: mission46_RoundHasEnded(), mission46_MatchHasEnded()
                public static int mission46_WinStreakOf5Matches = 0, mission46_MissionSearch_Index = 0, mission46_RoundWinCount = 0, mission46_TotalRounds = 3;
                public static string mission46_MissionSearch = "", mission46_SearchTerm = "Mission46";
                public static bool mission46_MatchIsEnded = false;

                // public static bool mission17_WinStreakOf5Matches = false;
                public void mission46_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    mission46_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission46_SearchTerm));
                    mission46_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission46_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission46_MissionSearch != null){
                        mission46_WinStreakOf5Matches = int.Parse(getMissionValue(mission46_MissionSearch));

                        Debug.LogWarning("Miss46 " + mission46_WinStreakOf5Matches.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission46: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }


                    if (mission46_WinStreakOf5Matches == 7){
                        instantiate_completedMissionCanvas(46);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(46);

                        Debug.LogWarning("Mission46 Completed!");
                    }
                }

                public void mission46_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){
                        mission46_RoundWinCount++;
                    }
                }

                public void mission46_MatchHasEnded(){
                    // mission17_MatchIsEnded = true;
                    if (mission46_RoundWinCount == mission46_TotalRounds){
                        mission46_WinStreakOf5Matches++;
                        
                    }else{
                        mission46_WinStreakOf5Matches = 0;
                    }

                    mission46_RoundWinCount = 0;    //Reset for the next round

                    Player_missionProgress.completed_missions_inprogress[mission46_MissionSearch_Index] = "Mission46: " + mission46_WinStreakOf5Matches.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total WinStreak Mission46 = " + mission46_WinStreakOf5Matches.ToString());
                }



                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission46_MatchOver(){
                        mission46_MatchHasEnded();
                    }

                    public void a_mission46_RoundOver(){
                        mission46_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 46



            //Weekly Mission ID = 47        || Win each round your character's health below 25%
            #region
                //Functions used: mission47_RoundHasEnded(), mission47_MatchHasEnded()
                public static int mission47_TotalRounds = 3, mission47_RoundsCountWinWithLessThan25Health = 0;
                public static bool mission47_WinMatchComplete = false;
                public void mission47_weekly(){
                    if (mission47_WinMatchComplete == true){
                        instantiate_completedMissionCanvas(47);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(47);     //For registering the completed mission with the ID
                        Debug.Log("Mission47 done");             //Show which mission is done
                    }
                }


                public static int mission47_PlayerHealth = 24;
                public void mission47_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    mission47_PlayerHealth = playerHealth;
                    if ((round_status == "player_won") && (mission47_PlayerHealth < 25)){   //If Player Won and Health is less than 25
                        mission47_RoundsCountWinWithLessThan25Health++;
                    }
                }

                public void mission47_MatchHasEnded(){
                    if (mission47_RoundsCountWinWithLessThan25Health == mission47_TotalRounds){
                        mission47_WinMatchComplete = true;
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission47_RoundHasEnded(){
                        mission47_RoundHasEnded(1, "player_won", 20, 50, "Cheetah(Clone)", 100);
                    }

                    public void a_mission47_MatchOver(){
                        mission47_MatchHasEnded();
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 47



            //Weekly Mission ID = 48        || Reach 900 XP
            #region
                public void mission48_weekly(){
                    Debug.Log("Mission48 Called");

                    // Debug.LogError((playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 9000){
                        instantiate_completedMissionCanvas(48);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(48);     //For registering the completed mission with the ID
                        Debug.Log("Mission48 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 48



            //Weekly Mission ID = 49     || Rank up to Level 2 Diamond
            #region
                public void mission49_weekly(){
                    Debug.Log("Mission49 Called");

                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 2) && (playerData.rank == "Diamond")){
                        instantiate_completedMissionCanvas(49);
                        game_statsManager.updateMission(49);
                        
                        Debug.Log("Mission49 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 49



            //Weekly Mission ID = 50        || Complete week 2 missions
            #region
                public void mission50_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3 = ListToString(Player_missionProgress.completed_missions);
                    Debug.LogWarning("Completed Missions: " + result3);

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 46 && mission <= 49);

                    Debug.LogWarning("missionID50_counter " + count.ToString());

                    if (count >= 4){
                        instantiate_completedMissionCanvas(50);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(50);

                        Debug.LogWarning("Mission50 Completed");
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 50



            //Weekly Mission ID = 51        || Complete all 3 rounds in under 3 minutes
            #region
                //Functions used: mission51_RoundHasStarted(), mission51_RoundHasEnded(), mission51_MatchHasEnded()
                public static bool mission51_3RoundsUnder3Minutes = false;
                public static float mission51_RoundTime = 0, mission51_RoundStartTime = 0, mission51_RoundEndTime = 0, mission51_OverallTimeInMatch = 0;   // Time when the scene started

                public void mission51_weekly(){
                    Debug.LogWarning("RStT = " + mission51_RoundStartTime + " REndT = " + mission51_RoundEndTime + " OvTM = " + mission51_OverallTimeInMatch + " M51 = " + mission51_3RoundsUnder3Minutes);

                    if (mission51_3RoundsUnder3Minutes == true){
                        instantiate_completedMissionCanvas(51);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(51);

                        Debug.LogWarning("Mission51 Completed");
                    }
                }

                public void mission51_RoundHasStarted(){
                    // Record the time when the scene starts
                    mission51_RoundStartTime = Time.time;
                    // Debug.LogWarning("StartTime =");
                }

                public void mission51_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    //Stop Time Count
                    //Take Start and Stop Time, Add this time to see time used in Each Round
                    mission51_RoundEndTime = Time.time;
                    mission51_RoundTime = mission51_RoundEndTime - mission51_RoundStartTime;    //Total Time Used in Round
                    mission51_OverallTimeInMatch = mission51_OverallTimeInMatch + mission51_RoundTime;
                }

                public void mission51_MatchHasEnded(){
                    if (mission51_OverallTimeInMatch < 180){    //180 = 3 minutes
                        mission51_3RoundsUnder3Minutes = true;
                    }
                }

                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission51_RoundStart(){
                        mission51_RoundHasStarted();
                    }

                    public void a_mission51_RoundEnd(){
                        mission51_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a_mission51_MatchEnd(){
                        mission51_MatchHasEnded();
                    }

                #endregion

            #endregion
            //END OF Weekly Mission ID = 51



            //Weekly Mission ID = 52        || Watch 20 Ads
            #region
                //Functions used: mission52_AdsWatchedIncrement()
                public static string mission52_MissionSearch = "", mission52_SearchTerm = "Mission52";
                public static int mission52_AdsWatchedCount, mission52_MissionSearch_Index;
                public void mission52_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    string result3dx = ListToString(Player_missionProgress.completed_missions_inprogress);
                    Debug.LogWarning("Completed Missions52 In Progress: " + result3dx);

                    mission52_MissionSearch = Player_missionProgress.completed_missions_inprogress.FirstOrDefault(s => s.StartsWith(mission52_SearchTerm));
                    mission52_MissionSearch_Index = Player_missionProgress.completed_missions_inprogress.FindIndex(s => s.StartsWith(mission52_SearchTerm));

                    
                    //If the Mission exists, value has been saved
                    if (mission52_MissionSearch != null){
                        mission52_AdsWatchedCount = int.Parse(getMissionValue(mission52_MissionSearch));

                        Debug.LogWarning("Miss " + mission52_AdsWatchedCount.ToString() + " XTL");
                    }else{
                        Player_missionProgress.completed_missions_inprogress.Add("Mission52: 0");
                        SavePlayer_MissionData(Player_missionProgress);

                        Debug.LogWarning ("XTL No Results");
                    }

                    if (mission52_AdsWatchedCount == 20){
                        instantiate_completedMissionCanvas(52);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(52);

                        Debug.LogWarning("Mission52 Completed!");
                    }
                }

                public void mission52_AdsWatchedIncrement(){
                    mission52_AdsWatchedCount++;
                    Player_missionProgress.completed_missions_inprogress[mission52_MissionSearch_Index] = "Mission52: " + mission52_AdsWatchedCount.ToString();
                    SavePlayer_MissionData(Player_missionProgress);

                    Debug.LogWarning("Total Ads Watched Mission52 = " + mission52_AdsWatchedCount.ToString());
                }


                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a_mission52_AddAds(){
                        AdsWatched();
                        // mission52_AdsWatchedIncrement();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 52



            //Weekly Mission ID = 53        || Reach 1000 XP
            #region
                public void mission53_weekly(){
                    Debug.Log("Mission53 Called");

                    // Debug.LogError((playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 9000){
                        instantiate_completedMissionCanvas(53);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(53);     //For registering the completed mission with the ID

                        Debug.Log("Mission53 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 53



            //Weekly Mission ID = 54        || Rank up to Master Level
            #region
                public void mission54_weekly(){
                    Debug.Log("Mission54 Called");

                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 1) && (playerData.rank == "Master")){
                        instantiate_completedMissionCanvas(54);
                        game_statsManager.updateMission(54);
                        
                        Debug.Log("Mission54 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 54



            //Weekly Mission ID = 55        || Complete Week 3 missions
            #region
                public void mission55_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 51 && mission <= 54);
                    if (count >= 4){
                        instantiate_completedMissionCanvas(55);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(55);

                        Debug.LogWarning("Mission55 Completed");
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int missID32 = 51;
                    public void a_mission55_missionDone(){
                        instantiate_completedMissionCanvas(missID32);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(missID32);

                        missID32++;
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 55



            //Weekly Mission ID = 56        || Complete 2 rounds in under 1 minute
            #region
                //Functions used: mission51_RoundHasStarted(), mission51_RoundHasEnded(), mission51_MatchHasEnded()
                public static bool mission56_2RoundsUnder1Minutes = false;
                public static float mission56_RoundTime = 0, mission56_RoundStartTime = 0, mission56_RoundEndTime = 0, mission56_OverallTimeInMatch = 0;   // Time when the scene started

                public void mission56_weekly(){
                    Debug.LogWarning("RStT = " + mission56_RoundStartTime + " REndT = " + mission56_RoundEndTime + " OvTM = " + mission56_OverallTimeInMatch + " M51 = " + mission56_2RoundsUnder1Minutes);

                    if (mission56_2RoundsUnder1Minutes == true){
                        instantiate_completedMissionCanvas(56);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(56);

                        // Debug.LogWarning("Mission56 Completed");
                    }
                }

                public void mission56_RoundHasStarted(){
                    Debug.LogError("56 Round Started");
                    // Record the time when the scene starts
                    mission56_RoundStartTime = Time.time;
                    // Debug.LogWarning("StartTime =");
                }

                public void mission56_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    Debug.LogError("56 Round Over");
                    //Stop Time Count
                    //Take Start and Stop Time, Add this time to see time used in Each Round
                    mission56_RoundEndTime = Time.time;
                    mission56_RoundTime = mission56_RoundEndTime - mission56_RoundStartTime;    //Total Time Used in Round
                    mission56_OverallTimeInMatch = mission56_OverallTimeInMatch + mission56_RoundTime;

                    if ((roundNum == 2) && (!(mission56_OverallTimeInMatch < 60))){ //From Round 1 and 2
                        mission56_OverallTimeInMatch = 0;
                    }else{
                        if (roundNum != 1){
                            Debug.LogWarning("Mission56 Completed");
                            mission56_2RoundsUnder1Minutes = true;
                        }
                    }
                    
                }

                public void mission56_MatchHasEnded(){ //From Round 2 and 3
                    Debug.LogError("56 Match Over");
                    if (mission56_OverallTimeInMatch < 60){    //180 = 3 minutes
                        mission56_2RoundsUnder1Minutes = true;
                    }
                }

                //DELETE THIS, ONLY FOR TESTING
                //Function for StartOfMatch(), AddCompletedMissions(), EndOfMatch()
                #region
                    public void a1_mission56_RoundStart(){
                        mission56_RoundHasStarted();
                    }

                    public void a1R1_mission56_RoundEnd(){
                        mission56_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a1R2_mission56_RoundEnd(){
                        mission56_RoundHasEnded(2, "player_won", 70, 50, "C", 100);
                    }

                    public void a1_mission56_MatchEnd(){
                        mission56_MatchHasEnded();
                    }

                #endregion
            #endregion
            //END OF Weekly Mission ID = 56



            //Weekly Mission ID = 57        || Defeat opponent using only Kick-Punch move (KP)
            #region
                //Functions used: mission57_RoundHasStarted(), mission57_RoundHasEnded(), mission57_PlayerHasHitEnemy()
                public static string mission57_KickPunch = "", mission57_ComboBroken = "";
                public static bool mission57_RoundIsOverWon = false;

                public void mission57_weekly(){
                    Debug.LogWarning("57KP value = " + mission57_KickPunch + " ComboBroken = " + mission57_ComboBroken);

                    if (mission57_RoundIsOverWon == true){
                        if (mission57_ComboBroken != "X"){
                            instantiate_completedMissionCanvas(57);  //For displaying to the player that mission is done
                            game_statsManager.updateMission(57);

                            Debug.LogWarning("Mission57 Completed! Won using KP Combo");     
                        }
                    }
                }

                public void mission57_RoundHasStarted(){
                    mission57_RoundIsOverWon = false;
                    mission57_KickPunch = "";
                    mission57_ComboBroken = "";
                }

                public void mission57_RoundHasEnded(int roundNum, string round_status, int playerHealth, int playerPoints, string player_CharacterName, int enemyHealth){
                    if (round_status == "player_won"){
                        mission57_RoundIsOverWon = true;    
                    }
                }

                public void mission57_PlayerHasHitEnemy(string action_type, string action_source, int enemyHealth){
                    mission57_CheckCombo(action_type);
                }

                public void mission57_CheckCombo(string action_performed){  //Looking for KP
                    string action_done_initial = (action_performed == "punch") ? "P" : "K";

                    if (mission57_KickPunch == "KP"){
                        mission57_KickPunch = "";
                    }

                    switch(mission57_KickPunch){
                        //First letter
                        case "":
                            if (action_done_initial == "P"){
                                mission57_KickPunch = "";
                                mission57_ComboBroken = "X";
                                break;
                            }else{
                                // Add the first "K"
                                mission57_KickPunch += "K";
                                break;
                            }

                        //Second letter
                        case "K":
                            if (action_done_initial == "K"){
                                mission57_KickPunch = "";
                                mission57_ComboBroken = "X";
                                break;
                            }else{
                                // Add the "P"
                                mission57_KickPunch += "P";
                                break;
                            }                            
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public void a_mission57_kick(){
                        mission57_CheckCombo("kick");
                    }

                    public void a_mission57_punch(){
                        mission57_CheckCombo("punch");
                    }

                    public void a_mission57_RoundOver(){
                        mission57_RoundHasEnded(1, "player_won", 70, 50, "C", 100);
                    }

                    public void a_mission57_RoundStart(){
                        mission57_RoundHasStarted();
                    }
                #endregion

            #endregion
            //END OF Weekly Mission ID = 57



            //Weekly Mission ID = 58        || Reach 1200 XP
            #region
                public void mission58_weekly(){
                    Debug.Log("Mission58 Called");

                    // Debug.LogError((playerData.xp).ToString());
                    playerData = LoadPlayerData();

                    // if ((playerData.xp >= 1000) && (playerData.xp < 3000)){
                    if (playerData.xp >= 9000){
                        instantiate_completedMissionCanvas(58);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(58);     //For registering the completed mission with the ID
                        
                        Debug.Log("Mission58 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 58



            //Weekly Mission ID = 59        || Rank up to Apex Predator Level
            #region
                public void mission59_weekly(){
                    Debug.Log("Mission59 Called");

                    playerData = LoadPlayerData();

                    if ((playerData.rank_level == 1) && (playerData.rank == "Apex Predator")){
                        instantiate_completedMissionCanvas(59);
                        game_statsManager.updateMission(59);
                        
                        Debug.Log("Mission59 done");             //Show which mission is done
                    }
                }
            #endregion
            //END OF Weekly Mission ID = 59



            //Weekly Mission ID = 60        || Complete Week missions
            #region
                public void mission60_weekly(){
                    Player_missionProgress = LoadPlayer_MissionData();

                    int count = Player_missionProgress.completed_missions.Count(mission => mission >= 56 && mission <= 59);
                    if (count >= 4){
                        instantiate_completedMissionCanvas(60);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(60);

                        Debug.LogWarning("Mission60 Completed");
                    }
                }


                //DELETE THIS, ONLY FOR TESTING
                #region
                    public static int missID22 = 56;
                    public void a_mission60_missionDone(){
                        instantiate_completedMissionCanvas(missID22);  //For displaying to the player that mission is done
                        game_statsManager.updateMission(missID22);

                        missID22++;
                    }
                #endregion
            #endregion
            //END OF Weekly Mission ID = 60

        #endregion
        //END OF MONTH 3

    #endregion
    //END OF WEEKLY MISSIONS



    //Handle Completed Missions
    #region
        //Shows a popup indicating what missions was just completed
        public void instantiate_completedMissionCanvas(int missionID){
            popup.SetActive(true);

            GameObject completed_missions_canvas_instance = Instantiate(popup, completed_missions_canvas.transform);
            completed_missions_canvas_instance.name = "Completed_Mission" + missionID.ToString();
            completed_missions_canvas_instance.SetActive(false);

            string completed_mission_reference = "mission_details/mission_bg/mission_text";
            GameObject completed_mission_gameobject = completed_missions_canvas_instance.transform.Find(completed_mission_reference).gameObject;

            TextMeshProUGUI completed_mission_txt = completed_mission_gameobject.GetComponent<TextMeshProUGUI>();

            string missiontitle_retrieved = missions.getMissionTitle(missionID); //Get the Title of the completed mission
            completed_mission_txt.text = missiontitle_retrieved;

            popup.SetActive(false);
        }


        //Show Mission Completed popup for 3 seconds
        private IEnumerator SetActiveForDuration(GameObject gm){
            gm.SetActive(true);
            yield return new WaitForSeconds(2f);    //Show the popup for 3 seconds
            gm.SetActive(false);
        }

        //Shows Pop-ups for completed missions, showing each mission in an exact order from the first to the last
        IEnumerator ShowPopupsContinuously(){
            while (true){
                int childCount = completed_missions_canvas.transform.childCount;
                for (int i = 0; i < childCount; i++){

                    GameObject popup_instance = completed_missions_canvas.transform.GetChild(i).gameObject;    //Transform child out of bounds
                    // Debug.Log(popup_instance.name);

                    if (popup_instance.name == "mission_completed_popUp"){
                        continue;
                    }

                    //Show Popup
                    popup_instance.SetActive(true);

                    yield return new WaitForSeconds(3f);

                    //Hide Popup
                    if (popup_instance != null){
                        popup_instance.SetActive(false);
                        Destroy(popup_instance); // Delayed destruction to allow for fade-out or other effects
                    }    
                    break;
                }

                // Wait for a short time before checking for new children again
                yield return new WaitForSeconds(0.10f);
            }
        }

    #endregion



    // ***** PLAYER PREFS
    #region
        private const string player_completed_Missions_toAnimate = "Player_Completed_Missions_toAnimate";
        private const string player_missionData = "Player_MissionData";

        //Save Missions Data
        private void SavePlayer_MissionData(MissionProgress data){
            string jsonData = JsonUtility.ToJson(data);
            // PlayerPrefs.SetString("Player_MissionData", jsonData); // Details stored as "PlayerData"
            PlayerPrefs.SetString(player_missionData, jsonData); // Details stored as "PlayerData"
            PlayerPrefs.Save();
        }

        //Loads mission progress from PlayerPrefs.
        MissionProgress LoadPlayer_MissionData(){
            string jsonData = PlayerPrefs.GetString(player_missionData, "{}"); // Details were stored as "PlayerData"
            return JsonUtility.FromJson<MissionProgress>(jsonData);
        }


        //Load Missions data to Animate
        Completed_Missions_toAnimate LoadPlayerData_CompletedMission_toAnimate(){
            string jsonData2 = PlayerPrefs.GetString(player_completed_Missions_toAnimate, "{}"); // Details were stored as "PlayerData"
            return JsonUtility.FromJson<Completed_Missions_toAnimate>(jsonData2);
        }


        //Save Missions data to Animate
        private void SaveCompleted_Missions_toAnimate(Completed_Missions_toAnimate data){
            string jsonData = JsonUtility.ToJson(data);
            // PlayerPrefs.SetString("Player_MissionData", jsonData); // Details stored as "PlayerData"
            PlayerPrefs.SetString(player_completed_Missions_toAnimate, jsonData); // Details stored as "PlayerData"
            PlayerPrefs.Save();
        }


        //Retrieve XP of the player, then check if reaches the expected value, i.e 200 XP
        private const string Player_RewardsData = "Player_RewardsData";
        PlayerData playerData;

        //Load player data from PlayerPrefs
        PlayerData LoadPlayerData(){
            string jsonData = PlayerPrefs.GetString(Player_RewardsData, "{}"); // Details were stored as "PlayerData"
            return JsonUtility.FromJson<PlayerData>(jsonData);
        }
    #endregion


}
