示例#1
0
 public override void Declare(AC.Char _character)
 {
     character                   = _character;
     turningStyle                = TurningStyle.Linear;
     isSpriteBased               = true;
     character.doDirections      = true;
     character.doDiagonals       = true;
     SpineData                   = character.GetComponent <SpineData> ();
     CharSpine                   = character.GetComponent <CharSpine> ();
     CharSpine.skeletonAnimation = character.spriteChild.GetComponent <SkeletonAnimation> ();
 }
示例#2
0
        private static void MakeSpine(SpineData data)
        {
            var bones = MakeBones(data.Bones);
            var slots = MakeSlots(data.Slots, bones);

            foreach (var skin in data.Skins)
            {
                foreach (var slotInfo in skin.Value)
                {
                    // MakeAttachments(attachmentsData.ToDictionary(e => e.Key, e => e.Value), slots, data.Slots);
                    MakeSlotAttachment(slots[slotInfo.Key], slotInfo.Value.ToDictionary(e => e.Key, e => e.Value));
                }
            }
        }
示例#3
0
 void Update()
 {
     for (int i = mBodys.Count - 1; i >= 0; i--)
     {
         SpineData sd = mBodys[i];
         if ((sd.lifeTime -= Time.deltaTime / GhostLifeTime) > 0)
         {
             sd.body.SetColor(new Color(GhostColor.r, GhostColor.g, GhostColor.b, sd.lifeTime));
         }
         else
         {
             sd.body.gameObject.SetActive(false);
             mPools.Add(sd.body);
             mBodys.Remove(sd);
         }
     }
 }
示例#4
0
    public void CreateNewSpecies()
    {
        // First we must generate all random variables

        // First, define leg dimensions
        // Note, radii should always be less than length for stability, and ideally much less
        float frontHipRadius = 0.5f;
        float frontThighLength = 0.7f;  float frontThighRoundness = 0.6f;
        float frontKneeRadius = 0.4f;
        float frontCalfLength = 0.7f;   float frontCalfRoundness = 0.3f;
        float frontAnkleRadius = 0.3f;
        float frontFootLength = 0.6f;   float frontFootRoundness = 0.6f;
        float frontFootRadius = 0.4f;
        float frontToeLength = 0.5f;    float frontToeRoundness = 0.5f;
        float frontToeRadius = 0.3f;

        float backHipRadius = 0.7f;
        float backThighLength = 1.3f;   float backThighRoundness = 0.3f;
        float backKneeRadius = 0.4f;
        float backCalfLength = 1.2f;    float backCalfRoundness = 0.6f;
        float backAnkleRadius = 0.3f;
        float backFootLength = 0.6f;    float backFootRoundness = 0.7f;
        float backFootRadius = 0.2f;
        float backToeLength = 0.3f;             float backToeRoundness = 0.9f;
        float backToeRadius = 0.1f;

        // Data containers must be created for each segment
        BodySegmentMeshData fr_thighData = new BodySegmentMeshData(frontThighLength, frontHipRadius, frontKneeRadius, frontThighRoundness, 12);
        BodySegmentMeshData fr_calfData  = new BodySegmentMeshData(frontCalfLength, frontKneeRadius, frontAnkleRadius, frontCalfRoundness, 12);
        BodySegmentMeshData fr_footData  = new BodySegmentMeshData(frontFootLength, frontAnkleRadius, frontFootRadius, frontFootRoundness, 12);
        BodySegmentMeshData fr_toeData   = new BodySegmentMeshData(frontToeLength, frontFootRadius, frontToeRadius, frontToeRoundness, 12);

        BodySegmentMeshData bk_thighData = new BodySegmentMeshData(backThighLength, backHipRadius, backKneeRadius, backThighRoundness, 12);
        BodySegmentMeshData bk_calfData  = new BodySegmentMeshData(backCalfLength, backKneeRadius, backAnkleRadius, backCalfRoundness, 12);
        BodySegmentMeshData bk_footData  = new BodySegmentMeshData(backFootLength, backAnkleRadius, backFootRadius, backFootRoundness, 12);
        BodySegmentMeshData bk_toeData   = new BodySegmentMeshData(backToeLength, backFootRadius, backToeRadius, backToeRoundness, 12);

        // LegData objects can now be created by passing in segment data
        // Front and back legs have separate leg data
        m_frontLegData             = new LegData(fr_thighData, fr_calfData, fr_footData, fr_toeData);
        m_frontLegData.reverseKnee = true;         // Front legs bend the opposite way
        m_backLegData = new LegData(bk_thighData, bk_calfData, bk_footData, bk_toeData);

        // Creating the leg data has also defined the height at which each leg stands
        // Use this to set the default heights for the spine
        float shoulderHeight = m_frontLegData.legLength;
        float pelvisHeight   = m_backLegData.legLength;

        // Define other random variables for the spine
        float shoulderRadius = 0.8f;
        float torsoLength = 1.2f;       float torsoRoundness = 0.8f;
        float chestRadius = 1.0f;
        float waistLength = 1.5f;       float waistRoundness = 0.2f;
        float waistRadius = 0.8f;
        float pelvisLength = 1.2f;      float pelvisRoundness = 0.4f;
        float hipRadius = 0.6f;

        BodySegmentMeshData torsoData  = new BodySegmentMeshData(torsoLength, chestRadius, shoulderRadius, torsoRoundness, 20);
        BodySegmentMeshData waistData  = new BodySegmentMeshData(waistLength, waistRadius, chestRadius, waistRoundness, 20);
        BodySegmentMeshData pelvisData = new BodySegmentMeshData(pelvisLength, hipRadius, waistRadius, pelvisRoundness, 20);

        m_spineData = new SpineData(torsoData, waistData, pelvisData, 0.0f, 0.0f);
        Debug.Log("Checking, spine length is " + m_spineData.spineLength);
        m_legSeparation  = Mathf.Sqrt(m_spineData.spineLength * m_spineData.spineLength - (shoulderHeight - pelvisHeight) * (shoulderHeight - pelvisHeight));
        m_spineElevation = Mathf.Rad2Deg * Mathf.Asin((shoulderHeight - pelvisHeight) / m_spineData.spineLength);
        Debug.Log("Leg separation: " + m_legSeparation + ", Spine elevation: " + m_spineElevation);


        // Define tail dimensions
        m_tailLength   = 5.0f;
        m_tailTaper    = 0.8f;
        m_tailSegments = 6;



        // Create animations
        // Animations are based only on species variables defined above
        //AnimationGenerator animGenerator = new AnimationGenerator(this);
        //m_clips = animGenerator.GenerateAnimation();
        m_clips = new ClipContainer(this);
        m_clips.EnableAnimationGroup(ClipContainer.AnimType.IDLE);
        //ClipContainer clips = new ClipContainer(species);
        //clips.EnableAnimationGroup(ClipContainer.AnimType.IDLE);
        Debug.Log("m_clips = " + m_clips);
    }