Пример #1
0
 protected override void OnTick()
 {
     if (m_Cycle != 5)
     {
         //Display warning message
         if (KinCityManager.OnLBChangeWarning != null)
         {
             KinCityManager.OnLBChangeWarning(m_City);
             ++m_Cycle;
             Start();
         }
     }
     else
     {
         //Switch on LB guards
         KinCityData cityData = KinCityManager.GetCityData(m_City);
         if (cityData != null)
         {
             //Don't change the guards if it's somehow now owned by the GCs
             if (cityData.ControlingKin == IOBAlignment.None)
             {
                 return;
             }
             cityData.GuardOption = KinCityData.GuardOptions.LordBritish;
             cityData.ClearAllGuardPosts();
             //Switch on patrol npc guard type
             cityData.SetNPCFlag(KinCityData.NPCFlags.Patrol, true);
             //Raise event for the regions to sort themselves out with the new changes
             if (KinCityManager.OnChangeGuards != null)
             {
                 KinCityManager.OnChangeGuards(m_City, KinCityData.GuardOptions.LordBritish);
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Changes the guards.
        /// </summary>
        /// <param name="city">The city.</param>
        /// <param name="guardOption">The guard option.</param>
        public static void ChangeGuards(KinFactionCities city, KinCityData.GuardOptions guardOption, bool overrideTimeout)
        {
            KinCityData cityData = GetCityData(city);

            if (cityData == null)
            {
                return;
            }
            if (cityData.GuardOption == guardOption)
            {
                return;
            }

            if (!overrideTimeout)
            {
                if (DateTime.Now <= cityData.LastGuardChangeTime + TimeSpan.FromHours(KinSystemSettings.GuardChangeTimeHours))
                {
                    return;
                }
            }
            cityData.LastGuardChangeTime = DateTime.Now;

            if (guardOption == KinCityData.GuardOptions.LordBritish)
            {
                LBGuardTimer timer = new LBGuardTimer(city);
                timer.Start();
            }
            else
            {
                cityData.GuardOption = guardOption;
                //Switch off patrol npc guard type
                cityData.SetNPCFlag(KinCityData.NPCFlags.Patrol, false);
                if (guardOption == KinCityData.GuardOptions.None)
                {
                    cityData.ClearAllGuardPosts();
                }

                //Update existing guards with the new rules
                foreach (KinCityData.BeneficiaryData bd in cityData.BeneficiaryDataList)
                {
                    foreach (KinGuardPost kgp in bd.GuardPosts)
                    {
                        if (kgp != null && !kgp.Deleted)
                        {
                            kgp.UpdateExisitngGuards();
                        }
                    }
                }

                //Raise event for the regions to sort themselves out with the new changes
                if (KinCityManager.OnChangeGuards != null)
                {
                    KinCityManager.OnChangeGuards(city, guardOption);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Transfers owership of a city to a kin or golem controller king
        /// </summary>
        /// <param name="city"></param>
        /// <param name="winners"></param>
        public static void TransferOwnership(KinFactionCities city, IOBAlignment kin, List <PlayerMobile> winners)
        {
            KinCityData cd = GetCityData(city);

            if (cd == null)
            {
                Console.WriteLine("Error in KinCityManager.TransferOwnership() - City Data not found");
                return;
            }

            //Set props that apply to both GC and Kin
            cd.CityLeader  = null;
            cd.CaptureTime = DateTime.Now;
            cd.ClearAllGuardPosts();
            cd.ClearActivityDelta();

            if (kin == IOBAlignment.None)             //GCs!
            {
                cd.ControlingKin = kin;
                //setup defaults for a controller city
                cd.IsVotingStage = false;
                cd.TaxRate       = 0.0;
                cd.BeneficiaryDataList.Clear();
                cd.UnassignedGuardPostSlots = 0;
                //Absorb treasury
                cd.EmptyTreasury();
                ChangeGuards(city, KinCityData.GuardOptions.None, true);
                cd.ClearNPCFLags();
                //Update townspeople spawners and switch on GCs
                UpdateCityNPCSpawners(cd.City);
                if (OnGolemController != null)
                {
                    OnGolemController(cd.City, true);
                }
            }
            else
            {
                //check to see if the city was previously owned by the controllers
                if (cd.ControlingKin == IOBAlignment.None)
                {
                    //if so then apply default settings for a town
                    cd.SetAllNPCFlags();
                    ChangeGuards(city, KinCityData.GuardOptions.None, true);
                    //Set last change time so they can change the guards immediately
                    cd.LastGuardChangeTime = DateTime.Now.AddHours(-KinSystemSettings.GuardChangeTimeHours);
                    //Update townspeople spawners and switch off GCs
                    UpdateCityNPCSpawners(cd.City);
                    SetGolemControllers(cd.City, false);
                    if (OnGolemController != null)
                    {
                        OnGolemController(cd.City, false);
                    }
                }
                else
                {
                    cd.LastGuardChangeTime = DateTime.Now.AddHours(-KinSystemSettings.GuardChangeTimeHours);
                }

                cd.ControlingKin = kin;
                //Assign voting info
                cd.BeneficiaryDataList.Clear();
                foreach (PlayerMobile pm in winners)
                {
                    cd.BeneficiaryDataList.Add(new KinCityData.BeneficiaryData(pm, 0));
                }

                //Change the guards to none if it is LB incase the new owners are all red
                if (cd.GuardOption == KinCityData.GuardOptions.LordBritish)
                {
                    ChangeGuards(cd.City, KinCityData.GuardOptions.None, true);
                }

                //Skip voting if only one beneficiary
                if (cd.BeneficiaryDataList.Count == 1)
                {
                    cd.CityLeader = cd.BeneficiaryDataList[0].Pm;
                }
                else
                {
                    cd.IsVotingStage = true;
                }

                cd.UnassignedGuardPostSlots = KinSystem.GetCityGuardPostSlots(city);
                //Voting is controlled by heartbeat
            }
        }