Exemplo n.º 1
0
 public KartInfo(string kartName, Palette palette, bool original)
 {
     KartName       = kartName;
     KartImages     = new KartImagePool(palette);
     KartAnimations = new List <KartAnimationSeries>();
     KartPortraits  = new List <MK64Image>();
     OriginalKart   = original;
 }
Exemplo n.º 2
0
        public KartInfo(XElement xml)
        {
            KartName     = xml.Attribute(NAME).Value;
            OriginalKart = bool.Parse(xml.Attribute(ORIGINAL).Value);
            XElement imagePoolElement = xml.Element(KartImagePool.KART_IMAGE_POOL);

            if (imagePoolElement != null)
            {
                KartImages = new KartImagePool(imagePoolElement);
            }
            else
            {
                KartImages = new KartImagePool();
            }
            KartAnimations = new List <KartAnimationSeries>();
            KartPortraits  = new List <MK64Image>();

            XElement animations = xml.Element(ANIMATIONS);

            foreach (XElement animation in animations.Elements())
            {
                string name = animation.Attribute(NAME).Value;
                KartAnimationSeries newAnim = new KartAnimationSeries(name);

                newAnim.KartAnimationType = int.Parse(animation.Attribute(ANIMATION_TYPE).Value);
                foreach (XElement image in animation.Elements())
                {
                    newAnim.OrderedImageNames.Add(image.Attribute(IMAGE_NAME).Value);
                }
                KartAnimations.Add(newAnim);
            }

            XElement portraits = xml.Element(PORTRAITS);

            foreach (XElement portrait in portraits.Elements())
            {
                KartPortraits.Add(new MK64Image(portrait));
            }

            XElement namePlate = xml.Element(NAME_PLATE);

            //byte[] namePlateData = Convert.FromBase64String(namePlate.Value);
            //ushort namePlateAlpha = ushort.Parse(namePlate.Attribute(NAME_PLATE_ALPHA).Value);

            KartNamePlate = new MK64Image(namePlate.Elements().First());

            //if (RomProject.Instance.Files[0].HasElementExactlyAt(namePlateOffset))
            //{
            //    N64DataElement element = RomProject.Instance.Files[0].GetElementAt(namePlateOffset);
            //    if (element is TKMK00Block)
            //    {
            //        KartNamePlate = (TKMK00Block)element;
            //    }
            //}
        }
Exemplo n.º 3
0
        public byte[] GenerateKartAnimationPaletteData(KartImagePool images, bool isTurnAnim)
        {
            //Generate the palettes
            int paletteCount;

            if (isTurnAnim)
            {
                paletteCount = 21;
            }
            else
            {
                paletteCount = 20;
            }

            List <byte> bytes = new List <byte>();

            for (int i = 0; i < paletteCount; i++)
            {
                int imageIndex;
                if (IsTurnAnim)
                {
                    imageIndex = GetImageIndexForTurnFrame(i);
                }
                else //if (IsSpinAnim)
                {
                    imageIndex = GetImageIndexForSpinFrame(i);
                }

                KartImage image = images.Images[OrderedImageNames[imageIndex]];

                if (image.IsAnimated)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        bytes.AddRange(image.Images[j].ImageReference.BasePalettes[1].RawData);
                    }
                }
                else
                {
                    for (int j = 0; j < 4; j++)
                    {
                        bytes.AddRange(image.Images[0].ImageReference.BasePalettes[1].RawData);
                    }
                }
            }

            return(bytes.ToArray());
        }
Exemplo n.º 4
0
 //Duplicate copy
 public KartInfo(string kartName, KartInfo baseKart)
 {
     KartName   = kartName;
     KartImages = new KartImagePool(baseKart.KartImages.ImagePalette);
     foreach (string key in baseKart.KartImages.Images.Keys)
     {
         KartImages.Images.Add(key, baseKart.KartImages.Images[key]);
     }
     KartAnimations = new List <KartAnimationSeries>();
     foreach (KartAnimationSeries anim in baseKart.KartAnimations)
     {
         KartAnimationSeries newAnim = new KartAnimationSeries(anim.Name);
         newAnim.KartAnimationType = anim.KartAnimationType;
         newAnim.OrderedImageNames.AddRange(anim.OrderedImageNames);
         KartAnimations.Add(newAnim);
     }
     KartPortraits = new List <MK64Image>();
     foreach (MK64Image block in baseKart.KartPortraits)
     {
         KartPortraits.Add(block);
     }
     KartNamePlate = baseKart.KartNamePlate;
     OriginalKart  = false;
 }