예제 #1
0
        internal Point getRandomWalkableSquare()
        {
            List <Point> list = new List <Point>();

            checked
            {
                for (int i = 0; i < this.mGameMap.GetUpperBound(1) - 1; i++)
                {
                    for (int j = 0; j < this.mGameMap.GetUpperBound(0) - 1; j++)
                    {
                        if (this.mStaticModel.DoorX != j && this.mStaticModel.DoorY != i && this.mGameMap[j, i] == 1)
                        {
                            list.Add(new Point(j, i));
                        }
                    }
                }
                int randomNumber = CyberEnvironment.GetRandomNumber(0, list.Count);
                int num          = 0;
                foreach (Point current in list)
                {
                    if (num == randomNumber)
                    {
                        return(current);
                    }
                    num++;
                }
                return(new Point(0, 0));
            }
        }
예제 #2
0
 internal void PetEnergy(bool Add)
 {
     checked
     {
         int num;
         if (Add)
         {
             if (this.Energy > 100)
             {
                 this.Energy = 100;
                 return;
             }
             else if (this.Energy > 85)
             {
                 return;
             }
             if (this.Energy > 85)
             {
                 num = Pet.MaxEnergy - this.Energy;
             }
             else
             {
                 num = 10;
             }
         }
         else
         {
             num = 15;
         }
         if (num <= 4)
         {
             num = 15;
         }
         int randomNumber = CyberEnvironment.GetRandomNumber(4, num);
         if (!Add)
         {
             this.Energy -= randomNumber;
             if (this.Energy < 0)
             {
                 this.Energy = 1;
             }
         }
         else
         {
             this.Energy += randomNumber;
         }
         if (this.DBState != DatabaseUpdateState.NeedsInsert)
         {
             this.DBState = DatabaseUpdateState.NeedsUpdate;
         }
     }
 }
예제 #3
0
 internal RandomSpeech GetRandomSpeech(bool MixPhrases)
 {
     if (this.RandomSpeech.Count < 1)
     {
         return(new RandomSpeech("", false));
     }
     checked
     {
         if (MixPhrases)
         {
             return(this.RandomSpeech[CyberEnvironment.GetRandomNumber(0, this.RandomSpeech.Count)]);
         }
         RandomSpeech result = new RandomSpeech("", false);
         if (this.LastSpokenPhrase >= this.RandomSpeech.Count)
         {
             this.LastSpokenPhrase = 1;
         }
         result = this.RandomSpeech[this.LastSpokenPhrase - 1];
         this.LastSpokenPhrase++;
         return(result);
     }
 }
예제 #4
0
        internal override void OnTimerTick()
        {
            checked
            {
                if (this.SpeechTimer <= 0)
                {
                    RoomUser roomUser = base.GetRoomUser();
                    if (roomUser.PetData.DBState != DatabaseUpdateState.NeedsInsert)
                    {
                        roomUser.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
                    }
                    if (roomUser != null)
                    {
                        Random random = new Random();
                        this.RemovePetStatus();
                        string[] value = PetLocale.GetValue("speech.pet" + roomUser.PetData.Type);
                        string   text  = value[random.Next(0, value.Length - 1)];
                        if (text.Length != 3)
                        {
                            roomUser.Chat(null, text, false, 0, 0);
                        }
                        else
                        {
                            roomUser.Statusses.Add(text, TextHandling.GetString(roomUser.Z));
                        }
                    }
                    this.SpeechTimer = CyberEnvironment.GetRandomNumber(20, 120);
                }
                else
                {
                    this.SpeechTimer--;
                }
                if (this.ActionTimer <= 0)
                {
                    try
                    {
                        this.RemovePetStatus();
                        this.ActionTimer = CyberEnvironment.GetRandomNumber(15, 40 + base.GetRoomUser().PetData.VirtualId);
                        if (!base.GetRoomUser().RidingHorse)
                        {
                            if (base.GetRoomUser().PetData.Type != 16u)
                            {
                                Point randomWalkableSquare = base.GetRoom().GetGameMap().getRandomWalkableSquare();
                                base.GetRoomUser().MoveTo(randomWalkableSquare.X, randomWalkableSquare.Y);
                            }
                        }

                        if (new Random().Next(2, 15) % 2 == 0)
                        {
                            if (base.GetRoomUser().PetData.Type == 16)
                            {
                                MoplaBreed breed = base.GetRoomUser().PetData.MoplaBreed;
                                base.GetRoomUser().PetData.Energy--;
                                base.GetRoomUser().AddStatus("gst", (breed.LiveState == MoplaState.DEAD) ? "sad" : "sml");
                                base.GetRoomUser().PetData.MoplaBreed.OnTimerTick(base.GetRoomUser().PetData.LastHealth, base.GetRoomUser().PetData.UntilGrown);
                            }
                            else
                            {
                                if (base.GetRoomUser().PetData.Energy < 30)
                                {
                                    base.GetRoomUser().AddStatus("lay", "");
                                }
                                else
                                {
                                    base.GetRoomUser().AddStatus("gst", "joy");
                                    if (new Random().Next(1, 7) == 3)
                                    {
                                        base.GetRoomUser().AddStatus("snf", "");
                                    }
                                }
                            }

                            base.GetRoomUser().UpdateNeeded = true;
                        }

                        goto IL_1B5;
                    }
                    catch (Exception pException)
                    {
                        Logging.HandleException(pException, "PetBot.OnTimerTick");
                        goto IL_1B5;
                    }
                }
                this.ActionTimer--;
IL_1B5:
                if (this.EnergyTimer <= 0)
                {
                    this.RemovePetStatus();
                    RoomUser roomUser2 = base.GetRoomUser();
                    roomUser2.PetData.PetEnergy(true);
                    this.EnergyTimer = CyberEnvironment.GetRandomNumber(30, 120);
                    return;
                }
                this.EnergyTimer--;
            }
        }