Ejemplo n.º 1
0
        public void DoActions(PetInterAction Action, VirtualRoomUser Pet)
        {
            if (Pet.ContainsStatus("lay"))
            {
                Pet.RemoveStatus("lay");
            }

            if (Action.Equals(PetInterAction.Progressing))
            {
                this.Action = PetInterAction.Progressing;
            }

            if (Energy <= 15 && !this.Action.Equals(PetInterAction.Sleeping))
            {
                if (Happiness > 0)
                {
                    Happiness--;
                    UpdateHappiness();
                }

                Pet.AddStatus("lay", string.Empty);
                Pet.UpdateStatus(true);

                this.Action = PetInterAction.Sleeping;
            }
            else
            {
                if (this.Action.Equals(PetInterAction.Sleeping))
                {
                    if (Energy < PetReactor.MAX_ENERGY(Level) && Energy + 2 <= PetReactor.MAX_ENERGY(Level))
                    {
                        Energy += 2;
                        UpdateEnergy();
                    }
                    else
                    {
                        Energy = PetReactor.MAX_ENERGY(Level);
                    }

                    if (Energy >= PetReactor.MAX_ENERGY(Level))
                    {
                        Pet.Talk("Welcome back!", SpeechType.Talk, 0, string.Empty);
                        Pet.RemoveStatus("lay");

                        if (Happiness < PetReactor.MAX_HAPPINESS)
                        {
                            Happiness++;
                            UpdateHappiness();
                        }

                        this.Action = PetInterAction.Interactive;
                    }
                    else
                    {
                        Pet.AddStatus("lay", string.Empty);
                    }

                    Pet.UpdateStatus(true);

                    if (Action.Equals(PetInterAction.Chatting))
                    {
                        Pet.Talk("*Sleeping Zzz..*", SpeechType.Talk, 0, string.Empty);
                    }
                }
                else
                {
                    if (this.Action.Equals(PetInterAction.Progressing))
                    {
                        if (GetRoom().GetRoomEngine().GetPetToys().Count > 0)
                        {
                            foreach (Item Toy in GetRoom().GetRoomEngine().GetPetToys())
                            {
                                if (GetRoomUser().Point.Compare(Toy.Point))
                                {
                                    if (Toy.ExtraData == "0")
                                    {
                                        Pet.RotBody = 2;
                                        Pet.RotHead = 2;

                                        Pet.AddStatus("pla", string.Empty);
                                        Pet.UpdateStatus(true);

                                        Toy.ExtraData = "1";

                                        if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 3 <= PetReactor.MAX_HAPPINESS)
                                        {
                                            Happiness += 3;
                                            UpdateHappiness();
                                        }

                                        GetRoom().GetRoomEngine().BroadcastResponse(Toy.GetTriggerResponse());
                                    }
                                    else
                                    {
                                        if (!EndPlaying)
                                        {
                                            EndPlaying = true;
                                        }
                                        else
                                        {
                                            Toy.ExtraData = "0";
                                            GetRoom().GetRoomEngine().BroadcastResponse(Toy.GetTriggerResponse());
                                            EndPlaying = false;

                                            Pet.RemoveStatus("pla");
                                            Pet.UpdateStatus(true);

                                            this.Action = PetInterAction.Interactive;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (Action.Equals(PetInterAction.Walking))
                        {
                            if (Energy > 0)
                            {
                                if (Pet.IsWalking)
                                {
                                    Pet.PathPoints = new List<Rooms.Pathfinding.iPoint>();
                                    Pet.UpdateStatus(true);
                                }

                                Pet.UnhandledGoalPoint = GetRoom().GetRoomEngine().GetRandom();

                                Energy--;
                                UpdateEnergy();

                                if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 3 <= PetReactor.MAX_HAPPINESS)
                                {
                                    Happiness += 3;
                                    UpdateHappiness();
                                }

                                this.Action = Action;
                            }
                        }
                        else if (Action.Equals(PetInterAction.Chatting) && !Muted)
                        {
                            var Speeches = BrickEngine.GetPetReactor().GetSpeechesForType(Type);

                            PetSpeech Speech = null;

                            if (Speeches.Count > 0)
                            {
                                Speech = Speeches[Random.Next(0, Speeches.Count - 1)];
                            }

                            if (Speech != null)
                            {
                                Pet.Talk(Speech.Speech, Speech.Shout ? SpeechType.Shout : SpeechType.Talk, 0, string.Empty);
                            }

                            if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 5 <= PetReactor.MAX_HAPPINESS)
                            {
                                Happiness += 5;
                                UpdateHappiness();
                            }

                            this.Action = Action;
                        }
                        else if (Action.Equals(PetInterAction.Action) && !GetRoomUser().IsWalking)
                        {
                            if (Pet.GetRoom().GetRoomEngine().GetPetToys().Count > 0 && Random.Next(0, 5) == 2)
                            {
                                Pet.AddStatus("gst", "plf");
                                Pet.UpdateStatus(true);

                                Pet.UnhandledGoalPoint = Pet.GetRoom().GetRoomEngine().GetPetToys()[Random.Next(0, Pet.GetRoom().GetRoomEngine().GetPetToys().Count - 1)].Point;
                                DoActions(PetInterAction.Progressing, Pet);
                            }
                            else
                            {
                                var Actions = BrickEngine.GetPetReactor().GetActionsForType(Type);

                                PetAction doAction = null;

                                if (Actions.Count > 0)
                                {
                                    doAction = Actions[Random.Next(0, Actions.Count - 1)];
                                }

                                if (doAction != null)
                                {
                                    Pet.AddStatus(doAction.Key, doAction.Value);
                                    Pet.UpdateStatus(true);
                                }

                                if (Energy > 0)
                                {
                                    Energy--;
                                    UpdateEnergy();
                                }

                                if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 5 <= PetReactor.MAX_HAPPINESS)
                                {
                                    Happiness += 5;
                                    UpdateHappiness();
                                }

                                this.Action = Action;
                            }
                        }
                        else
                        {
                            this.Action = PetInterAction.Interactive;
                        }
                    }
                }
            }
        }