127 lines
3.6 KiB
C#
127 lines
3.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using ZXKFramework;
|
|
|
|
public class ShiTuStateMain : StateBase
|
|
{
|
|
ModelChildShowOne allShiTu;
|
|
List<ShiTuItem> allShituItem = new List<ShiTuItem>();
|
|
private ShiTuBomb curModel;
|
|
ModelChildShowOne loModelChildShowOne = new ModelChildShowOne();
|
|
|
|
public override void Init(IFSM stateMachine)
|
|
{
|
|
base.Init(stateMachine);
|
|
allShiTu = Game.Instance.transform.FindFirst<ModelChildShowOne>("ShiTu");
|
|
int loIndex = 0;
|
|
foreach (Transform item in allShiTu.transform)
|
|
{
|
|
ShiTuItem loShiTuItem = item.GetComponent<ShiTuItem>();
|
|
GameObject lobj = ShiTuLauncher.Instance.allModel.transform.GetChild(loIndex).gameObject;
|
|
loShiTuItem.Init(lobj);
|
|
allShituItem.Add(loShiTuItem);
|
|
loIndex++;
|
|
}
|
|
loModelChildShowOne = GameObject.Find("Main").FindFirst<ModelChildShowOne>("ModelShow");
|
|
loModelChildShowOne?.CloseAllModel();
|
|
}
|
|
|
|
public override void OnEnter(params object[] obj)
|
|
{
|
|
base.OnEnter(obj);
|
|
Game.Instance.uiManager.ShowUIAndCloseOther<ShiTuPanel>();
|
|
Game.Instance.eventManager.AddListener<ShiTuEvent>(OnShiTuEvent);
|
|
ToReset();
|
|
}
|
|
|
|
public override void OnExit()
|
|
{
|
|
base.OnExit();
|
|
Game.Instance.eventManager.RemoveListener<ShiTuEvent>(OnShiTuEvent);
|
|
ShiTuLauncher.Instance.allModel?.CloseAllModel();
|
|
}
|
|
|
|
private void OnShiTuEvent(ShiTuEvent e)
|
|
{
|
|
switch (e.eventData)
|
|
{
|
|
case "ShiTu1":
|
|
ChangeShiTu(0);
|
|
break;
|
|
case "ShiTu2":
|
|
ChangeShiTu(1);
|
|
break;
|
|
case "ShiTu3":
|
|
ChangeShiTu(2);
|
|
break;
|
|
case "Last":
|
|
break;
|
|
case "ChaiBtn":
|
|
curModel?.MoveOrBack();
|
|
break;
|
|
case "Next":
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void ToReset()
|
|
{
|
|
ChangeShiTu(0);
|
|
}
|
|
|
|
public void ChangeShiTu(int index)
|
|
{
|
|
if (index >= 0 && index < allShituItem.Count)
|
|
{
|
|
allShiTu?.ShowModel(index);
|
|
GameObject loMod = ShiTuLauncher.Instance.allModel?.ShowModel(index);
|
|
if (loMod != null) curModel = loMod.GetComponent<ShiTuBomb>();
|
|
allShituItem[index].ToReset();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public class ShiTuStateShowModel : StateBase
|
|
{
|
|
ModelChildShowOne loModelChildShowOne = new ModelChildShowOne();
|
|
public override void Init(IFSM stateMachine)
|
|
{
|
|
base.Init(stateMachine);
|
|
loModelChildShowOne = GameObject.Find("Main").FindFirst<ModelChildShowOne>("ModelShow");
|
|
loModelChildShowOne?.CloseAllModel();
|
|
}
|
|
public override void OnEnter(params object[] obj)
|
|
{
|
|
base.OnEnter(obj);
|
|
Game.Instance.uiManager.ShowUIAndCloseOther<ShiTuModelShowUI>();
|
|
string objName = obj[0].ToString();
|
|
loModelChildShowOne?.ShowModel(objName);
|
|
Game.Instance.eventManager.AddListener<ShiTuEvent>(OnShiTuEvent);
|
|
}
|
|
|
|
public override void OnExit()
|
|
{
|
|
base.OnExit();
|
|
loModelChildShowOne?.CloseAllModel();
|
|
Game.Instance.eventManager.RemoveListener<ShiTuEvent>(OnShiTuEvent);
|
|
}
|
|
|
|
private void OnShiTuEvent(ShiTuEvent e)
|
|
{
|
|
switch (e.eventData)
|
|
{
|
|
case "Back":
|
|
Game.Instance.fsm.ChangeState<ShiTuStateMain>();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|