68 lines
1.4 KiB
C#
68 lines
1.4 KiB
C#
![]() |
using DG.Tweening;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class Shu : Interactable
|
||
|
{
|
||
|
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>();
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void OnCall()
|
||
|
{
|
||
|
|
||
|
switch (interactState) {
|
||
|
case 0:
|
||
|
ItemController.Instance.AddItem(Stick1);
|
||
|
ItemController.Instance.AddItem(Stick2);
|
||
|
ChangesDuringIntertacting();
|
||
|
break;
|
||
|
case 1:
|
||
|
transform.DORotate(new Vector3(0, 0, -90), rotateDuration);
|
||
|
ChangesDuringIntertacting();
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void ResetInteracting() {
|
||
|
interating = false;
|
||
|
CancleEvent();
|
||
|
}
|
||
|
|
||
|
void ChangesDuringIntertacting()
|
||
|
{
|
||
|
if (interating==false) {
|
||
|
player.ToMap("Null");
|
||
|
interactState++;
|
||
|
interating = true;
|
||
|
Invoke(nameof(ResetInteracting), rotateDuration);}
|
||
|
}
|
||
|
|
||
|
public override void CancleEvent()
|
||
|
{
|
||
|
player.ToMap("Normal");
|
||
|
|
||
|
}
|
||
|
}
|