96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
using Spine;
|
|
using Spine.Unity;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public class MonsterControl : MonoBehaviour
|
|
{
|
|
public MonsterDataBase monsterData = new MonsterDataBase(new MonsterHealthBase());
|
|
public SkeletonAnimation skeleton;
|
|
public bool isSpine = true;
|
|
public Dictionary<CharacterAnimationType, string> dic_AnimKeyAnimName = new Dictionary<CharacterAnimationType, string>();
|
|
public CharacterStateType currState;
|
|
//这里捕鱼的结构很简单可以穿模直接写移动
|
|
void Update()
|
|
{
|
|
OnUpdate(currState);
|
|
}
|
|
public void Start()
|
|
{
|
|
ChangeState(CharacterStateType.move);
|
|
}
|
|
public virtual void OnMoveEnter()
|
|
{
|
|
PlayAnim(CharacterAnimationType.move);
|
|
}
|
|
public virtual void OnMoveExit()
|
|
{
|
|
|
|
}
|
|
float moveTime = 0;
|
|
public virtual void OnMoveUpdata()
|
|
{
|
|
moveTime += Time.deltaTime;
|
|
|
|
//播放动画
|
|
skeleton.AnimationState.SetAnimation(0, dic_AnimKeyAnimName[CharacterAnimationType.move], true);
|
|
//transform.position = new Vector3();//等策划给路线
|
|
Vector2 v2 = monsterData.moveLine.GetBezierPoint(moveTime);
|
|
Debug.Log(v2);
|
|
transform.position = v2;
|
|
//transform.Translate(Vector3.down);
|
|
|
|
}
|
|
|
|
public void PlayAnim(CharacterAnimationType animType, bool loop = true)
|
|
{
|
|
skeleton.AnimationState.SetAnimation(0, dic_AnimKeyAnimName[animType], loop);
|
|
}
|
|
public void OnEnter(CharacterStateType stateType)
|
|
{
|
|
switch (stateType)
|
|
{
|
|
case CharacterStateType.move:
|
|
OnMoveEnter();
|
|
break;
|
|
case CharacterStateType.idle:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void OnUpdate(CharacterStateType stateType)
|
|
{
|
|
switch (stateType)
|
|
{
|
|
case CharacterStateType.move:
|
|
OnMoveUpdata();
|
|
break;
|
|
case CharacterStateType.idle:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void OnExit(CharacterStateType stateType)
|
|
{
|
|
switch (stateType)
|
|
{
|
|
case CharacterStateType.move:
|
|
break;
|
|
case CharacterStateType.idle:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
public void ChangeState(CharacterStateType stateType)
|
|
{
|
|
OnExit(currState);
|
|
currState = stateType;
|
|
OnEnter(currState);
|
|
}
|
|
}
|