225 lines
6.1 KiB
C#
225 lines
6.1 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
public class CharacterInturn : MonoBehaviour
|
||
{
|
||
|
||
private Button recubtn;//안賭객큐
|
||
private Button disbtn;//토든芎객큐
|
||
private Button connectgun;//젯쌈彊퓜객큐
|
||
private Button connectfa;//젯쌈彊랫객큐
|
||
private Button openfa;//댔역彊랫객큐
|
||
|
||
|
||
private CharacterAin Characterain;
|
||
|
||
private int XfsStep = 0;
|
||
public GameObject Peidianpoint;
|
||
public GameObject cha;
|
||
public GameObject xfs;
|
||
public GameObject Dian;
|
||
private GameObject timer;
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
xfs = GameObject.Find("Canvas/xfs");
|
||
|
||
recubtn = GameObject.Find("Canvas/Recuse").GetComponent<Button>();
|
||
disbtn = GameObject.Find("Canvas/Distribution box").GetComponent<Button>();
|
||
connectgun = GameObject.Find("Canvas/xfs/ConnectGun").GetComponent<Button>();
|
||
connectfa = GameObject.Find("Canvas/xfs/ConnectFa").GetComponent<Button>();
|
||
openfa = GameObject.Find("Canvas/xfs/OpenFa").GetComponent<Button>();
|
||
Characterain = this.GetComponent<CharacterAin>();
|
||
//animator = this.GetComponent<Animator>();
|
||
// stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
||
|
||
timer = GameObject.Find("Canvas/Timer");
|
||
|
||
recubtn.gameObject.SetActive(false);
|
||
disbtn.gameObject.SetActive(false);
|
||
xfs.gameObject.SetActive(false);
|
||
|
||
|
||
recubtn.onClick.AddListener(Recuse);
|
||
disbtn.onClick.AddListener(disClick);
|
||
connectgun.onClick.AddListener(CgunClick);
|
||
connectfa.onClick.AddListener(CfaClick);
|
||
openfa.onClick.AddListener(OfaClick);
|
||
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
|
||
}
|
||
|
||
void Recuse()//안賭꾸鱗
|
||
{
|
||
Characterain.SetSkillAin(CharacterSkill.Rescue);
|
||
StartCoroutine(Rescuereturn(7f));
|
||
}
|
||
|
||
void disClick()//토든芎꾸鱗
|
||
{
|
||
GameObject ob = Instantiate(Dian);
|
||
ob.transform.SetParent(Peidianpoint.transform);
|
||
ob.transform.localPosition = new Vector3(0, 0, 0);
|
||
StartCoroutine(AnimTimeSuccefful(6f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateSuccess);
|
||
Destroy(disbtn.gameObject);
|
||
Destroy(ob,6f);
|
||
}
|
||
|
||
void CgunClick()//젯쌈彊퓜꾸鱗
|
||
{
|
||
if (XfsStep == 0)
|
||
{
|
||
//獵契꾸鱗땡뺌
|
||
Debug.Log("젯쌈彊퓜");
|
||
CoGunHide(0);
|
||
XfsStep++;
|
||
StartCoroutine(AnimTimeSuccefful(6f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateSuccess);
|
||
}
|
||
else
|
||
{
|
||
|
||
//獵契꾸鱗呵겨땡뺌
|
||
Debug.Log("꾸鱗呵겨,路劤역迦");
|
||
XfsStep = 0;
|
||
CoGunHide(0);
|
||
StartCoroutine(AnimTimeFail(2f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateFail);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
void CfaClick()//젯쌈彊랫꾸鱗
|
||
{
|
||
if (XfsStep == 1)
|
||
{
|
||
//獵契꾸鱗땡뺌
|
||
Debug.Log("젯쌈彊랫");
|
||
CoGunHide(1);
|
||
XfsStep++;
|
||
StartCoroutine(AnimTimeSuccefful(6f));
|
||
connectfa.gameObject.SetActive(false);
|
||
Characterain.SetSkillAin(CharacterSkill.OperateSuccess);
|
||
}
|
||
else
|
||
{
|
||
//獵契꾸鱗呵겨땡뺌
|
||
XfsStep = 0;
|
||
CoGunHide(0);
|
||
StartCoroutine(AnimTimeFail(2f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateFail);
|
||
}
|
||
|
||
}
|
||
|
||
void OfaClick()//댔역彊랫꾸鱗
|
||
{
|
||
if (XfsStep == 2)
|
||
{
|
||
//獵契꾸鱗땡뺌
|
||
Debug.Log("댔역彊랫");
|
||
CoGunHide(1);
|
||
XfsStep++;
|
||
StartCoroutine(AnimTimeSuccefful(6f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateSuccess);
|
||
|
||
}
|
||
else
|
||
{
|
||
//獵契꾸鱗呵겨땡뺌
|
||
XfsStep = 0;
|
||
CoGunHide(0);
|
||
StartCoroutine(AnimTimeFail(2f));
|
||
Characterain.SetSkillAin(CharacterSkill.OperateFail);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
IEnumerator AnimTimeSuccefful(float timer)//꾸鱗냥묘獵契돨葵넋
|
||
{
|
||
TimerMgr.Instance.StartCooldown(timer, HandleCooldownFinished); // 눈흙잤홱珂쇌뵨써監慤숭
|
||
yield return null;
|
||
|
||
}
|
||
|
||
IEnumerator AnimTimeFail(float timer)//꾸鱗呵겨獵契돨葵넋
|
||
{
|
||
TimerMgr.Instance.StartCooldown(timer, HandleCooldownFinishedFailed);
|
||
yield return null;
|
||
}
|
||
|
||
void HandleCooldownFinished()//句렝堈꾸鱗냥묘,侶쟁警속寧몸慤숭痰윱뇹잿셕珂포잤홱세減빈돨쭉서
|
||
{
|
||
Characterain.SetSkillAin(CharacterSkill.NoSkill);
|
||
CoApper();
|
||
}
|
||
|
||
void HandleCooldownFinishedFailed()//句렝堈꾸鱗呵겨써監빈돨慤숭뇹잿,警속寧몸홍애돨폭텟뎐눗
|
||
{
|
||
PromptMgr.Instance.PromptBubble("꾸鱗呵겨");
|
||
Characterain.SetSkillAin(CharacterSkill.NoSkill);
|
||
CoApper();
|
||
|
||
}
|
||
|
||
IEnumerator Rescuereturn(float timer)//葵넋茄君npc굳안賭냥묘빈쏵契낮잼
|
||
{
|
||
recubtn.gameObject.SetActive(false);
|
||
TimerMgr.Instance.StartCooldown(timer,HandleRescue);
|
||
yield return null;
|
||
|
||
|
||
}
|
||
void HandleRescue()//안賭냥묘빈뚤훙膠땡鱗쏵契돨뇹잿,鹿섟npc품鞏寧땍뒈듐돨뇹잿
|
||
{
|
||
Characterain.SetSkillAin(CharacterSkill.NoSkill);
|
||
cha.GetComponent<RecuseNpc>().Setnpcstate();
|
||
}
|
||
void CoGunHide(int Hide)//獵契땡鱗퍅쇌뚤객큐쏵契茶꾜
|
||
{
|
||
switch (Hide)
|
||
{
|
||
case 0:
|
||
connectgun.gameObject.SetActive(false);
|
||
connectfa.gameObject.SetActive(false);
|
||
openfa.gameObject.SetActive(false);
|
||
break;
|
||
case 1:
|
||
openfa.gameObject.SetActive(false);
|
||
break;
|
||
}
|
||
}
|
||
|
||
void CoApper()//鞫刻뎠품꼍朧壇맡놔君돨객큐
|
||
{
|
||
switch (XfsStep)
|
||
{
|
||
case 0:
|
||
connectgun.gameObject.SetActive(true);
|
||
connectfa.gameObject.SetActive(true);
|
||
openfa.gameObject.SetActive(true);
|
||
break;
|
||
case 1:
|
||
connectfa.gameObject.SetActive(true);
|
||
openfa.gameObject.SetActive(true);
|
||
break;
|
||
case 2:
|
||
openfa.gameObject.SetActive(true);
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
}
|