/// <summary>Returns an instance of this class, which will manage the interpolation between two #SpriterAbstractPlayer instances.
 ///     </summary>
 /// <remarks>Returns an instance of this class, which will manage the interpolation between two #SpriterAbstractPlayer instances.
 ///     </remarks>
 /// <param name="first">player to interpolate with the second one.</param>
 /// <param name="second">player to interpolate with the first one.</param>
 public SpriterPlayerInterpolator(SpriterAbstractPlayer
                                  first, SpriterAbstractPlayer second) : base(first.loader, first.animations)
 {
     this.weight = 0.5f;
     setPlayers(first, second);
     this.generateData();
     this.update(0, 0);
 }
        /// <summary>Returns an instance of this class, which will manage the interpolation between two #SpriterAbstractPlayer instances.
        /// 	</summary>
        /// <remarks>Returns an instance of this class, which will manage the interpolation between two #SpriterAbstractPlayer instances.
        /// 	</remarks>
        /// <param name="first">player to interpolate with the second one.</param>
        /// <param name="second">player to interpolate with the first one.</param>
        public SpriterPlayerInterpolator(SpriterAbstractPlayer
			 first, SpriterAbstractPlayer second)
            : base(first.loader, first.animations)
        {
            this.weight = 0.5f;
            setPlayers(first, second);
            this.generateData();
            this.update(0, 0);
        }
 /// <summary>Note: Make sure, that both instances hold the same bone and object structure.
 ///     </summary>
 /// <remarks>
 /// Note: Make sure, that both instances hold the same bone and object structure.
 /// Otherwise you will not get the interpolation you wish.
 /// </remarks>
 /// <param name="first">SpriterPlayer instance to interpolate.</param>
 /// <param name="second">SpriterPlayer instance to interpolate.</param>
 public virtual void setPlayers(SpriterAbstractPlayer
                                first, SpriterAbstractPlayer second)
 {
     this.first         = first;
     this.second        = second;
     this.moddedBones   = this.first.moddedBones;
     this.moddedObjects = this.first.moddedObjects;
     this.first.setRootParent(this.rootParent);
     this.second.setRootParent(this.rootParent);
 }
        public virtual void activateAll(SpriterAbstractPlayer
			 player)
        {
            foreach (SpriterBone bone in player.getRuntimeBones())
            {
                bone.active = true;
            }
            foreach (SpriterObject obj in player.getRuntimeObjects())
            {
                obj.active = true;
            }
        }
 public virtual void activateEffectors(SpriterAbstractPlayer player)
 {
     foreach (SpriterIKObject key in this.ikMap.Keys)
     {
         SpriterAbstractObject obj = this.ikMap[key];
         if (obj is SpriterBone) obj = player.getRuntimeBones()[obj.getId()];
         else obj = player.getRuntimeObjects()[obj.getId()];
         obj.active = true;
         SpriterBone par = (SpriterBone)obj.getParent();
         for (int j = 0; j < key.chainLength && par != null; j++)
         {
             player.getRuntimeBones()[par.getId()].active = true;
             par = (SpriterBone)par.getParent();
         }
     }
 }
 /// <summary>Attaches a given player to this.</summary>
 /// <remarks>Attaches a given player to this.</remarks>
 /// <param name="player">indicates the player which has to be attached.</param>
 /// <param name="root">
 /// indicates the object the attached player has to follow.
 /// Set to
 /// <see cref="getRootParent()">getRootParent()</see>
 /// to attach the player to the same position as this player.
 /// </param>
 public virtual void attachPlayer(SpriterAbstractPlayer
                                  player, SpriterAbstractObject root)
 {
     this.players.Add(player);
     player.changeRootParent(root);
 }
 protected override void resolve(float x, float y, int chainLength, SpriterAbstractObject effector, SpriterAbstractPlayer player)
 {
     base.updateRecursively(player, effector);
     float xx = effector.getX() + (float)System.Math.Cos(SpriterCalculator.DegreeToRadian(effector
         .getAngle())) * Com.Brashmonkey.Spriter.draw.AbstractDrawer.BONE_LENGTH * effector
         .getScaleX();
     float yy = effector.getY() + (float)System.Math.Sin(SpriterCalculator.DegreeToRadian(effector
         .getAngle())) * Com.Brashmonkey.Spriter.draw.AbstractDrawer.BONE_LENGTH * effector
         .getScaleX();
     effector.setAngle(Com.Brashmonkey.Spriter.SpriterCalculator.angleBetween(effector
         .getX(), effector.getY(), x, y));
     if (player.getFlipX() == -1)
     {
         effector.setAngle(effector.getAngle() + 180f);
     }
     SpriterBone parent = null;
     if (effector.hasParent())
     {
         parent = player.getRuntimeBones()[effector.getParentId()];
     }
     //effector.copyValuesTo(temp);
     //SpriterCalculator.reTranslateRelative(parent, temp);
     //if(effector instanceof SpriterBone)	temp.copyValuesTo(player.lastFrame.getBones()[effector.getId()]);
     //else temp.copyValuesTo(player.lastFrame.getObjects()[effector.getId()]);
     for (int i = 0; i < chainLength && parent != null; i++)
     {
         if (Com.Brashmonkey.Spriter.SpriterCalculator.distanceBetween(xx, yy, x, y) <= this
             .tolerance)
         {
             SpriterBone p = null;
             if (parent.hasParent())
             {
                 p = player.getRuntimeBones()[parent.getParentId()];
             }
             int j = 0;
             while (p != null && j < chainLength)
             {
                 base.updateRecursively(player, p);
                 if (p.hasParent())
                 {
                     p = player.getRuntimeBones()[p.getParentId()];
                 }
                 else
                 {
                     p = null;
                 }
                 j++;
             }
             return;
         }
         parent.setAngle(parent.getAngle() + Com.Brashmonkey.Spriter.SpriterCalculator.angleDifference
             (Com.Brashmonkey.Spriter.SpriterCalculator.angleBetween(parent.getX(), parent.getY
             (), x, y), Com.Brashmonkey.Spriter.SpriterCalculator.angleBetween(parent.getX(),
             parent.getY(), xx, yy)));
         base.updateRecursively(player, parent);
         if (parent.hasParent())
         {
             parent = player.getRuntimeBones()[parent.getParent().getId()];
         }
         else
         {
             parent = null;
         }
         xx = effector.getX() + (float)System.Math.Cos(SpriterCalculator.DegreeToRadian(effector.getAngle
             ())) * Com.Brashmonkey.Spriter.draw.AbstractDrawer.BONE_LENGTH * effector.getScaleX
             ();
         yy = effector.getY() + (float)System.Math.Sin(SpriterCalculator.DegreeToRadian(effector.getAngle
             ())) * Com.Brashmonkey.Spriter.draw.AbstractDrawer.BONE_LENGTH * effector.getScaleX
             ();
     }
 }
        /// <summary>Note: Make sure, that both instances hold the same bone and object structure.
        /// 	</summary>
        /// <remarks>
        /// Note: Make sure, that both instances hold the same bone and object structure.
        /// Otherwise you will not get the interpolation you wish.
        /// </remarks>
        /// <param name="first">SpriterPlayer instance to interpolate.</param>
        /// <param name="second">SpriterPlayer instance to interpolate.</param>
        public virtual void setPlayers(SpriterAbstractPlayer
			 first, SpriterAbstractPlayer second)
        {
            this.first = first;
            this.second = second;
            this.moddedBones = this.first.moddedBones;
            this.moddedObjects = this.first.moddedObjects;
            this.first.setRootParent(this.rootParent);
            this.second.setRootParent(this.rootParent);
        }
        /// <summary>Removes the given player from this one.</summary>
        /// <remarks>Removes the given player from this one.</remarks>
        /// <param name="player">indicates the player which has to be removed.</param>
        public virtual void removePlayer(SpriterAbstractPlayer
			 player)
        {
            this.players.Remove(player);
            player.changeRootParent(null);
        }
        /// <summary>Indicates whether the given player is attached to this or not.</summary>
        /// <remarks>Indicates whether the given player is attached to this or not.</remarks>
        /// <param name="player">the player to ask after.</param>
        /// <returns>true if player is attached or not.</returns>
        public virtual bool containsPlayer(SpriterAbstractPlayer
			 player)
        {
            return this.players.Contains(player);
        }
