Files
Darklings-FightingGame/Assets/_Project/Scripts/ScriptableObjectScripts/AnimationSO.cs

95 lines
2.1 KiB
C#
Raw Normal View History

2022-09-27 10:01:43 +03:00
using System;
2022-10-01 18:02:11 +03:00
using System.Collections.Generic;
2022-11-01 21:49:47 +02:00
using Sirenix.OdinInspector;
2022-10-08 23:00:05 +03:00
using UnityEditor;
2022-09-27 10:01:43 +03:00
using UnityEngine;
using UnityEngine.U2D;
[CreateAssetMenu(fileName = "AnimationSO", menuName = "Darklings-FightingGame/AnimationSO", order = 0)]
public class AnimationSO : ScriptableObject
{
2022-10-08 23:00:05 +03:00
[SerializeField]
2022-09-27 10:01:43 +03:00
public SpriteAtlas[] spriteAtlas;
2022-10-08 23:00:05 +03:00
[SerializeField]
2022-09-27 10:01:43 +03:00
public AnimationCelsGroup[] animationCelsGroup;
public Sprite GetSprite(int skin, int group, int cel)
{
2022-10-07 10:29:42 +03:00
if (spriteAtlas.Length > 0)
{
return spriteAtlas[skin].GetSprite(animationCelsGroup[group].animationCel[cel].sprite.name);
}
else
{
return animationCelsGroup[group].animationCel[cel].sprite;
}
2022-09-27 10:01:43 +03:00
}
public AnimationCelsGroup GetGroup(int group)
{
return animationCelsGroup[group];
}
public AnimationCel GetCel(int group, int cel)
{
return animationCelsGroup[group].animationCel[cel];
}
public int GetGroupId(string name)
{
for (int i = 0; i < animationCelsGroup.Length; i++)
{
if (animationCelsGroup[i].celName == name)
{
return i;
}
}
return 0;
}
2022-10-08 23:00:05 +03:00
private void OnDisable()
{
EditorUtility.SetDirty(this);
AssetDatabase.SaveAssets();
}
2022-09-27 10:01:43 +03:00
}
[Serializable]
public struct AnimationCelsGroup
{
public string celName;
public bool loop;
2022-10-06 17:42:26 +03:00
public CameraShakerSO cameraShake;
2022-10-01 18:02:11 +03:00
public List<AnimationCel> animationCel;
2022-09-27 10:01:43 +03:00
}
[Serializable]
2022-10-01 18:02:11 +03:00
public class AnimationCel
2022-09-27 10:01:43 +03:00
{
public int frames;
public Sprite sprite;
2022-10-06 17:42:26 +03:00
public AnimationEvent animationEvent;
2022-10-02 12:58:34 +03:00
public List<AnimationBox> hitboxes;
public List<AnimationBox> hurtboxes;
2022-09-27 10:01:43 +03:00
}
2022-10-06 17:42:26 +03:00
[Serializable]
public class AnimationEvent
{
public bool jump;
2022-11-01 21:49:47 +02:00
[ShowIf("jump")]
public Vector2 jumpDirection;
2022-10-06 17:42:26 +03:00
public bool footstep;
2022-10-07 00:59:20 +03:00
public bool parry;
2022-10-08 23:00:05 +03:00
public bool projectile;
2022-10-07 14:54:38 +03:00
public bool invisibile;
2022-10-06 17:42:26 +03:00
public bool throwEnd;
2022-11-01 23:26:30 +02:00
public bool throwArcanaEnd;
2022-10-07 00:59:20 +03:00
public Vector2 grabPoint;
2022-10-06 17:42:26 +03:00
}
2022-09-27 10:01:43 +03:00
[Serializable]
2022-10-02 12:58:34 +03:00
public class AnimationBox
2022-09-27 10:01:43 +03:00
{
2022-10-02 12:58:34 +03:00
public Vector2 size;
public Vector2 offset;
2022-09-27 10:01:43 +03:00
}