public static ItemListItem Create(RdlActor item)
        {
            ItemListItem listItem = new ItemListItem();

            listItem.Actor = item;
            return(listItem);
        }
Exemple #2
0
        public static string GetQuestRewardItemsDisplay(RdlActor quest)
        {
            StringBuilder sb    = new StringBuilder();
            var           items = quest.Properties.Where(p => p.Name.StartsWith("RewardItem_"));

            if (items.Count() > 0)
            {
                int count = 0;
                foreach (var item in items)
                {
                    if (count > 0)
                    {
                        sb.Append(", ");
                    }
                    TemplateItem temp = JsonHelper.FromJson <TemplateItem>(item.Value.ToString());
                    if (temp.Quantity > 1)
                    {
                        sb.AppendFormat("{0} ({1})", temp.Name, temp.Quantity);
                    }
                    else
                    {
                        sb.Append(temp.Name);
                    }
                    count++;
                }
            }
            return(sb.ToString());
        }
Exemple #3
0
        public Avatar(RdlActor actor)
            : base(actor)
        {
            Init();

            string gender = actor.Properties.GetValue <string>("Gender");

            if (!String.IsNullOrEmpty(gender))
            {
                this.Gender = (Gender)Enum.Parse(typeof(Gender), gender, true);
            }
            string race = actor.Properties.GetValue <string>("Race");

            if (!String.IsNullOrEmpty(race) && Game.Races.ContainsKey(race))
            {
                this.Race = Game.Races[race];
            }

            var skills = actor.Properties.Where(p => p.Name.StartsWith("Skill_")).ToList();

            foreach (var skill in skills)
            {
                this.Skills.Add(skill.Name, new Skill {
                    Name = skill.Name, Value = (int)skill.GetValue <double>()
                });
            }
            Game.EnsureSkillDetails(this.Skills.Values);
        }
 public void Drop(IDroppable item)
 {
     if (item is ItemListItem)
     {
         RdlActor actor = (item as ItemListItem).Actor;
         if (actor.Properties.GetValue <ObjectType>("ObjectType") == ObjectType.Quest)
         {
             QuestFacilitatorDialog diag = new QuestFacilitatorDialog();
             diag.Tag = actor;
             diag.QuestFacilitatorTypeSelected += new QuestFacilitatorTypeSelectedEventHandler(diag_QuestFacilitatorTypeSelected);
             PopupManager.Add(diag, new Point(354, 57));                     // Admin screen position.
         }
         else
         {
             actor.OwnerID = this.Actor.ID;
             this.ActorDrop(this, new ActorEventArgs {
                 Actor = actor
             });
             //// Args:
             //// 0 = Item
             //// 1 = Target
             //ServerManager.Instance.SendCommand("ADMINDROPITEM", actor.Name, this.Actor.ID);
         }
     }
 }
        public static AvatarListItem Create(RdlActor avatar)
        {
            AvatarListItem item = new AvatarListItem();

            item.Actor = avatar;
            return(item);
        }
Exemple #6
0
 public ContextMenu(ContextMenuType type, RdlActor actor)
 {
     this.Loaded += new RoutedEventHandler(ContextMenu_Loaded);
     InitializeComponent();
     this.Type  = type;
     this.Actor = actor;
 }
Exemple #7
0
        public RdlActor ToRdlActor()
        {
            RdlActor actor = new RdlActor(this.ID, this.Name);

            foreach (var prop in this.Properties.Values)
            {
                actor.Properties.Add(new RdlProperty(this.ID, prop.Name, prop.Value));
            }
            return(actor);
        }
