lspdC 44c4946a71 3.20
整理了树木交互,写了个具体互动物品的基类。
创建了火类,实现火焰交互示意(拿上木棍才能成功交互)。
2022-03-20 23:24:29 +08:00

73 lines
1.6 KiB
C#

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shu : Interacter
{
Animator anim;
public float rotateDuration=0.5f;
SpriteRenderer m_spr;
public Sprite sprite_Mu;
public Item Stick1;
public Item Stick2;
override protected void Start()
{
base.Start();
m_spr = GetComponent<SpriteRenderer>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
public override void OnCall()
{
switch (interactState) {
//交互的第一阶段,掉落树枝
case 0:
ChangesDuringIntertacting(1f);
//树抖两下
anim.SetTrigger("Shake");
ItemController.Instance.AddItem(Stick1);
ItemController.Instance.AddItem(Stick2);
//ItemController.Instance.ToLastestItem();
break;
//交互的第二阶段,推倒树木
case 1:
ChangesDuringIntertacting(rotateDuration);
anim.SetTrigger("Fall");
//transform.DORotate(new Vector3(0, 0, -90), rotateDuration);
break;
default:
break;
}
}
override protected void ChangesDuringIntertacting(float time)
{
base.ChangesDuringIntertacting(time);
}
public override void CancleEvent()
{
player.ToMap("Normal");
}
}