示例#11
0
 /// <summary>Resolves the inverse kinematics constraint with a specific algtorithm</summary>
 /// <param name="x">the target x value</param>
 /// <param name="y">the target y value</param>
 /// <param name="chainLength">number of parents which are affected</param>
 /// <param name="effector">the actual effector where the resolved information has to be stored in.
 /// 	</param>
 protected abstract void resolve(float x, float y, int chainLength, SpriterAbstractObject effector, SpriterAbstractPlayer player);
示例#12
0
        protected internal virtual void updateRecursively(SpriterAbstractPlayer
			 player, SpriterAbstractObject @object)
        {
            this.updateObject(player, @object);
            if (@object is SpriterBone)
            {
                foreach (SpriterBone child in ((SpriterBone
                    )@object).getChildBones())
                {
                    this.updateRecursively(player, player.getRuntimeBones()[child.getId()]);
                }
                foreach (SpriterObject child_1 in ((SpriterBone
                    )@object).getChildObjects())
                {
                    this.updateRecursively(player, player.getRuntimeObjects()[child_1.getId()]);
                }
            }
        }
示例#13
0
        protected internal virtual void updateObject(SpriterAbstractPlayer
			 player, SpriterAbstractObject @object)
        {
            player.updateAbstractObject(@object);
        }
