using LinePutScript;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static VPet_Simulator.Core.GraphHelper;
namespace VPet_Simulator.Core
{
///
/// 动画信息
///
/// 新版本动画类型是根据整体类型+名字定义而成
/// 动画类型->动画名字
/// 动画名字->状态+动作->动画
/// 类型: 主要动作分类
/// 动画名字: 用户自定义, 同名字动画支持相同随机,不再使用StoreRand
/// 动作: 动画的动作 Start Loop End
/// 状态: 动画的状态 Save.GameSave.ModeType
public class GraphInfo
{
///
/// 创建动画信息
///
/// 动画名字: 用户自定义 同名字动画支持相同随机,不再使用StoreRand
/// 动作: 动画的动作 Start Loop End
/// 类型: 主要动作分类
/// 状态: 4种状态
public GraphInfo(string name, GraphType type = GraphType.Common, AnimatType animat = AnimatType.Single, GameSave.ModeType modeType = GameSave.ModeType.Nomal)
{
Name = name;
Animat = animat;
Type = type;
ModeType = modeType;
}
///
/// 通过文件位置和信息获取动画信息
///
/// 文件夹位置
/// 信息
public GraphInfo(FileSystemInfo path, ILine info)
{
string pn;
if (path is DirectoryInfo)
pn = Sub.Split(path.FullName.ToLower(), info[(gstr)"startuppath"].ToLower()).Last();
else
pn = Sub.Split(path.FullName.Substring(0, path.FullName.Length - path.Extension.Length).ToLower(), info[(gstr)"startuppath"].ToLower()).Last();
var path_name = pn.Replace('\\', '_').Split('_').ToList();
path_name.RemoveAll(string.IsNullOrWhiteSpace);
if (!Enum.TryParse(info[(gstr)"mode"], true, out GameSave.ModeType modetype))
{
if (path_name.Remove("happy"))
{
modetype = GameSave.ModeType.Happy;
}
else if (path_name.Remove("nomal"))
{
modetype = GameSave.ModeType.Nomal;
}
else if (path_name.Remove("poorcondition"))
{
modetype = GameSave.ModeType.PoorCondition;
}
else if (path_name.Remove("ill"))
{
modetype = GameSave.ModeType.Ill;
}
else
{
modetype = GameSave.ModeType.Nomal;
}
}
if (!Enum.TryParse(info[(gstr)"graph"], true, out GraphType graphtype))
{
graphtype = GraphInfo.GraphType.Common;
for (int i = 0; i < GraphTypeValue.Length; i++)
{//挨个找第一个匹配的
if (path_name.Contains(GraphTypeValue[i][0]))
{
int index = path_name.IndexOf(GraphTypeValue[i][0]);
bool ismatch = true;
for (int b = 1; b < GraphTypeValue[i].Length && b + index < path_name.Count; b++)
{
if (path_name[index + b] != GraphTypeValue[i][b])
{
ismatch = false;
break;
}
}
if (ismatch)
{
graphtype = (GraphType)i;
path_name.RemoveRange(index, GraphTypeValue[i].Length);
break;
}
}
}
}
if (!Enum.TryParse(info[(gstr)"animat"], true, out AnimatType animatType))
{
if (path_name.Remove("a") || path_name.Remove("start"))
{
animatType = AnimatType.A_Start;
}
else if (path_name.Remove("b") || path_name.Remove("loop"))
{
animatType = AnimatType.B_Loop;
}
else if (path_name.Remove("c") || path_name.Remove("end"))
{
animatType = AnimatType.C_End;
}
else if (path_name.Remove("single"))
{
animatType = AnimatType.Single;
}
else
{
animatType = AnimatType.Single;
}
}
Name = info.Info;
if (string.IsNullOrWhiteSpace(Name))
{
while (path_name.Count > 0 && (double.TryParse(path_name.Last(), out _) || path_name.Last().StartsWith("~")))
{
path_name.RemoveAt(path_name.Count - 1);
}
if (path_name.Count > 0)
Name = path_name.Last();
}
if (string.IsNullOrWhiteSpace(Name))
{
Name = graphtype.ToString().ToLower();
}
Type = graphtype;
Animat = animatType;
ModeType = modetype;
}
///
/// 类型: 主要动作分类
///
/// * 为必须有的动画
public enum GraphType
{
///
/// 通用动画,用于被被其他动画调用或者mod等用途
///
/// 不被默认启用/使用的 不包含在GrapType
Common,
///
/// 被提起动态 *
///
Raised_Dynamic,
///
/// 被提起静态 (开始&循环&结束) *
///
Raised_Static,
///
/// 现在所有会动的东西都是MOVE
///
Move,
///
/// 呼吸 *
///
Default,
///
/// 摸头 (开始&循环&结束)
///
Touch_Head,
///
/// 摸身体 (开始&循环&结束)
///
Touch_Body,
///
/// 空闲 (包括下蹲/无聊等通用空闲随机动画) (开始&循环&结束)
///
Idel,
///
/// 睡觉 (开始&循环&结束) *
///
Sleep,
///
/// 说话 (开始&循环&结束) *
///
Say,
///
/// 待机 模式1 (开始&循环&结束)
///
StateONE,
///
/// 待机 模式2 (开始&循环&结束)
///
StateTWO,
///
/// 开机 *
///
StartUP,
///
/// 关机
///
Shutdown,
///
/// 工作 (开始&循环&结束) *
///
Work,
///
/// 向上切换状态
///
Switch_Up,
///
/// 向下切换状态
///
Switch_Down,
///
/// 口渴
///
Switch_Thirsty,
///
/// 饥饿
///
Switch_Hunger,
}
///
/// 动作: 动画的动作 Start Loop End
///
public enum AnimatType
{
///
/// 动画只有一个动作
///
Single,
///
/// 开始动作
///
A_Start,
///
/// 循环动作
///
B_Loop,
///
/// 结束动作
///
C_End,
}
///
/// 动画名字: 用户自定义 同名字动画支持相同随机,不再使用StoreRand
///
public string Name { get; set; }
///
/// 动作: 动画的动作 Start Loop End
///
public AnimatType Animat { get; set; }
///
/// 类型: 主要动作分类
///
public GraphType Type { get; set; }
///
/// 状态: 4种状态
///
public GameSave.ModeType ModeType { get; set; }
/////
///// 其他附带的储存信息
/////
//public ILine Info { get; set; }
}
}