Esempio n. 1
0
 /// <summary>Changes the state of each effector to unactive.</summary>
 /// <remarks>Changes the state of each effector to unactive. The effect results in non animated bodyparts.
 ///     </remarks>
 /// <param name="parents">indicates whether parents of the effectors have to be deactivated or not.
 ///     </param>
 public virtual void deactivateEffectors(SpriterAbstractPlayer player, bool parents)
 {
     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 = false;
         if (!parents)
         {
             continue;
         }
         SpriterBone par = (SpriterBone)obj.getParent();
         for (int j = 0; j < key.chainLength && par != null; j++)
         {
             player.getRuntimeBones()[par.getId()].active = false;
             par = (SpriterBone)par.getParent();
         }
     }
 }
Esempio n. 2
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);
         }
     }
 }
        private void updateTempObject(SpriterAbstractObject
                                      source, SpriterAbstractObject[] target)
        {
            bool found = false;

            for (int j = 0; j < target.Length && !found; j++)
            {
                if (source.getId() == target[j].getId())
                {
                    source.copyValuesTo(target[j]);
                    found = true;
                }
            }
        }
 public virtual void updateAbstractObject(SpriterAbstractObject @object)
 {
     if (@object.hasParent())
     {
         SpriterAbstractObject obj = (@object is SpriterBone
                                      ) ? (SpriterAbstractObject)this.lastFrame.getBones()[@object.getId()] : this.lastFrame.getObjects()[@object
                                                                                                                                          .getId()];
         SpriterCalculator.translateRelative(this.tempBones[@object
                                                            .getParentId()], obj.getX(), obj.getY(), @object);
     }
 }