private AnimationElement cloneAndPaste(AnimationSequencer destinationSequence)
        {
            AnimationElement clonedElement = null;

            if (currentClipboardObject is AnimationElement)
            {
                var cloningElement = currentClipboardObject as AnimationElement;
                clonedElement = cloningElement.Clone(cloningElement.Target);

                destinationSequence.InsertElement(clonedElement);
            }
            else
            {
                var cloningAbility           = currentClipboardObject as AnimatedAbility;
                AnimationSequencer sequencer = cloningAbility.Clone() as AnimationSequencer;

                AnimatedCharacter target = null;
                if (destinationSequence is AnimatedAbility)
                {
                    target = (destinationSequence as AnimatedAbility).Target;
                }
                else
                {
                    target = (destinationSequence as SequenceElement).Target;
                }

                SequenceElementImpl sequenceElement = new HeroVirtualTabletop.AnimatedAbility.SequenceElementImpl(sequencer, target);
                sequenceElement.Type = sequencer.Type;
                sequenceElement.Name = "Sequence: " + sequenceElement.Type.ToString();
                clonedElement        = sequenceElement;

                destinationSequence.InsertElement(sequenceElement);
            }
            return(clonedElement);
        }
        private AnimationElement cutAndPaste(AnimationSequencer destinationSequence)
        {
            object[]           clipboardObj   = this.currentClipboardObject as object[];
            AnimationElement   cutElement     = clipboardObj[0] as AnimationElement;
            AnimationSequencer parentSequence = clipboardObj[1] as AnimationSequencer;

            parentSequence.RemoveElement(cutElement);
            destinationSequence.InsertElement(cutElement);

            return(cutElement);
        }
Exemple #3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="position"> Location in game.</param>
        /// <param name="width"> Width of the entity.</param>
        /// <param name="height"> Height of the entity.</param>
        /// <param name="level"> The level the Entity is in.</param>
        public Entity(Vector2 position, int width, int height, Level level)
        {
            Parent = level;

            Position = position;

            Width  = width;
            Height = height;

            Animations = new AnimationSequencer();
            Bounds     = new Rectangle((int)position.X, (int)position.Y, width, height);

            Solid = true;

            CheckCollisions = true;

            Collidable = true;
        }
        public AnimationElement PasteFromClipboard(AnimationSequencer destinationSequence)
        {
            AnimationElement pastedMember = null;

            switch (this.CurrentClipboardAction)
            {
            case ClipboardAction.Clone:
                pastedMember = cloneAndPaste(destinationSequence);
                break;

            case ClipboardAction.Cut:
                pastedMember = cutAndPaste(destinationSequence);
                break;
            }
            this.CurrentClipboardAction = ClipboardAction.None;
            this.currentClipboardObject = null;

            return(pastedMember);
        }
        public bool CheckPasteEligibilityFromClipboard(AnimationSequencer destinationSequence)
        {
            bool canPaste = false;

            switch (this.CurrentClipboardAction)
            {
            case ClipboardAction.Clone:
                if (this.currentClipboardObject != null)
                {
                    if (this.currentClipboardObject is AnimationSequencer)
                    {
                        AnimationSequencer      seqElement  = this.currentClipboardObject as AnimationSequencer;
                        List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements);
                        if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference?.Ability == destinationSequence); })))
                        {
                            canPaste = true;
                        }
                    }
                    else if (this.currentClipboardObject is ReferenceElement)
                    {
                        ReferenceElement refAbility = this.currentClipboardObject as ReferenceElement;
                        if (refAbility.Reference?.Ability == destinationSequence)
                        {
                            canPaste = false;
                        }
                        else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0)
                        {
                            bool refexists = false;
                            if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement))
                            {
                                refexists = true;
                            }
                            List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements);
                            if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); }))
                            {
                                refexists = true;
                            }
                            if (!refexists)
                            {
                                canPaste = true;
                            }
                        }
                        else
                        {
                            canPaste = true;
                        }
                    }
                    else
                    {
                        canPaste = true;
                    }
                }
                break;

            case ClipboardAction.Cut:
                if (this.currentClipboardObject != null)
                {
                    object[]           clipObj = this.currentClipboardObject as object[];
                    AnimationElement   clipboardAnimationElement   = clipObj[0] as AnimationElement;
                    AnimationSequencer clipboardAnimationSequencer = clipObj[1] as AnimationSequencer;
                    if (clipboardAnimationElement is SequenceElement)
                    {
                        SequenceElement         seqElement  = clipboardAnimationElement as SequenceElement;
                        List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements);
                        if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); })))
                        {
                            canPaste = true;
                        }
                    }
                    else if (clipboardAnimationElement is ReferenceElement)
                    {
                        ReferenceElement refAbility = clipboardAnimationElement as ReferenceElement;
                        if (refAbility.Reference?.Ability == destinationSequence)
                        {
                            canPaste = false;
                        }
                        else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0)
                        {
                            bool refexists = false;
                            if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement))
                            {
                                refexists = true;
                            }
                            List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements);
                            if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); }))
                            {
                                refexists = true;
                            }
                            if (!refexists)
                            {
                                canPaste = true;
                            }
                        }
                        else
                        {
                            canPaste = true;
                        }
                    }
                    else
                    {
                        canPaste = true;
                    }
                }
                break;
            }
            return(canPaste);
        }
 public void CutToClipboard(AnimationElement animationElement, AnimationSequencer sourceSequence)
 {
     this.CurrentClipboardAction = ClipboardAction.Cut;
     this.currentClipboardObject = new object[] { animationElement, sourceSequence };
 }
 public AnimatedAbilityImpl(AnimationSequencer clonedsequencer)
 {
     _sequencer = clonedsequencer;
 }