示例#14
0
 /// <summary>
 /// Resolves the inverse kinematics constraints with the implemented algorithm in
 /// <see cref="resolve(float, float, int, SpriterAbstractObject, SpriterAbstractPlayer)
 /// 	">resolve(float, float, int, SpriterAbstractObject, SpriterAbstractPlayer)
 /// 	</see>
 /// .
 /// </summary>
 /// <param name="player">player to apply the resolving.</param>
 public virtual void resolve(SpriterAbstractPlayer player)
 {
     foreach(SpriterIKObject key in this.ikMap.Keys)
     {
         for (int j = 0; j < key.iterations; j++)
         {
             SpriterAbstractObject obj = this.ikMap[key];
             if (obj is Com.Brashmonkey.Spriter.objects.SpriterBone) obj = player.getRuntimeBones()[obj.getId()];
             else obj = player.getRuntimeObjects()[obj.getId()];
             this.resolve(obj.getX(), obj.getY(), key.chainLength, obj, player);
         }
     }
 }
 /// <summary>Removes the given player from this one.</summary>
 /// <remarks>Removes the given player from this one.</remarks>
 /// <param name="player">indicates the player which has to be removed.</param>
 public virtual void removePlayer(SpriterAbstractPlayer
                                  player)
 {
     this.players.Remove(player);
     player.changeRootParent(null);
 }
 /// <summary>Indicates whether the given player is attached to this or not.</summary>
 /// <remarks>Indicates whether the given player is attached to this or not.</remarks>
 /// <param name="player">the player to ask after.</param>
 /// <returns>true if player is attached or not.</returns>
 public virtual bool containsPlayer(SpriterAbstractPlayer
                                    player)
 {
     return(this.players.Contains(player));
 }
        /// <summary>Attaches a given player to this.</summary>
        /// <remarks>Attaches a given player to this.</remarks>
        /// <param name="player">indicates the player which has to be attached.</param>
        /// <param name="root">
        /// indicates the object the attached player has to follow.
        /// Set to
        /// <see cref="getRootParent()">getRootParent()</see>
        /// to attach the player to the same position as this player.
        /// </param>
        public virtual void attachPlayer(SpriterAbstractPlayer
			 player, SpriterAbstractObject root)
        {
            this.players.Add(player);
            player.changeRootParent(root);
        }