public static bool Mission_Finish(this Avatar Player, int Global_ID) { if (Player.Tutorials.FindIndex(M => M == Global_ID) < 0) { var Mission = CSV.Tables.Get(Gamefile.Missions).GetDataWithID(Global_ID) as Missions; #if DEBUG Console.WriteLine($"Mission received {Mission.Name} marked as finished"); #endif if (!string.IsNullOrEmpty(Mission.RewardResource)) { var CSV_Resources = CSV.Tables.Get(Gamefile.Resources).GetData(Mission.RewardResource) as Resource; Player.Resources.Plus(CSV_Resources.GetGlobalId(), Mission.RewardResourceCount); } if (!string.IsNullOrEmpty(Mission.RewardTroop)) { var CSV_Characters = CSV.Tables.Get(Gamefile.Characters).GetData(Mission.RewardTroop) as Characters; #if DEBUG Console.WriteLine($"Player received {CSV_Characters.Name} as mission rewards"); #endif Player.Add_Unit(CSV_Characters.GetGlobalId(), Mission.RewardTroopCount); } if (!string.IsNullOrEmpty(Mission.Dependencies)) { var DependenciesID = CSV.Tables.Get(Gamefile.Missions).GetData(Mission.Dependencies).GetGlobalId(); if (Player.Tutorials.FindIndex(M => M == DependenciesID) < 0) { #if DEBUG Console.WriteLine( $"Mission Dependencies {(CSV.Tables.Get(Gamefile.Missions).GetDataWithID(DependenciesID) as Missions).Name} marked as finished"); #endif Mission_Finish(Player, DependenciesID); } } if (!string.IsNullOrEmpty(Mission.AttackNPC)) { var CSV_Npcs = CSV.Tables.Get(Gamefile.Npcs).GetData(Mission.AttackNPC) as Npcs; if (Player.Npcs.FindIndex(N => N.NPC_Id == CSV_Npcs.GetGlobalId()) > -1) { Player.Resources.Plus(Logic.Enums.Resource.Gold, CSV_Npcs.Gold); Player.Resources.Plus(Logic.Enums.Resource.Elixir, CSV_Npcs.Elixir); } } if (Mission.ChangeName) { Player.Resources.Plus(Logic.Enums.Resource.Gold, 900); Player.Resources.Plus(Logic.Enums.Resource.Elixir, 400); } Player.AddExperience(Mission.RewardXP); Player.Tutorials.Add(Mission.GetGlobalId()); return true; } return false; }