format code

This commit is contained in:
EliyaFishman 2022-12-07 18:19:39 +02:00
parent b5bec07e27
commit 5818234018
12 changed files with 172 additions and 220 deletions

View file

@ -2,37 +2,14 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Bread2Unity;
using UnityEditor;
using UnityEditor.Animations;
using UnityEditor.Graphs;
using UnityEngine;
using Animation = Bread2Unity.Animation;
namespace Bread2Unity
{
public static class AnimationCreator
{
private class BccadCurve : AnimationCurve
{
private float _prev;
public new void AddKey(float time, float value)
{
if (keys.Length != 0 && !(Math.Abs(value - _prev) > 0.000001)) return;
AddKey(new Keyframe(time, value, float.PositiveInfinity, float.PositiveInfinity));
_prev = value;
}
public void CopyLastKey(float time)
{
Keyframe lastKey = keys.LastOrDefault();
base.AddKey(new Keyframe(time, keys.Length > 0 ? lastKey.value : 1, float.PositiveInfinity,
float.PositiveInfinity));
}
}
public static void CreateAnimation(BccadPrefab bccadPrefab, BCCAD bccad, PrefabData prefabData,
List<Sprite> sprites)
{
@ -42,10 +19,7 @@ namespace Bread2Unity
$"Assets\\Resources\\Sprites\\Games\\{char.ToUpperInvariant(rootPrefabName[0]) + rootPrefabName.Substring(1)}";
var animationsFolderPath = spritesFolderPath + $"/Animations/{prefabData.Name}";
if (!Directory.Exists(animationsFolderPath))
{
Directory.CreateDirectory(animationsFolderPath);
}
if (!Directory.Exists(animationsFolderPath)) Directory.CreateDirectory(animationsFolderPath);
var controller =
AnimatorController.CreateAnimatorControllerAtPath(
@ -77,7 +51,7 @@ namespace Bread2Unity
{
var animationClip = new AnimationClip();
var prefab = bccadPrefab.ParentObject;
for (int childIndex = 0; childIndex < prefab.transform.childCount; childIndex++)
for (var childIndex = 0; childIndex < prefab.transform.childCount; childIndex++)
{
var child = prefab.transform.GetChild(childIndex).gameObject;
@ -87,7 +61,7 @@ namespace Bread2Unity
var stepScaleX = new BccadCurve();
var stepScaleY = new BccadCurve();
var stepRotation = new BccadCurve();
var enabledCurve = new BccadCurve();
var xTransformCurve = new BccadCurve();
@ -116,7 +90,7 @@ namespace Bread2Unity
stepRotation.AddKey(currentTime, currentStep.Rotation);
stepScaleX.AddKey(currentTime, currentStep.StretchX);
stepScaleY.AddKey(currentTime, currentStep.StretchY);
var bccadSprite = currentStep.BccadSprite;
// Find the index of part of the game object
var partIndex = bccadSprite.parts.Select((value, index) => new { value, index })
@ -180,11 +154,8 @@ namespace Bread2Unity
if (animation.Steps.Select(step => step.Rotation).Distinct().Count() > 1)
animationClip.SetCurve("", typeof(Transform), "localEulerAngles.z", stepRotation);
if (childIndex == 0)
{
enabledCurve.CopyLastKey(currentTime);
}
if (childIndex == 0) enabledCurve.CopyLastKey(currentTime);
var spriteBinding = new EditorCurveBinding
{
@ -207,15 +178,13 @@ namespace Bread2Unity
//Check if there is any need for z animation
var setOfZIndexes = new HashSet<float>();
foreach (var sprite in spritesAssociatedWithPrefab)
{
for (int i = 0; i < sprite.parts.Count && setOfZIndexes.Count < 2; i++)
for (var i = 0; i < sprite.parts.Count && setOfZIndexes.Count < 2; i++)
{
var part = sprite.parts[i];
if (bccadPrefab.RegionToChild[part.RegionIndex] != child)
continue;
setOfZIndexes.Add(i);
}
}
if ((from part in partsOfGameObject select part.PosX).Distinct().Count() > 1 ||
(from part in partsOfGameObject select part.PosY).Distinct().Count() > 1 ||
@ -229,9 +198,7 @@ namespace Bread2Unity
}
if ((from part in partsOfGameObject select part.Rotation).Distinct().Count() > 1)
{
animationClip.SetCurve(child.name, typeof(Transform), "localEulerAngles.z", rotationCurve);
}
if ((from part in partsOfGameObject select part.StretchX).Distinct().Count() > 1 ||
(from part in partsOfGameObject select part.StretchY).Distinct().Count() > 1)
@ -257,5 +224,25 @@ namespace Bread2Unity
return animationClip;
}
private class BccadCurve : AnimationCurve
{
private float _prev;
public new void AddKey(float time, float value)
{
if (keys.Length != 0 && !(Math.Abs(value - _prev) > 0.000001)) return;
AddKey(new Keyframe(time, value, float.PositiveInfinity, float.PositiveInfinity));
_prev = value;
}
public void CopyLastKey(float time)
{
var lastKey = keys.LastOrDefault();
base.AddKey(new Keyframe(time, keys.Length > 0 ? lastKey.value : 1, float.PositiveInfinity,
float.PositiveInfinity));
}
}
}
}

View file

@ -1,34 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Bread2Unity;
using UnityEngine;
namespace Bread2Unity
{
public class BccadPrefab
{
public GameObject ParentObject { get; }
public readonly Dictionary<RegionIndex, GameObject> RegionToChild = new Dictionary<RegionIndex, GameObject>();
private readonly BCCAD _bccad;
private readonly List<GameObject> _children = new List<GameObject>();
private readonly PrefabData _data;
private readonly BCCAD _bccad;
public float HeightRatio { get; }
public float WidthRatio { get; }
public readonly Dictionary<RegionIndex, GameObject> RegionToChild = new Dictionary<RegionIndex, GameObject>();
public BccadPrefab(PrefabData data, BCCAD bccad, Texture2D texture)
{
ParentObject = new GameObject(data.Name);
_data = data;
HeightRatio = (float)texture.height / bccad.sheetH;
WidthRatio = (float)texture.width / bccad.sheetW;
HeightRatio = (float)texture.height / bccad.SheetH;
WidthRatio = (float)texture.width / bccad.SheetW;
_bccad = bccad;
CalculateParts();
}
public GameObject ParentObject { get; }
public float HeightRatio { get; }
public float WidthRatio { get; }
private void CalculateParts()
{
var defaultSprite = _bccad.sprites[_data.SpriteIndex];
var defaultSprite = _bccad.Sprites[_data.SpriteIndex];
if (_data.Animations.Count == 0)
{
for (var index = 0; index < defaultSprite.parts.Count; index++)
@ -74,10 +74,7 @@ namespace Bread2Unity
}
}
foreach (var r in regionsList)
{
RegionToChild.Add(r, child);
}
foreach (var r in regionsList) RegionToChild.Add(r, child);
childIndex++;
}
@ -91,12 +88,8 @@ namespace Bread2Unity
{
var regionsOfSprite = sprite.parts.Select(part => part.RegionIndex).ToArray();
if (regionsOfSprite.Intersect(regions).Any())
{
foreach (var r in regionsOfSprite)
{
notAdjacentRegions.Remove(r);
}
}
}
return notAdjacentRegions;
@ -104,7 +97,7 @@ namespace Bread2Unity
public List<Tuple<int, SpritePart, GameObject>> GetHiddenParts()
{
var sprite = _bccad.sprites[_data.SpriteIndex];
var sprite = _bccad.Sprites[_data.SpriteIndex];
// index, part, game object
var hiddenParts = new List<Tuple<int, SpritePart, GameObject>>();
var gameObjects = new List<GameObject>(_children);
@ -120,12 +113,13 @@ namespace Bread2Unity
var region = RegionToChild.FirstOrDefault(keyValuePair => keyValuePair.Value == gameObject)
.Key;
var partIndexPairs = _data.Animations.SelectMany(anim => anim.Steps).Select(s => s.BccadSprite)
.SelectMany(bccadSprite => bccadSprite.parts.Select((part, index) => new {part, index}));
.SelectMany(bccadSprite => bccadSprite.parts.Select((part, index) => new { part, index }));
// Get the first possible part that the game object can have.
var partIndexPair = partIndexPairs
.First(pair => pair.part.RegionIndex.Equals(region));
hiddenParts.Add(new Tuple<int, SpritePart, GameObject>(partIndexPair.index, partIndexPair.part, gameObject));
hiddenParts.Add(
new Tuple<int, SpritePart, GameObject>(partIndexPair.index, partIndexPair.part, gameObject));
}
return hiddenParts;

View file

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Bread2Unity;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using Animation = Bread2Unity.Animation;
namespace Bread2Unity
{
@ -21,7 +18,7 @@ namespace Bread2Unity
var root = PrefabUtility.LoadPrefabContents(prefabAssetPath);
foreach (var prefabData in prefabDataList)
{
var defaultSprite = bccad.sprites[prefabData.SpriteIndex];
var defaultSprite = bccad.Sprites[prefabData.SpriteIndex];
var bccadPrefab = new BccadPrefab(prefabData, bccad, texture);
var newPrefab = bccadPrefab.ParentObject;
newPrefab.transform.SetParent(root.transform);

View file

@ -1,37 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using Bread2Unity;
namespace Bread2Unity
{
public class SpriteCreator : MonoBehaviour
{
public const int PixelsPerUnit = 100;
public static Texture2D ComputeSprites(BCCAD bccad, string texturePath, string prefabName, bool shouldRotate = false)
public static Texture2D ComputeSprites(BCCAD bccad, string texturePath, string prefabName,
bool shouldRotate = false)
{
var textureName = Path.GetFileName(texturePath);
var spritesFolder =
$"Assets\\Resources\\Sprites\\Games\\{char.ToUpperInvariant(prefabName[0]) + prefabName.Substring(1)}\\";
if (!Directory.Exists(spritesFolder))
{
Directory.CreateDirectory(spritesFolder);
}
if (!Directory.Exists(spritesFolder)) Directory.CreateDirectory(spritesFolder);
var destTexturePath =
spritesFolder +
$"{textureName}";
var newTexture = new Texture2D(bccad.sheetW, bccad.sheetH);
var newTexture = new Texture2D(bccad.SheetW, bccad.SheetH);
newTexture.LoadImage(File.ReadAllBytes(texturePath));
var finalTexture = shouldRotate ? RotateTexture(newTexture) : newTexture;
finalTexture.name = textureName.Substring(0, textureName.Length - ".png".Length);
File.WriteAllBytes(destTexturePath, finalTexture.EncodeToPNG());
AssetDatabase.ImportAsset(destTexturePath);
var ti = AssetImporter.GetAtPath(destTexturePath) as TextureImporter;
if (ti != null)
{
ti.isReadable = true;
@ -43,18 +39,18 @@ namespace Bread2Unity
ti.textureCompression = TextureImporterCompression.Uncompressed;
var newData = new List<SpriteMetaData>();
var rectCtr = 0;
var heightRatio = (float)finalTexture.height / bccad.sheetH;
var widthRatio = (float)finalTexture.width / bccad.sheetW;
foreach (var r in bccad.regions)
var heightRatio = (float)finalTexture.height / bccad.SheetH;
var widthRatio = (float)finalTexture.width / bccad.SheetW;
foreach (var r in bccad.Regions)
{
var smd = new SpriteMetaData
{
pivot = new Vector2(0.5f, 0.5f),
alignment = 0,
name = finalTexture.name + "_" + rectCtr,
rect = new Rect(r.regionX * widthRatio,
finalTexture.height - (r.regionH + r.regionY) * heightRatio, r.regionW * widthRatio,
r.regionH * heightRatio)
rect = new Rect(r.RegionX * widthRatio,
finalTexture.height - (r.RegionH + r.RegionY) * heightRatio, r.RegionW * widthRatio,
r.RegionH * heightRatio)
};
newData.Add(smd);
@ -70,11 +66,11 @@ namespace Bread2Unity
public static Texture2D RotateTexture(Texture2D image)
{
Texture2D
var
target = new Texture2D(image.height, image.width, image.format,
false); //flip image width<>height, as we rotated the image, it might be a rect. not a square image
Color32[] pixels = image.GetPixels32(0);
var pixels = image.GetPixels32(0);
pixels = RotateTextureGrid(pixels, image.width, image.height);
target.SetPixels32(pixels);
target.Apply();
@ -87,15 +83,11 @@ namespace Bread2Unity
private static Color32[] RotateTextureGrid(Color32[] tex, int wid, int hi)
{
Color32[] ret = new Color32[wid * hi]; //reminder we are flipping these in the target
var ret = new Color32[wid * hi]; //reminder we are flipping these in the target
for (int y = 0; y < hi; y++)
{
for (int x = 0; x < wid; x++)
{
ret[(hi - 1) - y + x * hi] = tex[x + y * wid]; //juggle the pixels around
}
}
for (var y = 0; y < hi; y++)
for (var x = 0; x < wid; x++)
ret[hi - 1 - y + x * hi] = tex[x + y * wid]; //juggle the pixels around
return ret;
}

View file

@ -1,10 +1,7 @@
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using Bread2Unity;
using UnityEngine;
using Animation = Bread2Unity.Animation;
namespace Bread2Unity
{
@ -12,39 +9,39 @@ namespace Bread2Unity
{
public static BCCAD Read(byte[] bytes)
{
BCCAD bccad = new BCCAD();
var bccad = new BCCAD();
var byteBuffer = new ByteBuffer(bytes);
byteBuffer.ReadInt(); //timestamp
bccad.sheetW = byteBuffer.ReadUShort();
bccad.sheetH = byteBuffer.ReadUShort();
bccad.SheetW = byteBuffer.ReadUShort();
bccad.SheetH = byteBuffer.ReadUShort();
// Sprites
var spritesNum = byteBuffer.ReadInt();
for (int i = 0; i < spritesNum; i++)
for (var i = 0; i < spritesNum; i++)
{
BccadSprite bccadSprite = new BccadSprite();
var bccadSprite = new BccadSprite();
var partsNum = byteBuffer.ReadInt();
for (int j = 0; j < partsNum; j++)
for (var j = 0; j < partsNum; j++)
{
SpritePart part = new SpritePart();
var part = new SpritePart();
var region = new Region
{
regionX = byteBuffer.ReadUShort(),
regionY = byteBuffer.ReadUShort(),
regionW = byteBuffer.ReadUShort(),
regionH = byteBuffer.ReadUShort()
RegionX = byteBuffer.ReadUShort(),
RegionY = byteBuffer.ReadUShort(),
RegionW = byteBuffer.ReadUShort(),
RegionH = byteBuffer.ReadUShort()
};
var result = bccad.regions.FindIndex(x => Equals(x, region));
var result = bccad.Regions.FindIndex(x => Equals(x, region));
if (result == -1)
{
bccad.regions.Add(region);
part.RegionIndex = new RegionIndex(bccad.regions.Count - 1, 0);
bccad.Regions.Add(region);
part.RegionIndex = new RegionIndex(bccad.Regions.Count - 1, 0);
}
else
{
var repeatedNumber = bccadSprite.parts.Count(p => p.RegionIndex.Index == result);
part.RegionIndex = new RegionIndex(result, repeatedNumber);
}
part.PosX = byteBuffer.ReadShort();
part.PosY = byteBuffer.ReadShort();
part.StretchX = byteBuffer.ReadFloat();
@ -61,11 +58,8 @@ namespace Bread2Unity
Convert.ToInt32(byteBuffer.ReadByte() & 0xff) / 255f);
part.Multicolor.a = byteBuffer.ReadByte() / 255f;
for (int k = 0; k < 12; k++)
{
byteBuffer.ReadByte();
}
for (var k = 0; k < 12; k++) byteBuffer.ReadByte();
part.designation = byteBuffer.ReadByte();
part.unknown = byteBuffer.ReadShort();
@ -76,30 +70,24 @@ namespace Bread2Unity
bccadSprite.parts.Add(part);
}
bccad.sprites.Add(bccadSprite);
bccad.Sprites.Add(bccadSprite);
}
// Animations
var animationsNum = byteBuffer.ReadInt();
for (int i = 0; i < animationsNum; i++)
for (var i = 0; i < animationsNum; i++)
{
var anim = new Animation();
var nameBuilder = new StringBuilder();
var length = Convert.ToInt32(byteBuffer.ReadByte());
for (int j = 0; j < length; j++)
{
nameBuilder.Append(Convert.ToChar(byteBuffer.ReadByte()));
}
for (var j = 0; j < length; j++) nameBuilder.Append(Convert.ToChar(byteBuffer.ReadByte()));
for (var j = 0; j < 4 - (length + 1) % 4; j++) byteBuffer.ReadByte();
for (int j = 0; j < 4 - ((length + 1) % 4); j++)
{
byteBuffer.ReadByte();
}
anim.Name = nameBuilder.ToString();
anim.InterpolationInt = byteBuffer.ReadInt();
var stepsNum = byteBuffer.ReadInt();
for (int j = 0; j < stepsNum; j++)
for (var j = 0; j < stepsNum; j++)
{
var spriteIndex = byteBuffer.ReadUShort();
var step = new AnimationStep
@ -114,7 +102,7 @@ namespace Bread2Unity
Color = new Color(Convert.ToInt32(byteBuffer.ReadByte() & 0xff) / 255f,
Convert.ToInt32(byteBuffer.ReadByte() & 0xff) / 255f,
Convert.ToInt32(byteBuffer.ReadByte() & 0xff) / 255f),
BccadSprite = bccad.sprites[spriteIndex]
BccadSprite = bccad.Sprites[spriteIndex]
};
byteBuffer.ReadByte();
byteBuffer.ReadByte();
@ -123,7 +111,7 @@ namespace Bread2Unity
anim.Steps.Add(step);
}
bccad.animations.Add(anim);
bccad.Animations.Add(anim);
}
return bccad;

View file

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEditor;
using Bread2Unity;
using UnityEngine;
namespace Bread2Unity
{
@ -13,38 +11,22 @@ namespace Bread2Unity
private const string EditorFolderName = "bread2unity";
private const float Width = 657;
private const float Height = 442;
private GameObject _prefab;
private readonly List<string> _animationsIndexes = new List<string>();
private readonly List<PrefabData> _prefabDataList = new List<PrefabData>();
private DataModel _animation;
private List<PrefabData> _prefabDataList = new List<PrefabData>();
private List<string> _animationsIndexes = new List<string> ();
private bool _shouldRotate;
private GameObject _prefab;
private Vector2 _scrollPosition;
[MenuItem("Tools/bread2unity")]
public static void ShowWindow()
{
var window = GetWindow<Bread2UnityGUI>("bread2unity");
var x = Screen.currentResolution.width / 2f - Width;
var y = Screen.currentResolution.height / 2f - Height;
window.position = new Rect(x,y,Width,Height);
}
public void CreateGUI()
{
_animationsIndexes.Add("");
_prefabDataList.Add(new PrefabData("", 0));
}
private bool _shouldRotate;
public void OnGUI()
{
// Logo
Texture logo =
var logo =
(Texture)AssetDatabase.LoadAssetAtPath($"Assets/Editor/{EditorFolderName}/logo.png", typeof(Texture));
GUILayout.Box(logo, GUILayout.ExpandWidth(true), GUILayout.Height(60));
GUILayout.Space(30);
GUIStyle desc = EditorStyles.label;
var desc = EditorStyles.label;
desc.wordWrap = true;
desc.fontStyle = FontStyle.BoldAndItalic;
// Description
@ -110,7 +92,7 @@ namespace Bread2Unity
_shouldRotate = GUILayout.Toggle(_shouldRotate, "Rotate Spritesheet");
GUILayout.Space(12f);
// Create button
if (GUILayout.Button("Generate Assets") && _prefab != null)
{
@ -123,9 +105,10 @@ namespace Bread2Unity
if (!string.IsNullOrEmpty(pngFilePath))
{
var bccad = BCCAD.Read(File.ReadAllBytes(bccadFilePath));
var spriteTexture = SpriteCreator.ComputeSprites(bccad, pngFilePath, _prefab.name, _shouldRotate);
var spriteTexture =
SpriteCreator.ComputeSprites(bccad, pngFilePath, _prefab.name, _shouldRotate);
//Create prefab from prefab data
for (int i = 0; i < _prefabDataList.Count; i++)
for (var i = 0; i < _prefabDataList.Count; i++)
{
List<int> animationIndexes;
var prefabData = _prefabDataList[i];
@ -134,7 +117,7 @@ namespace Bread2Unity
else
animationIndexes = _animationsIndexes[i].Split(',').Select(int.Parse).ToList();
prefabData.Animations =
animationIndexes.Select(index => bccad.animations[index]).ToList();
animationIndexes.Select(index => bccad.Animations[index]).ToList();
}
PrefabCreator.CreatePrefab(_prefab, bccad, _prefabDataList, spriteTexture);
@ -143,14 +126,28 @@ namespace Bread2Unity
}
GUILayout.Space(12f);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Bread Download", GUILayout.Height(40)))
{
Application.OpenURL("https://github.com/rhmodding/bread");
}
GUILayout.EndHorizontal();
}
public void CreateGUI()
{
_animationsIndexes.Add("");
_prefabDataList.Add(new PrefabData("", 0));
}
[MenuItem("Tools/bread2unity")]
public static void ShowWindow()
{
var window = GetWindow<Bread2UnityGUI>("bread2unity");
var x = Screen.currentResolution.width / 2f - Width;
var y = Screen.currentResolution.height / 2f - Height;
window.position = new Rect(x, y, Width, Height);
}
}
}

View file

@ -6,14 +6,14 @@ namespace Bread2Unity
{
private readonly byte[] _bytes;
public int ReadPoint{ get; private set; }
public ByteBuffer(byte[] bytes)
{
_bytes = bytes;
ReadPoint = 0;
}
public int ReadPoint { get; private set; }
public ushort ReadUShort()
{
var result = BitConverter.ToUInt16(_bytes, ReadPoint);
@ -30,21 +30,21 @@ namespace Bread2Unity
public float ReadFloat()
{
float result = BitConverter.ToSingle(_bytes, ReadPoint);
var result = BitConverter.ToSingle(_bytes, ReadPoint);
ReadPoint += sizeof(float);
return result;
}
public byte ReadByte()
{
byte result = _bytes[ReadPoint];
var result = _bytes[ReadPoint];
ReadPoint += sizeof(byte);
return result;
}
public int ReadInt()
{
int result = BitConverter.ToInt32(_bytes, ReadPoint);
var result = BitConverter.ToInt32(_bytes, ReadPoint);
ReadPoint += sizeof(int);
return result;
}

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -6,30 +5,29 @@ namespace Bread2Unity
{
public class Animation
{
public List<AnimationStep> Steps = new List<AnimationStep>();
public string Name;
public int InterpolationInt = 0;
public string Name;
public List<AnimationStep> Steps = new List<AnimationStep>();
public bool Interpolated => (InterpolationInt & 0b1) > 0;
}
public class AnimationStep
{
public BccadSprite BccadSprite;
public Color Color; //needs to add
public ushort Delay;
public BccadSprite BccadSprite;
public short TranslateX;
public short TranslateY;
public float Depth;
public float StretchX;//needs to add
public float StretchY; //needs to add
public byte Opacity; //needs to add
public float Rotation; //needs to add
public byte Opacity;//needs to add
public Color Color;//needs to add
public float StretchX; //needs to add
public float StretchY; //needs to add
public short TranslateX;
public short TranslateY;
}
}

View file

@ -1,5 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -12,28 +10,29 @@ namespace Bread2Unity
public class SpritePart
{
public RegionIndex RegionIndex;
public float blDepth;
public float brDepth;
public short PosX;
public short PosY;
public float StretchX;
public float StretchY;
public float Rotation;
public byte designation;
public bool FlipX;
public bool FlipY;
public byte designation;
public short unknown;
public float tlDepth;
public float blDepth;
public float trDepth;
public float brDepth;
public Color Multicolor;
public short PosX;
public short PosY;
public RegionIndex RegionIndex;
public float Rotation;
public Color ScreenColor;
public float StretchX;
public float StretchY;
public float tlDepth;
public float trDepth;
public short unknown;
// public Color GetColor() => new Color(Multicolor.r, Multicolor.g, Multicolor.b, Multicolor.a);
}
@ -60,7 +59,7 @@ namespace Bread2Unity
public override int GetHashCode()
{
int hash = 23;
var hash = 23;
hash = hash * 31 + Index;
hash = hash * 31 + RepeatedNumber;
return hash;

View file

@ -1,52 +1,52 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Bread2Unity
{
public class DataModel
{
public List<Region> regions = new List<Region>();
public List<BccadSprite> sprites = new List<BccadSprite>();
public List<Animation> animations = new List<Animation>();
public int sheetW;
public int sheetH;
public List<Animation> Animations = new List<Animation>();
public List<Region> Regions = new List<Region>();
public int SheetH;
public int SheetW;
public List<BccadSprite> Sprites = new List<BccadSprite>();
}
public class Region
{
public ushort regionX;
public ushort regionY;
public ushort regionW;
public ushort regionH;
public ushort RegionH;
public ushort RegionW;
public ushort RegionX;
public ushort RegionY;
public override string ToString()
{
return $"regionX: {regionX} regionY: {regionY} regionW: {regionW} regionH: {regionH}";
return $"regionX: {RegionX} regionY: {RegionY} regionW: {RegionW} regionH: {RegionH}";
}
protected bool Equals(Region other)
{
return regionX == other.regionX && regionY == other.regionY && regionW == other.regionW &&
regionH == other.regionH;
return RegionH == other.RegionH && RegionW == other.RegionW && RegionX == other.RegionX &&
RegionY == other.RegionY;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (obj.GetType() != GetType()) return false;
return Equals((Region)obj);
}
public override int GetHashCode()
{
int hash = 23;
hash = hash * 31 + regionX;
hash = hash * 31 + regionY;
hash = hash * 31 + regionW;
hash = hash * 31 + regionH;
return hash;
unchecked
{
var hashCode = RegionH.GetHashCode();
hashCode = (hashCode * 397) ^ RegionW.GetHashCode();
hashCode = (hashCode * 397) ^ RegionX.GetHashCode();
hashCode = (hashCode * 397) ^ RegionY.GetHashCode();
return hashCode;
}
}
}
}

View file

@ -1,12 +1,11 @@
using System.Collections.Generic;
using Bread2Unity;
namespace Bread2Unity
{
public class PrefabData
{
public string Name;
public List<Animation> Animations;
public string Name;
public int SpriteIndex;
public PrefabData(string name, int spriteIndex)

View file

@ -20,6 +20,7 @@ Rhythm Heaven animation to Unity animation converter
- [X] remove bccad test
- [X] add default line for bcaad data
- [X] change window height and width
- [x] fix imports
- [ ] change sprite order with sprite renderer.
- [ ] write a normal readme