Exemple #1
0
 public Crowd()
 {
     this.crowdMemberCollection = new HashedObservableCollection <ICrowdMember, string>(x => x.Name);
     this.CrowdMemberCollection = new ReadOnlyHashedObservableCollection <ICrowdMember, string>(crowdMemberCollection);
     this.IsGangMode            = true;
 }
        public void LoadCharacter(object state)
        {
            if (this.OptionGroups != null)
            {
                foreach (IOptionGroupViewModel ogVM in this.OptionGroups)
                {
                    ogVM.RemoveDesktopKeyEventHandlers();
                }
            }
            Tuple <ICrowdMemberModel, IEnumerable <ICrowdMemberModel> > tuple = state as Tuple <ICrowdMemberModel, IEnumerable <ICrowdMemberModel> >;

            if (tuple != null)
            {
                Character character = tuple.Item1 as Character;
                HashedObservableCollection <ICrowdMemberModel, string> collection;
                if (tuple.Item2 != null)
                {
                    collection = new HashedObservableCollection <ICrowdMemberModel, string>(tuple.Item2, x => x.Name);
                }
                else
                {
                    collection = new HashedObservableCollection <ICrowdMemberModel, string>(x => x.Name);
                    collection.Add(character as CrowdMemberModel);
                }
                if (character != null && collection != null)
                {
                    character.AddDefaultAbilities();
                    this.OptionGroups = new ObservableCollection <IOptionGroupViewModel>();
                    foreach (IOptionGroup group in character.OptionGroups)
                    {
                        bool showOptionsInGroup = false;
                        if (character.OptionGroupExpansionStates.ContainsKey(group.Name))
                        {
                            showOptionsInGroup = character.OptionGroupExpansionStates[group.Name];
                        }
                        switch (group.Type)
                        {
                        case OptionType.Ability:
                            OptionGroups.Add(this.Container.Resolve <OptionGroupViewModel <AnimatedAbility> >(
                                                 new ParameterOverride("optionGroup", group),
                                                 new ParameterOverride("owner", character),
                                                 new PropertyOverride("ShowOptions", showOptionsInGroup)
                                                 ));
                            break;

                        case OptionType.Identity:
                            OptionGroups.Add(this.Container.Resolve <OptionGroupViewModel <Identity> >(
                                                 new ParameterOverride("optionGroup", group),
                                                 new ParameterOverride("owner", character),
                                                 new PropertyOverride("ShowOptions", showOptionsInGroup)
                                                 ));
                            break;

                        case OptionType.CharacterMovement:
                            OptionGroups.Add(this.Container.Resolve <OptionGroupViewModel <CharacterMovement> >(
                                                 new ParameterOverride("optionGroup", group),
                                                 new ParameterOverride("owner", character),
                                                 new PropertyOverride("ShowOptions", showOptionsInGroup)
                                                 ));
                            break;

                        case OptionType.Mixed:
                            OptionGroups.Add(this.Container.Resolve <OptionGroupViewModel <CharacterOption> >(
                                                 new ParameterOverride("optionGroup", group),
                                                 new ParameterOverride("owner", character),
                                                 new PropertyOverride("ShowOptions", showOptionsInGroup)
                                                 ));
                            break;
                        }
                    }

                    this.EditedCharacter     = character;
                    this.characterCollection = collection;
                }
            }
        }
Exemple #3
0
 public CrowdModel(string name, int order = 0) : base(name)
 {
     this.crowdMemberCollection = new HashedObservableCollection <ICrowdMemberModel, string>(x => x.Name, x => x.Order, x => x.Name);
     this.CrowdMemberCollection = new ReadOnlyHashedObservableCollection <ICrowdMemberModel, string>(crowdMemberCollection);
     this.order = order;
 }