Esempio n. 1
0
        private void SpawnModels(object obj)
        {
            int x = 0;

            foreach (string model in SelectedModels)
            {
                if (tmpCrowd.CrowdMemberCollection.Any(m => m.Name == model))
                {
                    continue;
                }
                CrowdMemberModel tmpChar = charExpVM.GetNewCharacter(model, model, IdentityType.Model) as CrowdMemberModel;
                tmpCrowd.Add(tmpChar);
                tmpChar.Spawn();
                tmpChar.Position.X += x++ *3;
            }
        }
Esempio n. 2
0
        public override void Place(ICrowdMember crowdMember, bool completeEvent = true)
        {
            IMemoryElementPosition pos;

            if (this.SavedPositions.TryGetValue(crowdMember.Name, out pos))
            {
                CrowdMemberModel model = crowdMember as CrowdMemberModel;
                model.Position = pos.Clone(false, (model.Position as MemoryInstance).GetTargetPointer());
                //model.Target(false);
                //model.ActiveIdentity.RenderWithoutAnimation(completeEvent, model);
            }
            else if (this.Name == Constants.ALL_CHARACTER_CROWD_NAME)
            {
                CrowdMemberModel model = crowdMember as CrowdMemberModel;
                if (model.SavedPosition != null)
                {
                    MemoryInstance memIns = (model.Position as MemoryInstance);
                    uint           x      = memIns.GetTargetPointer();
                    model.Position = model.SavedPosition.Clone(false, x);
                }
            }
        }
        public override ICrowdMember Clone()
        {
            CrowdMemberModel crowdMemberModel = new CrowdMemberModel()
            {
                Name        = this.Name,
                RosterCrowd = null
            };

            crowdMemberModel.InitializeCharacter();

            foreach (AnimatedAbility ab in this.AnimatedAbilities)
            {
                AnimatedAbility clonedAbility = ab.Clone() as AnimatedAbility;
                clonedAbility.Owner = crowdMemberModel;
                if (clonedAbility.IsAttack)
                {
                    if ((clonedAbility as Attack).OnHitAnimation != null)
                    {
                        (clonedAbility as Attack).OnHitAnimation.Owner = crowdMemberModel;
                    }
                }
                crowdMemberModel.AnimatedAbilities.Add(clonedAbility);
            }

            foreach (Identity id in this.AvailableIdentities)
            {
                Identity clonedIdentity = id.Clone();
                if (id.AnimationOnLoad != null)
                {
                    AnimatedAbility animationOnLoad = crowdMemberModel.AnimatedAbilities.Where(aa => aa.Name == id.AnimationOnLoad.Name).FirstOrDefault();
                    clonedIdentity.AnimationOnLoad = animationOnLoad;
                }
                crowdMemberModel.AvailableIdentities.Add(clonedIdentity);
            }
            if (this.DefaultIdentity != null)
            {
                Identity defaultIdentity = crowdMemberModel.AvailableIdentities.Where(i => i.Name == this.DefaultIdentity.Name).FirstOrDefault();
                crowdMemberModel.DefaultIdentity = defaultIdentity;
            }
            if (this.ActiveIdentity != null)
            {
                Identity activeIdentity = crowdMemberModel.AvailableIdentities.Where(i => i.Name == this.ActiveIdentity.Name).FirstOrDefault();
                crowdMemberModel.ActiveIdentity = activeIdentity;
            }

            foreach (CharacterMovement characterMovement in this.Movements)
            {
                CharacterMovement clonedCharacterMovement = characterMovement.Clone();
                clonedCharacterMovement.Character = crowdMemberModel;
                crowdMemberModel.Movements.Add(clonedCharacterMovement);
            }

            if (this.DefaultMovement != null)
            {
                CharacterMovement defaultCharacterMovement = crowdMemberModel.Movements.FirstOrDefault(cm => cm.Name == this.DefaultMovement.Name);
                crowdMemberModel.DefaultMovement = defaultCharacterMovement;
            }

            // Custom option groups

            foreach (var customGroup in this.OptionGroups.Where(og => og.Type == HeroVirtualTabletop.OptionGroups.OptionType.Mixed))
            {
                OptionGroup <CharacterOption> optGroup = new OptionGroup <CharacterOption>(customGroup.Name);
                crowdMemberModel.AddOptionGroup(optGroup);
                foreach (var customOption in customGroup.Options)
                {
                    if (customOption is Identity)
                    {
                        Identity id = customOption as Identity;
                        Identity identityToRefer = crowdMemberModel.AvailableIdentities.FirstOrDefault(i => i.Name == id.Name);
                        if (identityToRefer != null)
                        {
                            optGroup.Add(identityToRefer);
                        }
                    }
                    else if (customOption is AnimatedAbility)
                    {
                        AnimatedAbility ab             = customOption as AnimatedAbility;
                        AnimatedAbility abilityToRefer = crowdMemberModel.AnimatedAbilities.FirstOrDefault(aa => aa.Name == ab.Name);
                        if (abilityToRefer != null)
                        {
                            optGroup.Add(abilityToRefer);
                        }
                    }
                    else if (customOption is CharacterMovement)
                    {
                        CharacterMovement mv = customOption as CharacterMovement;
                        CharacterMovement characterMovementToRefer = crowdMemberModel.Movements.FirstOrDefault(m => m.Name == mv.Name);
                        if (characterMovementToRefer != null)
                        {
                            optGroup.Add(characterMovementToRefer);
                        }
                    }
                }
            }

            return(crowdMemberModel);
        }