57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
using Base;
|
|
using Data;
|
|
using Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace Prefab
|
|
{
|
|
public class EntityPrefab : MonoBehaviour
|
|
{
|
|
public Entity.Entity entity;
|
|
public Outline outline;
|
|
|
|
public Vector3 Position
|
|
{
|
|
get
|
|
{
|
|
return transform.position;
|
|
}
|
|
set
|
|
{
|
|
transform.position = value;
|
|
}
|
|
}
|
|
|
|
public void Init(Data.EntityDef entityDef)
|
|
{
|
|
entity.Init(entityDef);
|
|
|
|
outline.Init();
|
|
outline.Hide();
|
|
}
|
|
|
|
public void DefaultInit()
|
|
{
|
|
var animator = GetComponentsInChildren<SpriteAnimator>();
|
|
var inf = animator.Cast<ITick>().ToArray();
|
|
foreach (EntityState state in Enum.GetValues(typeof(EntityState)))
|
|
{
|
|
var orientationDict = new Dictionary<Orientation, ITick[]>();
|
|
foreach (Orientation orientation in Enum.GetValues(typeof(Orientation)))
|
|
{
|
|
orientationDict[orientation] = inf; // 所有值都指向同一个列表
|
|
}
|
|
entity.bodyAnimationNode[state] = orientationDict;
|
|
}
|
|
|
|
outline.Init();
|
|
outline.Hide();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |