126 lines
3.1 KiB
C#
126 lines
3.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DragonLi.Core;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
public class PuzzleTask : Task
|
|
{
|
|
public PlayerModel player;
|
|
public GameObject puzzle;
|
|
public List<PuzzleItem> puzzleItems=new List<PuzzleItem>();
|
|
|
|
public bool isGetPuzzle = false;
|
|
|
|
private void Start()
|
|
{
|
|
player.gameObject.SetActive(false);
|
|
puzzle.SetActive(false);
|
|
}
|
|
|
|
public override void StartTask()
|
|
{
|
|
base.StartTask();
|
|
winTaskTime = Random.Range(40, 61);
|
|
endTaskTime = 60;
|
|
GameManager.Ins.playerRightHand._isOpenLine = true;
|
|
isGetPuzzle = false;
|
|
player.gameObject.SetActive(true);
|
|
puzzle.SetActive(true);
|
|
player.Init();
|
|
}
|
|
|
|
public void InitData()
|
|
{
|
|
|
|
}
|
|
|
|
public void GetPuzzle(int id)
|
|
{
|
|
if (isGetPuzzle||isEnd)
|
|
return;
|
|
foreach (var item in puzzleItems)
|
|
{
|
|
if (item.id == id&& !item.IsFly)
|
|
{
|
|
item.isSelect = true;
|
|
isGetPuzzle = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void TryPuzzle()
|
|
{
|
|
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
|
|
base.Update();
|
|
if (GameManager.Ins == null || !GameManager.Ins.playerRightHand)
|
|
return;
|
|
if (isEnd)
|
|
return;
|
|
foreach (var item in puzzleItems)
|
|
{
|
|
if (item && GameManager.Ins.playerRightHand.hit)
|
|
{
|
|
var x = GameManager.Ins.playerRightHand.hit.transform.GetComponent<PuzzleItem>();
|
|
if (x == null)
|
|
continue;
|
|
if ((x.id == item.id))
|
|
{
|
|
item.ShowOutline();
|
|
break;
|
|
}
|
|
}
|
|
item.GetComponent<PuzzleItem>().HideOutline();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public override void EndTask()
|
|
{
|
|
base.EndTask();
|
|
StartCoroutine(StartEndTask());
|
|
}
|
|
|
|
IEnumerator StartEndTask()
|
|
{
|
|
GameManager.Ins.PlaySound2DRPC("1.16");
|
|
foreach (var item in puzzleItems)
|
|
{
|
|
if (item.gameObject.activeSelf && item.id <= 5)
|
|
{
|
|
item.StartFlyTarget(player.dress[item.id].transform.position, player.dress[item.id].transform.eulerAngles);
|
|
yield return new WaitForSeconds(1.5f);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public override void CompleteTask()
|
|
{
|
|
base.CompleteTask();
|
|
|
|
foreach (var item in puzzleItems)
|
|
{
|
|
item.gameObject.SetActive(false);
|
|
}
|
|
GameManager.Ins.PlaySound2DRPC("1.17");
|
|
puzzle.SetActive(false);
|
|
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
|
{
|
|
player.gameObject.SetActive(false);
|
|
GameManager.Ins.enemy.Show();
|
|
GameManager.Ins.enemy.SetState(3);
|
|
GameManager.Ins.taskManager.StartTask();
|
|
},3);
|
|
}
|
|
|
|
}
|