Esempio n. 1
0
        internal static void Check_Missions(this Avatar Player)
        {
            if (Player != null)
                foreach (Missions CSV_Missions in CSV.Tables.Get(Gamefile.Missions).Datas)
                    if (Player.Tutorials.FindIndex(M => M == CSV_Missions.GetGlobalId()) < 0)
                    {
                        if (!string.IsNullOrEmpty(CSV_Missions.Dependencies))
                        {
                            var Dependencies_Missions =
                                CSV.Tables.Get(Gamefile.Missions).GetData(CSV_Missions.Dependencies) as Missions;

                            if (Player.Tutorials.FindIndex(T => T == Dependencies_Missions.GetGlobalId()) < 0)
                                continue;
                        }
                        if (!string.IsNullOrEmpty(CSV_Missions.BuildBuilding))
                        {
                            var CSV_Buildings = CSV.Tables.Get(Gamefile.Buildings)
                                .GetData(CSV_Missions.BuildBuilding) as Buildings;

                            //List<Building> Building = Player.Objects.Buildings.FindAll(B => B.Data == CSV_Buildings.GetGlobalID());

                            if (CSV_Missions.BuildBuildingCount == 1)
                            {
                                //      int Index = Building.FindIndex(B => B.Level + 1 >= CSV_Missions.BuildBuildingLevel);

                                //    if (Index > -1)
                                {
                                    //      Player.Tutorials.Add(CSV_Missions.GetGlobalID());
                                }
                            }
                        }
                        else if (CSV_Missions.OpenAchievements)
                        {
                            Player.Tutorials.Add(CSV_Missions.GetGlobalId());
                        }
                        else if (CSV_Missions.TrainTroops > 0)
                        {
                            var Troops_Count = 0;

                            //foreach (Slot Slot in Player.Units)
                            {
                                //  Troops_Count += Slot.Count;
                            }

                            if (Troops_Count >= CSV_Missions.TrainTroops)
                                Player.Tutorials.Add(CSV_Missions.GetGlobalId());
                        }
                        else if (!string.IsNullOrEmpty(CSV_Missions.AttackNPC))
                        {
                            //Npcs CSV_Npcs = CSV.Tables.Get(Gamefile.Npcs).GetData(CSV_Missions.AttackNPC) as Npcs;

                            //if (Player.Npcs.FindIndex(N => N.Data == CSV_Npcs.GetGlobalID()) > -1)
                            {
                                Player.Tutorials.Add(CSV_Missions.GetGlobalId());
                                Player.AddExperience(CSV_Missions.RewardXP);

                                //  Player.Resources.Plus(Logic.Enums.Resource.GOLD, CSV_Npcs.Gold);
                                //Player.Resources.Plus(Logic.Enums.Resource.ELIXIR, CSV_Npcs.Elixir);
                            }
                        }
                        else if (CSV_Missions.ChangeName)
                        {
                            //if (Player.NameSet > 0)
                            Player.Tutorials.Add(CSV_Missions.GetGlobalId());
                        }
                        if (!string.IsNullOrEmpty(CSV_Missions.RewardResource))
                            Player.AddExperience(CSV_Missions.RewardXP);
                        if (!string.IsNullOrEmpty(CSV_Missions.RewardTroop))
                            Player.AddExperience(CSV_Missions.RewardXP);
                    }
        }
Esempio n. 2
0
        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;
        }