2022-03-15 20:26:46 +08:00
|
|
|
using DG.Tweening;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class Shu : Interactable
|
|
|
|
{
|
2022-03-19 23:02:32 +08:00
|
|
|
Animator anim;
|
|
|
|
|
2022-03-15 20:26:46 +08:00
|
|
|
int interactState = 0;
|
|
|
|
public float rotateDuration=0.5f;
|
|
|
|
SpriteRenderer m_spr;
|
|
|
|
public Sprite sprite_Mu;
|
|
|
|
bool interating = false;
|
|
|
|
|
|
|
|
public Item Stick1;
|
|
|
|
public Item Stick2;
|
|
|
|
|
|
|
|
override protected void Start()
|
|
|
|
{
|
|
|
|
base.Start();
|
|
|
|
m_spr = GetComponent<SpriteRenderer>();
|
2022-03-19 23:02:32 +08:00
|
|
|
anim = GetComponent<Animator>();
|
2022-03-15 20:26:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnCall()
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (interactState) {
|
2022-03-19 23:02:32 +08:00
|
|
|
//交互的第一阶段,掉落树枝
|
|
|
|
case 0:
|
|
|
|
ChangesDuringIntertacting(1f);
|
|
|
|
//树抖两下
|
|
|
|
anim.SetTrigger("Shake");
|
2022-03-15 20:26:46 +08:00
|
|
|
ItemController.Instance.AddItem(Stick1);
|
|
|
|
ItemController.Instance.AddItem(Stick2);
|
2022-03-19 23:02:32 +08:00
|
|
|
|
|
|
|
//ItemController.Instance.ToLastestItem();
|
|
|
|
|
2022-03-15 20:26:46 +08:00
|
|
|
break;
|
2022-03-19 23:02:32 +08:00
|
|
|
//交互的第二阶段,推倒树木
|
2022-03-15 20:26:46 +08:00
|
|
|
case 1:
|
2022-03-19 23:02:32 +08:00
|
|
|
ChangesDuringIntertacting(rotateDuration);
|
|
|
|
anim.SetTrigger("Fall");
|
|
|
|
//transform.DORotate(new Vector3(0, 0, -90), rotateDuration);
|
2022-03-15 20:26:46 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetInteracting() {
|
|
|
|
interating = false;
|
|
|
|
CancleEvent();
|
|
|
|
}
|
|
|
|
|
2022-03-19 23:02:32 +08:00
|
|
|
void ChangesDuringIntertacting(float Time)
|
2022-03-15 20:26:46 +08:00
|
|
|
{
|
|
|
|
if (interating==false) {
|
|
|
|
player.ToMap("Null");
|
|
|
|
interactState++;
|
|
|
|
interating = true;
|
2022-03-19 23:02:32 +08:00
|
|
|
Invoke(nameof(ResetInteracting), Time);}
|
2022-03-15 20:26:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void CancleEvent()
|
|
|
|
{
|
|
|
|
player.ToMap("Normal");
|
|
|
|
|
|
|
|
}
|
2022-03-19 23:02:32 +08:00
|
|
|
|
|
|
|
public void ChangeToLastWeapon() {
|
|
|
|
ItemController.Instance.ToLastestItem();
|
|
|
|
}
|
2022-03-15 20:26:46 +08:00
|
|
|
}
|