Exemple #8
0
        private void BindQuests()
        {
            if (this.Target != null && this.Player != null)
            {
                QuestDetailContainer.Visibility = Visibility.Collapsed;
                QuestListContainer.Visibility   = Visibility.Visible;
                lstQuests.Children.Clear();
                foreach (var item in this.Target.Inventory.GetQuests())
                {
                    RdlActor playerQuest = this.Player.Inventory.GetQuests().Where(q => q.Name == item.Name).FirstOrDefault();

                    if (playerQuest != null)
                    {
                        // Do not display quests for which the player has already completed.
                        if (playerQuest.Properties.GetValue <bool>("IsComplete"))
                        {
                            continue;
                        }

                        // Do not display quests where the target is the endswith value and the player has not finished
                        // nor has the player started quest.
                        if ((!playerQuest.Properties.GetValue <bool>("IsFinished") || !playerQuest.Properties.GetValue <bool>("IsStarted")) &&
                            playerQuest.Properties.GetValue <int>(String.Format("EndsWith_{0}",
                                                                                this.Target.ID)) == this.Target.ID)
                        {
                            continue;
                        }
                    }

                    if (!String.IsNullOrEmpty(item.Properties.GetValue <string>("ParentQuestName")))
                    {
                        // If the player has not completed the parent quest, do not display this
                        // quest as an option.
                        // TODO: This is inefficient, need a better way to query this.
                        if (this.Player.Inventory.GetQuests().Where(q =>
                                                                    q.Name == item.Properties.GetValue <string>("ParentQuestName") &&
                                                                    !q.Properties.GetValue <bool>("IsComplete")).Count() > 0)
                        {
                            continue;
                        }
                    }

                    QuestInfoPanel pnl = new QuestInfoPanel();
                    pnl.PlayerQuest = playerQuest;
                    pnl.TargetQuest = item;
                    pnl.Click      += new RoutedEventHandler(OnQuestInfoPanelClick);
                    pnl.Refresh();
                    lstQuests.Children.Add(pnl);
                }
            }
            else
            {
                this.ShowLoader();
            }
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the Actor class from an RdlActor and RdlProperty tags.
        /// </summary>
        /// <param name="actorTag">The RdlActor tag used to set the ID and Name of the actor.</param>
        public Actor(RdlActor actorTag)
            : this()
        {
            this.ID   = actorTag.ID;
            this.Name = actorTag.Name;

            foreach (var item in actorTag.Properties)
            {
                this.Properties.SetValue(item.Name, item.Value);
            }
        }
Exemple #10
0
        private void LoadQuest()
        {
            // Quest will be the target's quest instance, not the player's.
            if (this.Quest != null)
            {
                QuestDetailContainer.Visibility = Visibility.Visible;
                QuestListContainer.Visibility   = Visibility.Collapsed;

                lblQuestName.Text = this.Quest.Name;

                lblMessage.Text = this.Quest.Description;

                // Reward items
                lblRewardItems.Text = ItemHelper.GetQuestRewardItemsDisplay(this.Quest);

                // Currency
                ctlCurrency.Currency = new Currency(this.Quest.Properties.GetValue <int>("RewardCurrency"));

                // Emblem
                ctlCurrency.Emblem = this.Quest.Properties.GetValue <int>("RewardEmblem");

                // Load the player's quest instance.
                bool showComplete = false;
                if (this.Player != null && this.Target != null)
                {
                    RdlActor playerQuest = this.Player.Inventory.GetQuests().Where(q => q.Name == this.Quest.Name).FirstOrDefault();
                    if (playerQuest != null)
                    {
                        if ((playerQuest.Properties.GetValue <bool>("IsFinished") && !playerQuest.Properties.GetValue <bool>("IsComplete")) &&
                            this.Quest.Properties.GetValue <int>(String.Format("EndsWith_{0}",
                                                                               this.Target.ID)) == this.Target.ID)
                        {
                            // Quest is finished, not complete and ends with the current target, display complete
                            // button so player can complete the quest and gain the rewards.
                            showComplete    = true;
                            lblMessage.Text = this.Quest.Properties.GetValue <string>("CompletedMessage");
                        }
                    }
                }

                if (showComplete)
                {
                    btnComplete.Visibility = Visibility.Visible;
                }
                else
                {
                    btnAccept.Visibility = Visibility.Visible;
                }
            }
            else
            {
                this.BindQuests();
            }
        }
Exemple #11
0
        public static EquipLocation EquipLocation(this RdlActor actor)
        {
            EquipLocation equipLoc = Radiance.EquipLocation.None;
            string        loc      = actor.Properties.GetValue <string>("EquipLocation");

            if (!String.IsNullOrEmpty(loc))
            {
                equipLoc = (EquipLocation)Enum.Parse(typeof(EquipLocation), loc, true);
            }
            return(equipLoc);
        }
Exemple #12
0
        public static void EnsureBuyCost(RdlActor item, double markupPercentage)
        {
            int cost    = item.Properties.GetValue <int>("Cost");
            int buyCost = (int)(cost * markupPercentage);

            if (markupPercentage == 0)
            {
                buyCost = cost;
            }
            item.Properties.SetValue("BuyCost", buyCost);
        }
Exemple #13
0
        public Actor(RdlActor tag)
            : this()
        {
            this.ID   = tag.ID;
            this.Name = tag.Name;

            // Properties
            foreach (var property in tag.Properties)
            {
                this.Properties.SetValue(property.Name, property.Value);
            }
        }
Exemple #14
0
 public static string GetLastMap(string playerName)
 {
     byte[] buffer = Read(GetPath(UserDirectory), playerName);
     if (buffer != null && buffer.Length > 0)
     {
         RdlActor player = RdlActor.FromBytes(buffer) as RdlActor;
         if (player != null)
         {
             return(player.Properties.GetValue <string>("Zone"));
         }
     }
     return(String.Empty);
 }
Exemple #15
0
 public void Refresh()
 {
     if (this.Affect != null && this.Owner != null)
     {
         // Find the item assoiated with this affect.
         RdlActor item = this.GetItem();
         if (item != null)
         {
             ToolTipService.SetToolTip(this, item.Name.Replace("Affect_", String.Empty));
             imgMain.Source = ImageManager.GetImageSource(item.Properties.GetValue <string>("ImageUri"));
         }
     }
 }
Exemple #16
0
        private void LoadQuest(RdlActor quest)
        {
            // Description
            lblDescription.Text = quest.Description;

            // Rewards
            lblRewards.Text = ItemHelper.GetQuestRewardItemsDisplay(quest);

            // Currency
            ctlCurrency.Currency = new Currency(quest.Properties.GetValue <int>("RewardCurrency"));

            // Emblem
            ctlCurrency.Emblem = quest.Properties.GetValue <int>("RewardEmblem");
        }
        void diag_QuestFacilitatorTypeSelected(object sender, QuestFacilitatorTypeSelectedEventArgs e)
        {
            RdlActor actor = (sender as QuestFacilitatorDialog).Tag as RdlActor;

            PopupManager.Remove();
            this.ActorDrop(this, new ActorEventArgs {
                Actor = actor
            });
            //// Args:
            //// 0 = Item
            //// 1 = Target
            //// 2 = Arg0
            //ServerManager.Instance.SendCommand("ADMINDROPITEM", actor.Name, this.Actor.ID, e.Type);
        }
Exemple #18
0
        public static void EnsureSellCost(RdlActor item, double markdownPercentage)
        {
            if (markdownPercentage > 0)
            {
                markdownPercentage *= -1;
            }
            int cost     = item.Properties.GetValue <int>("Cost");
            int sellCost = (int)(cost * markdownPercentage);

            if (sellCost <= 0)
            {
                sellCost = cost;
            }
            item.Properties.SetValue("SellCost", sellCost);
        }
Exemple #19
0
        public void SetProperties(RdlActor actor)
        {
            this.SetProperties(new Avatar(actor));
            //int health, healthMax, willpower, willpowerMax, level;
            //string race, gender;
            //health = actor.Properties.GetValue<int>("Body");
            //healthMax = actor.Properties.GetValue<int>("BodyMax");
            //willpower = actor.Properties.GetValue<int>("Mind");
            //willpowerMax = actor.Properties.GetValue<int>("MindMax");
            //level = actor.Properties.GetValue<int>("Level");
            //race = actor.Properties.GetValue<string>("Race");
            //gender = actor.Properties.GetValue<string>("Gender");

            //this.SetProperties(actor.ID, actor.Name, health, healthMax, willpower, willpowerMax, level, race, gender);
        }
Exemple #20
0
        /// <summary>
        /// Updates the specified properties of the actor represented by the RdlProperty.ID value.
        /// </summary>
        /// <param name="actor">The RdlActor instance defining the actor to update.</param>
        /// <param name="properties">The list of properties to update.</param>
        public void SaveActor(RdlActor actor, List <RdlProperty> properties)
        {
            IActor obj = this.GetActor(actor.ID);

            if (obj != null)
            {
                // Update the properties and persist to the database.
                foreach (var item in properties)
                {
                    if (item.ID == actor.ID)
                    {
                        obj.Properties.SetValue(item.Name, item.Value);
                    }
                }
                this.SaveActor(obj);
            }
        }
        public static ActorItem Create(RdlActor actorTag, bool displayItemsAsMerchandise)
        {
            ActorItem item = new ActorItem()
            {
                ActorID   = actorTag.ID,
                ActorName = actorTag.Name
            };

            // Each Actor has a list of actions associated with them, they are prefixed in the properties
            // collection with "Action_".
            List <RdlProperty> properties = actorTag.Properties.Where(p => p.Name.StartsWith("Action_")).ToList();

            foreach (var p in properties)
            {
                item.CreateButton(p.Name.Replace("Action_", ""));
            }
            return(item);
        }
Exemple #22
0
 public static void SetSlotItem(Slot slot, RdlActor item)
 {
     if (slot != null)
     {
         if (item != null)
         {
             int quantity = item.Properties.GetValue <int>("Quantity");
             slot.ToolTip = item.Name;
             slot.Item    = new SlotItem(item,
                                         Asset.GetImageSource(item.Properties.GetValue <string>("ImageUri")),
                                         quantity, item.Properties.GetValue <bool>("IsStackable"));
         }
         else
         {
             slot.Item = null;
         }
     }
 }
        public void UpdateActor(RdlActor actor)
        {
            var tile = _tiles.Where(t => t.Place.Actors.Count(a => a.ID == actor.ID) > 0).FirstOrDefault();

            if (tile != null)
            {
                int index = -1;
                for (int i = 0; i < tile.Place.Actors.Count; i++)
                {
                    if (tile.Place.Actors[i].ID == actor.ID)
                    {
                        index = i;
                        break;
                    }
                }
                if (index >= 0)
                {
                    tile.Place.Actors[index] = actor;
                }
            }
        }
Exemple #24
0
        public void Refresh()
        {
            if (this.Player != null)
            {
                var quests = this.Player.Inventory.GetQuests();

                // Active Quests
                lstActive.Children.Clear();
                RdlActor lastQuest = null;
                foreach (var quest in quests.Where(q => !q.Properties.GetValue <bool>("IsComplete")))
                {
                    QuestInfoPanel pnl = new QuestInfoPanel();
                    pnl.TargetQuest = quest;
                    pnl.Click      += new RoutedEventHandler(OnQuestInfoPanelClick);
                    pnl.Refresh();
                    lstActive.Children.Add(pnl);

                    lastQuest = quest;
                }
                if (lastQuest != null)
                {
                    this.LoadQuest(lastQuest);
                }

                // Compelted Quests
                lstCompleted.Children.Clear();
                foreach (var quest in quests.Where(q => q.Properties.GetValue <bool>("IsComplete")))
                {
                    QuestInfoPanel pnl = new QuestInfoPanel();
                    pnl.TargetQuest = quest;
                    pnl.Refresh();
                    lstCompleted.Children.Add(pnl);
                }

                // Hide the loading window.
                this.HideLoader();
            }
        }
Exemple #25
0
        void AffectIcon_MouseEnter(object sender, MouseEventArgs e)
        {
            RdlActor item      = this.GetItem();
            TimeSpan duration  = new TimeSpan(Convert.ToInt64(this.Affect.Value));
            TimeSpan now       = new TimeSpan(DateTime.Now.ToUniversalTime().Ticks);
            TimeSpan remainder = now.Subtract(duration);

            string minutes = String.Empty;

            if (remainder.TotalMinutes > 1)
            {
                minutes = String.Format("{0} minutes remaining.", remainder.TotalMinutes);
            }
            else if (remainder.TotalMinutes < 1)
            {
                minutes = String.Format("{0} seconds remaining.", remainder.TotalSeconds);
            }
            else
            {
                minutes = "1 minute remaining.";
            }

            int    power = item.Properties.GetValue <int>("AffectPower");
            string sign  = "+";

            if (power < 0)
            {
                sign = "-";
            }

            ToolTipService.SetToolTip(this, String.Format("{0} ({1}{2} {3}) {4}",
                                                          this.Affect.Name.Replace("Affect_", String.Empty),
                                                          sign,
                                                          power,
                                                          item.Properties.GetValue <string>("AffectType"),
                                                          minutes));
        }
Exemple #26
0
 public static int Quantity(this RdlActor actor)
 {
     return(actor.Properties.GetValue <int>("Quantity"));
 }
Exemple #27
0
 public static ObjectType ObjectType(this RdlActor actor)
 {
     return(actor.Properties.GetValue <ObjectType>("ObjectType"));
 }
Exemple #28
0
 public static string ImageUri(this RdlActor actor)
 {
     return(actor.Properties.GetValue <string>("ImageUri"));
 }
 public void SetProperties(RdlActor actor)
 {
     this.Actor      = actor;
     this.Properties = actor.Properties;
 }
Exemple #30
0
 public static void SavePlayer(RdlActor player)
 {
     Write(GetPath(UserDirectory), player.Name, player.ToBytes());
 }