2301 lines
76 KiB
C#
2301 lines
76 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.EventSystems;
|
||
using UnityEngine.UI;
|
||
using System.Linq;
|
||
using DG.Tweening;
|
||
|
||
public class ZX4Controller : MonoBehaviour
|
||
{
|
||
/// <summary>
|
||
/// 美食预设体
|
||
/// </summary>
|
||
public GameObject preFood;
|
||
|
||
/// <summary>
|
||
/// 烹饪预设体
|
||
/// </summary>
|
||
public GameObject preOp;
|
||
/// <summary>
|
||
/// 选中预设体
|
||
/// </summary>
|
||
public GameObject preSelected;
|
||
/// <summary>
|
||
/// 食材预设体
|
||
/// </summary>
|
||
public GameObject preFoodMat;
|
||
|
||
//步骤框中心对象
|
||
public Transform tranStepCenter;
|
||
|
||
public UICircle imgSemi;
|
||
|
||
/// <summary>
|
||
/// 美食容器
|
||
/// </summary>
|
||
public Transform foodsContainer;
|
||
|
||
/// <summary>
|
||
/// 食材容器
|
||
/// </summary>
|
||
public Transform matContainer;
|
||
|
||
/// <summary>
|
||
/// 烹饪方式容器
|
||
/// </summary>
|
||
public Transform opContainer;
|
||
|
||
/// <summary>
|
||
/// 关闭按钮
|
||
/// </summary>
|
||
public Button closeButton;
|
||
|
||
/// <summary>
|
||
/// 返回按钮
|
||
/// </summary>
|
||
public Button backButton;
|
||
|
||
/// <summary>
|
||
/// 开始制作按钮
|
||
/// </summary>
|
||
public Button startButton;
|
||
|
||
/// <summary>
|
||
/// 退出制作按钮
|
||
/// </summary>
|
||
public Button quitGameButton;
|
||
|
||
/// <summary>
|
||
/// 完成制作按钮
|
||
/// </summary>
|
||
public Button okButton;
|
||
|
||
/// <summary>
|
||
/// 详细_图片
|
||
/// </summary>
|
||
public Image foodImage;
|
||
|
||
/// <summary>
|
||
/// 详细_美食名称
|
||
/// </summary>
|
||
public Text foodNameText;
|
||
|
||
/// <summary>
|
||
/// 详细_描述文本
|
||
/// </summary>
|
||
public Text descriptionText;
|
||
|
||
/// <summary>
|
||
/// 中间圆环的半径
|
||
/// </summary>
|
||
public float radius = 50f;
|
||
|
||
/// <summary>
|
||
/// 食材背景
|
||
/// </summary>
|
||
public Sprite bgMat;
|
||
|
||
/// <summary>
|
||
/// 操作背景
|
||
/// </summary>
|
||
public Sprite bgOp;
|
||
|
||
/// <summary>
|
||
/// 中间选中区背景
|
||
/// </summary>
|
||
public Sprite bgCenter;
|
||
|
||
|
||
private bool IsShowTip;
|
||
|
||
/// <summary>
|
||
/// 文件路径
|
||
/// </summary>
|
||
private string basePath;
|
||
|
||
/// <summary>
|
||
/// 选中的食材Food组件
|
||
/// </summary>
|
||
private Food selectedFood;
|
||
|
||
/// <summary>
|
||
/// 美食数据列表
|
||
/// </summary>
|
||
private List<FoodData> foodDataList;
|
||
|
||
/// <summary>
|
||
/// 动画组件
|
||
/// </summary>
|
||
private Animator animator;
|
||
|
||
//提示按钮
|
||
public Button btnTip;
|
||
//关闭提示框
|
||
public Button btnCloseTip;
|
||
//提示框
|
||
public GameObject pnlTip;
|
||
//提示制作过程文本
|
||
public Text txtTip;
|
||
//提示菜谱名称
|
||
public Text txtFoodNameTip;
|
||
|
||
//列表滑动限位
|
||
public GameObject mainfoodlist;
|
||
public GameObject foodlistmat;
|
||
public GameObject foodlistop;
|
||
|
||
//步骤提示
|
||
public GameObject StepCenter;
|
||
public GameObject promptMat;
|
||
public GameObject promptOp;
|
||
|
||
//制作动画
|
||
public GameObject cookingAnimation;
|
||
public int animationmark;
|
||
|
||
//卤肉饭动画
|
||
public GameObject Chaoluroufan;
|
||
public GameObject Luluroufan;
|
||
public GameObject Zhuanpanluroufan;
|
||
//蚵仔煎动画
|
||
public GameObject Jiaobankezaijian;
|
||
public GameObject Jiaobankezaijian2;
|
||
public GameObject Jiankezaijian;
|
||
//担仔面动画
|
||
public GameObject Jiaobandanzaimian;
|
||
public GameObject Zhudanzaimian;
|
||
public GameObject Jiaobandanzaimian2;
|
||
//肉粽动画
|
||
public GameObject Jinpaorouzong;
|
||
public GameObject Zhurouzong;
|
||
public GameObject Baorouzong;
|
||
public GameObject Zhurouzong2;
|
||
//大肠蚵仔面动画
|
||
public GameObject Lukezaimian;
|
||
public GameObject Zhukezaimian;
|
||
public GameObject Zhukezaimian2;
|
||
//台湾炒米粉动画
|
||
public GameObject Chaochaomifen;
|
||
public GameObject Jianchaomifen;
|
||
public GameObject Chaochaomifen2;
|
||
//鼎边锉动画
|
||
public GameObject Jiaobandingbiancuo;
|
||
public GameObject Zhudingbiancuo;
|
||
public GameObject Zhuangpandingbiancuo;
|
||
//深坑豆腐动画
|
||
public GameObject Jiandoufu;
|
||
public GameObject Chaodoufu;
|
||
public GameObject Zhudoufu;
|
||
//万峦猪蹄动画
|
||
public GameObject Zhuzhuti;
|
||
public GameObject Chaozhuti;
|
||
public GameObject Zhuzhuti2;
|
||
//烧仙草动画
|
||
public GameObject Zhengshaoxiancao;
|
||
public GameObject Zhushaoxiancao;
|
||
public GameObject Zhuangpanshaoxiancao;
|
||
|
||
//动画素材
|
||
//卤肉饭动画素材
|
||
public GameObject luroufanTransform;
|
||
public GameObject onions;
|
||
public GameObject mushroom;
|
||
public GameObject pork;
|
||
public GameObject rice;
|
||
//蚵仔煎动画素材
|
||
public GameObject kezaijianTransform;
|
||
public GameObject egg;
|
||
public GameObject oysters;
|
||
public GameObject eggliquid;
|
||
public GameObject oyster2;
|
||
public GameObject onionskezaijian;
|
||
//担仔面动画素材
|
||
public GameObject danzaimianTransform;
|
||
public GameObject porkdanzaimian;
|
||
public GameObject noodles;
|
||
public GameObject noodles2;
|
||
public GameObject shrimpdanzaimian;
|
||
public GameObject coriander;
|
||
//肉粽动画素材
|
||
public GameObject zongziTransform;
|
||
public GameObject ricezongzi;
|
||
public GameObject onionszongzi;
|
||
public GameObject mushroomzongzi;
|
||
public GameObject porkzongzi;
|
||
public GameObject ricezongzi2;
|
||
public GameObject leaves;
|
||
public GameObject zongzi;
|
||
//大肠蚵仔面动画素材
|
||
public GameObject kezaimianTransform;
|
||
public GameObject intestine;
|
||
public GameObject oysterskezaimian;
|
||
public GameObject nooldeskezaimian;
|
||
//台湾炒米粉动画素材
|
||
public GameObject chaomifenTransform;
|
||
public GameObject onionschaomifen;
|
||
public GameObject mushroomchaomifen;
|
||
public GameObject porkchaomifen;
|
||
public GameObject eggchaomifen;
|
||
public GameObject flour;
|
||
public GameObject onionschaomifen2;
|
||
public GameObject mushroomchaomifen2;
|
||
public GameObject porkchaomifen2;
|
||
//鼎边锉动画素材
|
||
public GameObject dingbiancuoTransform;
|
||
public GameObject powderdingbiancuo;
|
||
public GameObject mushroomdingbiancuo;
|
||
public GameObject shrimpdingbiancuo;
|
||
public GameObject oysterdingbiancuo;
|
||
public GameObject chive;
|
||
//深坑豆腐动画素材
|
||
public GameObject doufuTransform;
|
||
public GameObject doufu;
|
||
public GameObject garlic;
|
||
public GameObject doufu2;
|
||
public GameObject garlic2;
|
||
//万峦猪蹄动画素材
|
||
public GameObject zhutiTransform;
|
||
public GameObject trotters;
|
||
public GameObject candy;
|
||
public GameObject trotters2;
|
||
public GameObject trotters3;
|
||
//烧仙草动画素材
|
||
public GameObject shaoxiancaoTransform;
|
||
public GameObject potato;
|
||
public GameObject ball;
|
||
public GameObject pearl;
|
||
public GameObject grass;
|
||
public GameObject milk;
|
||
public GameObject ball2;
|
||
public GameObject pearl2;
|
||
//动画步骤标记
|
||
public int animationloadmark;
|
||
|
||
//选择食谱标记
|
||
public int currentSelected;
|
||
//食谱制作步骤
|
||
public int step;
|
||
//灶台锅贴图
|
||
public GameObject wok;
|
||
|
||
//半成品图
|
||
//卤肉饭半成品
|
||
public GameObject semiluroufan1;
|
||
public GameObject semiluroufan2;
|
||
//蚵仔煎半成品
|
||
public GameObject semikezaijian1;
|
||
public GameObject semikezaijian2;
|
||
//担仔面半成品
|
||
public GameObject semidaizaimian1;
|
||
public GameObject semidanzaimian2;
|
||
//肉粽半成品
|
||
public GameObject semirouzong1;
|
||
public GameObject semirouzong2;
|
||
public GameObject semirouzong3;
|
||
//大肠蚵仔面半成品
|
||
public GameObject semikezaimian1;
|
||
public GameObject semikezaimian2;
|
||
//台湾炒米粉半成品
|
||
public GameObject semichaomifen1;
|
||
public GameObject semichaomifen2;
|
||
//鼎边锉半成品
|
||
public GameObject semidingbiancuo1;
|
||
public GameObject semidingbiancuo2;
|
||
//深坑豆腐半成品
|
||
public GameObject semidoufu1;
|
||
public GameObject semidoufu2;
|
||
//万峦猪蹄半成品
|
||
public GameObject semizhuti1;
|
||
public GameObject semizhuti2;
|
||
//烧仙草半成品
|
||
public GameObject semishaoxiancao1;
|
||
public GameObject semishaoxaincao2;
|
||
|
||
//步骤干扰项
|
||
//正确食材
|
||
public string[] Matlist;
|
||
public int Matitem;
|
||
public int MatTrue;
|
||
public int MatTest;
|
||
//正确烹饪方法
|
||
public string[] Oplist;
|
||
public int Opitem;
|
||
public int OpTrue;
|
||
public int OpTest;
|
||
|
||
void Start()
|
||
{
|
||
foodDataList = new List<FoodData>();
|
||
animator = this.GetComponent<Animator>();
|
||
|
||
//文件路径
|
||
basePath = CommonData.DataServer + "/ZX4/Data/";
|
||
|
||
//按钮事件监听
|
||
closeButton.onClick.AddListener(onCloseButtonClick);
|
||
backButton.onClick.AddListener(onBackButtonClick);
|
||
startButton.onClick.AddListener(onStartButtonClick);
|
||
quitGameButton.onClick.AddListener(onQuitGameButtonClick);
|
||
okButton.onClick.AddListener(onQuitGameButtonClick);
|
||
btnTip.onClick.AddListener(onBtnTipClick);
|
||
btnCloseTip.onClick.AddListener(onBtnCloseTipClick);
|
||
|
||
//读取配置文件
|
||
StartCoroutine(JsonLoader.LoadJSON(basePath + "Foods.json", onFoodDataReceived));
|
||
|
||
//锅初始位置更新
|
||
wok.transform.SetParent(txtFoodName.gameObject.transform);
|
||
//动画对象初始位置更新
|
||
cookingAnimation.transform.SetParent(txtFoodName.gameObject.transform);
|
||
|
||
|
||
|
||
}
|
||
|
||
void Update()
|
||
{
|
||
//首页美食列表滑动限位
|
||
if (mainfoodlist.transform.localPosition.x>0)
|
||
{
|
||
mainfoodlist.transform.localPosition = new Vector2(0, 0);
|
||
}
|
||
else if (mainfoodlist.transform.localPosition.x<(- (mainfoodlist.transform.childCount/3)*254))
|
||
{
|
||
mainfoodlist.transform.localPosition = new Vector2( - (mainfoodlist.transform.childCount/3) * 254,0);
|
||
}
|
||
|
||
//食材列表滑动限位
|
||
if (foodlistmat.transform.localPosition.y < 0)
|
||
{
|
||
foodlistmat.transform.localPosition = new Vector2(0, 0);
|
||
}
|
||
else if (foodlistmat.transform.localPosition.y > foodlistmat.transform.childCount*80)
|
||
{
|
||
foodlistmat.transform.localPosition = new Vector2(0, foodlistmat.transform.childCount * 80);
|
||
}
|
||
|
||
//烹饪方式列表滑动限位
|
||
|
||
if (foodlistop.transform.localPosition.y < 0)
|
||
{
|
||
foodlistop.transform.localPosition = new Vector2(0, 0);
|
||
}
|
||
else if (foodlistop.transform.localPosition.y > foodlistop.transform.childCount*80)
|
||
{
|
||
foodlistop.transform.localPosition = new Vector2(0,foodlistop.transform.childCount * 80);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 首页美食加载
|
||
/// </summary>
|
||
/// <param name="data">美食数据</param>
|
||
private void onFoodDataReceived(string data)
|
||
{
|
||
foodDataList = JsonTools.ListFromJson<FoodData>(data);
|
||
foodsContainer.DetachChildren();
|
||
|
||
//首页美食列表数据生成
|
||
foreach (var fData in foodDataList)
|
||
{
|
||
GameObject foodItem = Instantiate(preFood, foodsContainer);
|
||
Food food = foodItem.GetComponent<Food>();
|
||
food.Data = fData;
|
||
food.button.onClick.AddListener(onFoodSelected);
|
||
}
|
||
//ShowFoods();
|
||
}
|
||
|
||
int index;
|
||
|
||
public void ShowFoods()
|
||
{
|
||
if (foodDataList != null && foodDataList.Count > 0)
|
||
{
|
||
GameObject foodItem = Instantiate(preFood, foodsContainer);
|
||
Food food = foodItem.GetComponent<Food>();
|
||
food.Data = foodDataList[index];
|
||
food.button.onClick.AddListener(onFoodSelected);
|
||
|
||
// 背景颜色
|
||
Tween myTween = foodItem.GetComponent<Image>().DOColor(new Color(255, 255, 255, 255), 0.5f);
|
||
myTween.SetEase(Ease.OutQuint);
|
||
|
||
// 缩放到1倍
|
||
Tween myTween2 = foodItem.transform.DOScale(Vector3.one, 0.5f);
|
||
myTween2.SetEase(Ease.OutQuint);
|
||
|
||
index++;
|
||
if (index < foodDataList.Count)
|
||
{
|
||
Invoke("ShowFoods", 1f);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选中美食加载详情
|
||
/// </summary>
|
||
public void onFoodSelected()
|
||
{
|
||
GameObject gameObject = EventSystem.current.currentSelectedGameObject;
|
||
currentSelected = int.Parse(gameObject.GetComponent<Food>().Data.id);
|
||
Food food = gameObject.GetComponent<Food>();
|
||
if (selectedFood != null)
|
||
{
|
||
selectedFood.objBgImage.SetActive(false);
|
||
}
|
||
food.objBgImage.SetActive(true);
|
||
|
||
foodImage.sprite = food.foodImage.sprite;
|
||
foodNameText.text = food.nameText.text;
|
||
txtFoodName.text = food.nameText.text;
|
||
txtFoodName2.text = food.nameText.text;
|
||
descriptionText.text = food.Data.description;
|
||
descriptionText.rectTransform.anchoredPosition = new Vector2(0f, -699f);
|
||
matContainer.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
||
opContainer.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
||
|
||
selectedFood = food;
|
||
animator.SetTrigger("ShowFoodInfo1");
|
||
PlayAudioByName("页面切换");
|
||
}
|
||
|
||
private void onBackButtonClick()
|
||
{
|
||
step = 0;
|
||
animator.SetTrigger("ShowFoodList");
|
||
PlayAudioByName("页面切换");
|
||
}
|
||
|
||
List<FoodStepData> allMatSteps;
|
||
List<FoodStepData> allOpSteps;
|
||
List<FoodStepData> selectedSteps;
|
||
List<GameObject> objSteps;
|
||
int currentStepIndex;
|
||
int currentObjIndex;
|
||
GameObject currentStepObj;
|
||
|
||
//标题菜谱名称
|
||
public Text txtFoodName;
|
||
|
||
//成功页面菜谱名称
|
||
public Text txtFoodName2;
|
||
|
||
//成功页面菜品图片显示
|
||
public RawImage imgFood;
|
||
|
||
//选择背景框
|
||
public GameObject objSelectedMatBg;
|
||
public GameObject objSelectedOpBg;
|
||
|
||
#region 操作提示
|
||
/// <summary>
|
||
/// 食材提示
|
||
/// </summary>
|
||
public GameObject objTipMat;
|
||
|
||
/// <summary>
|
||
/// 烹饪方式提示
|
||
/// </summary>
|
||
public GameObject objTipOp;
|
||
|
||
GameObject tip;
|
||
|
||
bool isBegin = true;
|
||
|
||
//提示框显示
|
||
void ShowTip(GameObject objTip, float showTime = 1.5f)
|
||
{
|
||
IsShowTip = true;
|
||
tip = objTip;
|
||
objTip.SetActive(true);
|
||
Invoke("HideTip", showTime);
|
||
}
|
||
|
||
//提示框隐藏
|
||
void HideTip()
|
||
{
|
||
IsShowTip = false;
|
||
tip.SetActive(false);
|
||
if (isBegin)
|
||
{
|
||
ShowTip(objTipOp, 3f);
|
||
isBegin = false;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
//游戏开始
|
||
private void onStartButtonClick()
|
||
{
|
||
//加载新菜品时进行初始化
|
||
if (step==0)
|
||
{
|
||
animator.SetTrigger("ShowGame");
|
||
PlayAudioByName("页面切换");
|
||
animationloadmark = 0;
|
||
luroufanTransform.SetActive(false);
|
||
kezaijianTransform.SetActive(false);
|
||
danzaimianTransform.SetActive(false);
|
||
zongziTransform.SetActive(false);
|
||
chaomifenTransform.SetActive(false);
|
||
dingbiancuoTransform.SetActive(false);
|
||
doufuTransform.SetActive(false);
|
||
zhutiTransform.SetActive(false);
|
||
shaoxiancaoTransform.SetActive(false);
|
||
|
||
}
|
||
|
||
//初始化时清除子对象及数据
|
||
foreach (Transform child in matContainer)
|
||
{
|
||
Destroy(child.gameObject);
|
||
}
|
||
|
||
//选择背景框初始化
|
||
objSelectedMatBg.transform.SetParent(matContainer.parent);
|
||
objSelectedMatBg.SetActive(false);
|
||
|
||
//初始化时清除子对象及数据
|
||
foreach (Transform child in opContainer)
|
||
{
|
||
Destroy(child.gameObject);
|
||
}
|
||
|
||
//选择背景框初始化
|
||
objSelectedOpBg.transform.SetParent(opContainer.parent);
|
||
objSelectedOpBg.SetActive(false);
|
||
foreach (Transform child in tranStepCenter)
|
||
{
|
||
Destroy(child.gameObject);
|
||
}
|
||
allMatSteps = null;
|
||
allOpSteps = null;
|
||
selectedSteps = null;
|
||
objSteps = null;
|
||
|
||
Matitem = 0;
|
||
MatTrue = 0;
|
||
string[] Matlist = new string[10];
|
||
|
||
Opitem = 0;
|
||
OpTrue = 0;
|
||
string[] Oplist = new string[10];
|
||
|
||
tranStepCenter.gameObject.SetActive(false);
|
||
|
||
// 第一次初始化食材及烹饪方式
|
||
if (allMatSteps == null || allOpSteps == null)
|
||
{
|
||
allMatSteps = new List<FoodStepData>();
|
||
allOpSteps = new List<FoodStepData>();
|
||
foreach (var fData in foodDataList)
|
||
{
|
||
foreach (var step in fData.steps)
|
||
{
|
||
//加载烹饪步骤
|
||
if (step.type == "1" && !allMatSteps.Any(tmpStep => tmpStep.name.Equals(step.name)))
|
||
{
|
||
allMatSteps.Add(step);
|
||
}
|
||
if (step.type == "2" && !allOpSteps.Any(tmpStep => tmpStep.name.Equals(step.name)))
|
||
{
|
||
allOpSteps.Add(step);
|
||
}
|
||
}
|
||
}
|
||
|
||
selectedSteps = selectedFood.Data.steps;
|
||
objSteps = new List<GameObject>();
|
||
}
|
||
|
||
//步骤框生成
|
||
//tranStepCenter.DetachChildren();
|
||
var step12 = selectedFood.Data.steps.Where(step => step.type == "1" || step.type == "2").ToList();
|
||
|
||
for (int i = 0; i < step12.Count; i++)
|
||
{
|
||
float angle = i * Mathf.PI * 2f / step12.Count;
|
||
Vector3 pos = new Vector3(Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius, 0);
|
||
GameObject obj = Instantiate(preSelected, pos, Quaternion.identity);
|
||
obj.transform.SetParent(tranStepCenter, false);
|
||
//obj.transform.GetChild(0).GetComponent<RawImage>().color =
|
||
// = step12[i].type == "1" ? Color.green : Color.yellow;
|
||
FoodStepInitial(obj, step12[i], false, i + 1);
|
||
objSteps.Add(obj);
|
||
}
|
||
|
||
//食材预制体生成
|
||
//matContainer.DetachChildren();
|
||
foreach (var item in allMatSteps)
|
||
{
|
||
for (int i = 0; i < step12.Count; i++)
|
||
{
|
||
|
||
if (item.name==step12[i].name)
|
||
{
|
||
Matlist[MatTrue] = step12[i].name;
|
||
MatTrue++;
|
||
GameObject obj = Instantiate(preFoodMat, matContainer);
|
||
FoodStepInitial(obj, item);
|
||
}
|
||
}
|
||
Matitem++;
|
||
}
|
||
|
||
var matfalse = 0;
|
||
foreach (var item in allMatSteps)
|
||
{
|
||
|
||
var matdifferent = 0;
|
||
//随机生成干扰项
|
||
for (int i = 0; i < MatTrue; i++)
|
||
{
|
||
if (item.name != Matlist[i])
|
||
{
|
||
matdifferent++;
|
||
}
|
||
}
|
||
if (Random.Range(1, 100) > 70 && matfalse < 3&&matdifferent==MatTrue)
|
||
{
|
||
matfalse++;
|
||
matdifferent = 0;
|
||
GameObject obj = Instantiate(preFoodMat, matContainer);
|
||
FoodStepInitial(obj, item);
|
||
}
|
||
MatTest++;
|
||
}
|
||
TransRandom(matContainer);
|
||
//烹饪方式预制体生成
|
||
//opContainer.DetachChildren();
|
||
foreach (var item in allOpSteps)
|
||
{
|
||
for (int i = 0; i < step12.Count; i++)
|
||
{
|
||
if (item.name == step12[i].name)
|
||
{
|
||
Oplist[OpTrue] = step12[i].name;
|
||
OpTrue++;
|
||
GameObject obj = Instantiate(preOp, opContainer);
|
||
FoodStepInitial(obj, item);
|
||
}
|
||
|
||
}
|
||
Opitem++;
|
||
}
|
||
|
||
var opfalse = 0;
|
||
foreach (var item in allOpSteps)
|
||
{
|
||
|
||
var opdifferent = 0;
|
||
//随机生成干扰项
|
||
for (int i = 0; i < OpTrue; i++)
|
||
{
|
||
if (item.name != Oplist[i])
|
||
{
|
||
opdifferent++;
|
||
}
|
||
}
|
||
if (Random.Range(1, 100) > 60 && opfalse < 2 && opdifferent == OpTrue)
|
||
{
|
||
opfalse++;
|
||
opdifferent = 0;
|
||
GameObject obj = Instantiate(preOp, opContainer);
|
||
FoodStepInitial(obj, item);
|
||
}
|
||
OpTest++;
|
||
}
|
||
TransRandom(opContainer);
|
||
|
||
currentObjIndex = 0;
|
||
currentStepIndex = 0;
|
||
currentStepObj = objSteps[currentObjIndex];
|
||
|
||
//设定图片参数
|
||
Sprite sp = selectedFood.foodImage.sprite;
|
||
Texture2D tex = new Texture2D((int)sp.rect.width, (int)sp.rect.height, TextureFormat.RGBA32, false);
|
||
tex.filterMode = FilterMode.Point;
|
||
tex.wrapMode = TextureWrapMode.Clamp;
|
||
tex.SetPixels(sp.texture.GetPixels(
|
||
(int)sp.textureRect.x,
|
||
(int)sp.textureRect.y,
|
||
(int)sp.textureRect.width,
|
||
(int)sp.textureRect.height));
|
||
tex.Apply();
|
||
imgFood.texture = tex;
|
||
|
||
Invoke("phantom", 0.001f);
|
||
|
||
//第一步提示自动显示
|
||
//ShowTip(objTipMat, 3f);
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "请加入:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
|
||
//加载提示菜谱
|
||
LoadTip();
|
||
}
|
||
|
||
//加载提示菜谱
|
||
void LoadTip()
|
||
{
|
||
//提示文本注入
|
||
txtFoodNameTip.text = selectedFood.nameText.text;
|
||
txtTip.text = selectedFood.Data.tip;
|
||
|
||
}
|
||
|
||
void HideAll()
|
||
{
|
||
objTipMat.SetActive(false);
|
||
objTipOp.SetActive(false);
|
||
}
|
||
|
||
void FoodStepInitial(GameObject obj, FoodStepData item, bool canClick = true, int index = 0)
|
||
{
|
||
obj.name = item.name;
|
||
Text txt = obj.GetComponentInChildren<Text>();
|
||
if (canClick)
|
||
{
|
||
//加载食材及烹饪方式图片
|
||
if (item.type == "1")
|
||
{
|
||
obj.GetComponent<Button>().onClick.AddListener(onFoodMatButtonClick);
|
||
StartCoroutine(ImageLoader<RawImage>.LoadImage(
|
||
CommonData.DataServer + "/ZX4/Mats/" + item.name + ".png",
|
||
obj.transform.GetChild(0).GetComponent<RawImage>()));
|
||
}
|
||
else
|
||
{
|
||
obj.GetComponent<Button>().onClick.AddListener(onFoodOpButtonClick);
|
||
StartCoroutine(ImageLoader<RawImage>.LoadImage(
|
||
CommonData.DataServer + "/ZX4/Ops/" + item.name + ".png",
|
||
obj.transform.GetChild(0).GetComponent<RawImage>()));
|
||
}
|
||
//if (txt != null)
|
||
//txt.text = item.name;
|
||
}
|
||
else
|
||
{
|
||
//if (txt != null)
|
||
// txt.text = index.ToString();
|
||
}
|
||
}
|
||
|
||
//选择正确显示步骤图片
|
||
void FoodStepInitial(GameObject objStep, GameObject objSelected)
|
||
{
|
||
objStep.transform.GetChild(1).GetComponent<RawImage>().texture
|
||
=
|
||
objSelected.transform.childCount == 2
|
||
?
|
||
objSelected.transform.GetChild(0).GetComponent<RawImage>().texture
|
||
:
|
||
objSelected.transform.GetChild(1).GetComponent<RawImage>().texture;
|
||
|
||
Text txt = objStep.GetComponentInChildren<Text>();
|
||
if (txt != null)
|
||
txt.text = objSelected.GetComponentInChildren<Text>().text;
|
||
}
|
||
|
||
//播放成功动画
|
||
void SemiInitial()
|
||
{
|
||
if (selectedSteps[currentStepIndex].type == "4")
|
||
{
|
||
animator.SetTrigger("Success");
|
||
PlayAudioByName("成功");
|
||
//Debug.Log("播放成功动画");
|
||
step = 0;
|
||
}
|
||
else
|
||
{
|
||
//Debug.Log("半成品");
|
||
/*
|
||
//imgSemi.gameObject.SetActive(true);
|
||
|
||
StartCoroutine(ImageLoader<RawImage>.LoadImage(
|
||
CommonData.DataServer + "/ZX4/Semis/" + selectedSteps[currentStepIndex].name + ".png", imgSemi));
|
||
Invoke("HideSemi", 3f);
|
||
*/
|
||
/*
|
||
currentStepIndex++;
|
||
|
||
currentObjIndex++;
|
||
currentStepObj = objSteps[currentObjIndex];
|
||
*/
|
||
}
|
||
}
|
||
|
||
void HideSemi()
|
||
{
|
||
imgSemi.gameObject.SetActive(false);
|
||
}
|
||
|
||
//选择食材
|
||
private void onFoodMatButtonClick()
|
||
{
|
||
Invoke("SetactivePromptMat", 0);
|
||
Invoke("SetactivePromptOp", 0);
|
||
if (!IsShowTip)
|
||
{
|
||
if (selectedSteps[currentStepIndex].type == "1")
|
||
{
|
||
GameObject obj = EventSystem.current.currentSelectedGameObject;
|
||
for (int i = currentStepIndex; i < selectedSteps.Count; i++)
|
||
{
|
||
if (selectedSteps[i].type != "1")
|
||
{
|
||
PlayAudioByName("选择错误");
|
||
if (selectedSteps[currentStepIndex].type=="1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
break;
|
||
}
|
||
else if (selectedSteps[i].name == obj.name)
|
||
{
|
||
FoodStepInitial(currentStepObj, obj);
|
||
//objSelectedMatBg.SetActive(true);
|
||
objSelectedMatBg.transform.position = obj.transform.position;
|
||
objSelectedMatBg.transform.SetParent(obj.transform);
|
||
objSelectedMatBg.transform.SetAsFirstSibling();
|
||
StepCenter.transform.GetChild(currentStepIndex).transform.GetChild(1).GetComponent<RawImage>().color = new Color(255, 255, 255, 1);
|
||
PlayAudioByName("选择正确");
|
||
if (i != currentStepIndex)
|
||
{
|
||
FoodStepData element = selectedSteps[i]; // 获取要移动的元素的值
|
||
selectedSteps.RemoveAt(i); // 移除要移动的元素
|
||
selectedSteps.Insert(currentStepIndex, element); // 将要移动的元素插入到目标位置
|
||
}
|
||
if (selectedSteps[currentStepIndex+1].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选对了,\n接下来加入:" + selectedSteps[currentStepIndex + 1].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else if((selectedSteps[currentStepIndex+1].type == "2"))
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选对了,\n接下来选择:" + selectedSteps[currentStepIndex + 1].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
AnimationLoad();
|
||
|
||
|
||
|
||
//wok.SetActive(false);
|
||
|
||
|
||
currentStepIndex++;
|
||
currentObjIndex++;
|
||
currentStepObj = objSteps[currentObjIndex];
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
PlayAudioByName("选择错误");
|
||
if (selectedSteps[currentStepIndex].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
//选择烹饪方法
|
||
private void onFoodOpButtonClick()
|
||
{
|
||
Invoke("SetactivePromptMat", 0);
|
||
Invoke("SetactivePromptOp", 0);
|
||
if (!IsShowTip)
|
||
{
|
||
if (selectedSteps[currentStepIndex].type == "2")
|
||
{
|
||
GameObject obj = EventSystem.current.currentSelectedGameObject;
|
||
|
||
if (selectedSteps[currentStepIndex].name == obj.name)
|
||
{
|
||
FoodStepInitial(currentStepObj, obj);
|
||
|
||
//objSelectedOpBg.SetActive(true);
|
||
objSelectedOpBg.transform.position = obj.transform.position;
|
||
objSelectedOpBg.transform.SetParent(obj.transform);
|
||
objSelectedOpBg.transform.SetAsFirstSibling();
|
||
StepCenter.transform.GetChild(currentStepIndex).transform.GetChild(1).GetComponent<RawImage>().color = new Color(255, 255, 255, 1);
|
||
Invoke("StepAnimation", 0);
|
||
if (selectedSteps[currentStepIndex + 1].type=="3")
|
||
{
|
||
step++;
|
||
Invoke("onFoodStep", 2f);
|
||
/*
|
||
CancelInvoke("SetactivePromptMat");
|
||
Invoke("OpenPrompt", 4f);
|
||
promptMat.GetComponentInChildren<Text>().text = "选对了,\n接下来加入:" + selectedSteps[currentStepIndex + 2].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
*/
|
||
}
|
||
else if (selectedSteps[currentStepIndex + 1].type == "4")
|
||
{
|
||
Invoke("SetactivePromptOp", 0);
|
||
}
|
||
else if (selectedSteps[currentStepIndex+1].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选对了,\n接下来加入:" + selectedSteps[currentStepIndex + 1].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
|
||
}
|
||
else if (selectedSteps[currentStepIndex+1].type == "2")
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选对了,\n接下来选择:" + selectedSteps[currentStepIndex + 1].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
//AnimationLoad();
|
||
if (selectedSteps[currentStepIndex].name == "装盘")
|
||
{
|
||
//Debug.Log("播放动画:" + obj.name);
|
||
|
||
Invoke("SemiInitial", 1.5f);
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name != "装盘")
|
||
{
|
||
//Debug.Log("播放动画:" + obj.name);
|
||
Invoke("SemiInitial", 2f);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
PlayAudioByName("选择错误");
|
||
if (selectedSteps[currentStepIndex].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
PlayAudioByName("选择错误");
|
||
if (selectedSteps[currentStepIndex].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选错啦,\n" + "应该是:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//退出游戏
|
||
private void onQuitGameButtonClick()
|
||
{
|
||
//退出游戏初始化数据
|
||
step = 0;
|
||
animationmark=0;
|
||
semiluroufan1.SetActive(false);
|
||
semiluroufan2.SetActive(false);
|
||
semikezaijian1.SetActive(false);
|
||
semikezaijian2.SetActive(false);
|
||
semidaizaimian1.SetActive(false);
|
||
semidanzaimian2.SetActive(false);
|
||
semirouzong1.SetActive(false);
|
||
semirouzong2.SetActive(false);
|
||
semirouzong3.SetActive(false);
|
||
semikezaimian1.SetActive(false);
|
||
semikezaimian2.SetActive(false);
|
||
semichaomifen1.SetActive(false);
|
||
semichaomifen2.SetActive(false);
|
||
semidingbiancuo1.SetActive(false);
|
||
semidingbiancuo2.SetActive(false);
|
||
semidoufu1.SetActive(false);
|
||
semidoufu2.SetActive(false);
|
||
semizhuti1.SetActive(false);
|
||
semizhuti2.SetActive(false);
|
||
semishaoxiancao1.SetActive(false);
|
||
semishaoxaincao2.SetActive(false);
|
||
animationloadmark = 0;
|
||
luroufanTransform.SetActive(false);
|
||
kezaijianTransform.SetActive(false);
|
||
danzaimianTransform.SetActive(false);
|
||
zongziTransform.SetActive(false);
|
||
kezaimianTransform.SetActive(false);
|
||
chaomifenTransform.SetActive(false);
|
||
dingbiancuoTransform.SetActive(false);
|
||
doufuTransform.SetActive(false);
|
||
zhutiTransform.SetActive(false);
|
||
shaoxiancaoTransform.SetActive(false);
|
||
|
||
for (int i = 0; i < luroufanTransform.transform.childCount; i++)
|
||
{
|
||
luroufanTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < kezaijianTransform.transform.childCount; i++)
|
||
{
|
||
kezaijianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < danzaimianTransform.transform.childCount; i++)
|
||
{
|
||
danzaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < zongziTransform.transform.childCount; i++)
|
||
{
|
||
zongziTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < kezaimianTransform.transform.childCount; i++)
|
||
{
|
||
kezaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < chaomifenTransform.transform.childCount; i++)
|
||
{
|
||
chaomifenTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < dingbiancuoTransform.transform.childCount; i++)
|
||
{
|
||
dingbiancuoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < doufuTransform.transform.childCount; i++)
|
||
{
|
||
doufuTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < zhutiTransform.transform.childCount; i++)
|
||
{
|
||
zhutiTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < shaoxiancaoTransform.transform.childCount; i++)
|
||
{
|
||
shaoxiancaoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
animator.SetTrigger("ShowFoodInfo2");
|
||
PlayAudioByName("页面切换");
|
||
|
||
}
|
||
|
||
//关闭程序
|
||
private void onCloseButtonClick()
|
||
{
|
||
BaseController.HideView();
|
||
Destroy(gameObject.transform.parent.gameObject);
|
||
}
|
||
|
||
//提示按钮
|
||
private void onBtnTipClick()
|
||
{
|
||
pnlTip.SetActive(!pnlTip.activeSelf);
|
||
}
|
||
|
||
//提示关闭按钮
|
||
private void onBtnCloseTipClick()
|
||
{
|
||
pnlTip.SetActive(false);
|
||
}
|
||
|
||
#region
|
||
|
||
//void PlayVideo()
|
||
//{
|
||
// string URL = null;
|
||
// // 获取视频路径并播放视频
|
||
// if (H5Controller.GetPlatformType() == 0)
|
||
// {
|
||
// URL = Application.streamingAssetsPath + "/ZX4/Videos/" + txtFood.text + ".mp4";
|
||
// }
|
||
// else
|
||
// {
|
||
// URL = "/Content/ZX4/Videos/" + txtFood.text + ".mp4";
|
||
// }
|
||
// Debug.Log(URL);
|
||
// vp.gameObject.SetActive(true);
|
||
// Tween myTween = vp.transform.DOScale(Vector3.one, 1f);
|
||
// myTween.SetEase(Ease.OutQuint);
|
||
// vp.Play(URL);
|
||
// tranFoodMatsParent.gameObject.SetActive(false);
|
||
// RemoveSelectedFoodMats();
|
||
//}
|
||
#endregion
|
||
|
||
//食材提示显示隐藏
|
||
public void OpenPromptMat()
|
||
{
|
||
promptMat.SetActive(true);
|
||
}
|
||
public void SetactivePromptMat()
|
||
{
|
||
promptMat.SetActive(false);
|
||
}
|
||
|
||
//烹饪方式提示显示隐藏
|
||
public void OpenPromptOp()
|
||
{
|
||
promptOp.SetActive(true);
|
||
}
|
||
public void SetactivePromptOp()
|
||
{
|
||
promptOp.SetActive(false);
|
||
}
|
||
|
||
//步骤提示
|
||
public void Stepstips()
|
||
{
|
||
if (selectedSteps[currentStepIndex].type == "1")
|
||
{
|
||
CancelInvoke("SetactivePromptMat");
|
||
promptMat.SetActive(true);
|
||
promptMat.GetComponentInChildren<Text>().text = "选对了,\n接下来加入:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptMat", 2f);
|
||
}
|
||
else if (selectedSteps[currentStepIndex].type == "2")
|
||
{
|
||
CancelInvoke("SetactivePromptOp");
|
||
promptOp.SetActive(true);
|
||
promptOp.GetComponentInChildren<Text>().text = "选对了,\n接下来选择:" + selectedSteps[currentStepIndex].name;
|
||
Invoke("SetactivePromptOp", 2f);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 加载美食之后步骤
|
||
/// </summary>
|
||
public void onFoodStep()
|
||
{
|
||
//菜谱拆分为三步加载,注意数组间隔
|
||
GameObject gameObject = foodsContainer.GetChild(step*10+currentSelected-1 ).gameObject;
|
||
|
||
Food food = gameObject.GetComponent<Food>();
|
||
if (selectedFood != null)
|
||
{
|
||
selectedFood.objBgImage.SetActive(false);
|
||
}
|
||
|
||
food.objBgImage.SetActive(true);
|
||
foodImage.sprite = food.foodImage.sprite;
|
||
foodNameText.text = food.nameText.text;
|
||
txtFoodName.text = food.nameText.text;
|
||
txtFoodName2.text = food.nameText.text;
|
||
descriptionText.text = food.Data.description;
|
||
descriptionText.rectTransform.anchoredPosition = new Vector2(0f, -699f);
|
||
matContainer.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
||
opContainer.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
||
selectedFood = food;
|
||
Invoke("onStartButtonClick", 0);
|
||
}
|
||
|
||
//步骤虚影提示
|
||
/*
|
||
public void phantom()
|
||
{
|
||
var step12 = selectedFood.Data.steps.Where(step => step.type == "1" || step.type == "2").ToList();
|
||
for (int i = 0; i < StepCenter.transform.childCount; i++)
|
||
{
|
||
//低透明度显示步骤提示
|
||
if (step12[i].type == "1")
|
||
{
|
||
StartCoroutine(ImageLoader<RawImage>.LoadImage(
|
||
CommonData.DataServer + "/ZX4/Mats/" + StepCenter.transform.GetChild(i).name + ".png",
|
||
StepCenter.transform.GetChild(i).transform.GetChild(1).GetComponent<RawImage>()));
|
||
StepCenter.transform.GetChild(i).transform.GetChild(1).GetComponent<RawImage>().color = new Color(255, 255, 255, 0.7f);
|
||
}
|
||
else
|
||
{
|
||
StartCoroutine(ImageLoader<RawImage>.LoadImage(
|
||
CommonData.DataServer + "/ZX4/Ops/" + StepCenter.transform.GetChild(i).name + ".png",
|
||
StepCenter.transform.GetChild(i).transform.GetChild(1).GetComponent<RawImage>()));
|
||
StepCenter.transform.GetChild(i).transform.GetChild(1).GetComponent<RawImage>().color = new Color(255, 255, 255, 0.7f);
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
//步骤动画
|
||
public void StepAnimation()
|
||
{
|
||
//包步骤时不触发音效
|
||
if (selectedSteps[currentStepIndex].name!="包")
|
||
{
|
||
PlayAudioByName(selectedSteps[currentStepIndex].name);
|
||
}
|
||
|
||
//卤肉饭动画
|
||
if (txtFoodName.GetComponent<Text>().text == "卤肉饭")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "炒")
|
||
{
|
||
Chaoluroufan.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Chaoluroufansetactive", 2f);
|
||
luroufanTransform.SetActive(false);
|
||
for (int i = 0; i < luroufanTransform.transform.childCount; i++)
|
||
{
|
||
luroufanTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "卤")
|
||
{
|
||
Luluroufan.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Luluroufansetactive", 2f);
|
||
luroufanTransform.SetActive(false);
|
||
for (int i = 0; i < luroufanTransform.transform.childCount; i++)
|
||
{
|
||
luroufanTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "装盘")
|
||
{
|
||
Zhuanpanluroufan.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semiluroufan1.SetActive(false);
|
||
semiluroufan2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhuanpansetactive", 1.5f);
|
||
luroufanTransform.SetActive(false);
|
||
for (int i = 0; i < luroufanTransform.transform.childCount; i++)
|
||
{
|
||
luroufanTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//蚵仔煎动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "蚵仔煎")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "搅拌")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Jiaobankezaijian.SetActive(true);
|
||
animationloadmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Jiaobankezaijian2.SetActive(true);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Jiaobankezaijiansetactive", 2f);
|
||
kezaijianTransform.SetActive(false);
|
||
for (int i = 0; i < kezaijianTransform.transform.childCount; i++)
|
||
{
|
||
kezaijianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煎")
|
||
{
|
||
Jiankezaijian.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
semikezaijian1.SetActive(false);
|
||
semikezaijian2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Jiankezaijiansetactive", 2f);
|
||
kezaijianTransform.SetActive(false);
|
||
for (int i = 0; i < kezaijianTransform.transform.childCount; i++)
|
||
{
|
||
kezaijianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//担仔面动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "担仔面")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "搅拌")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Jiaobandanzaimian.SetActive(true);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name + "担仔面");
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Jiaobandanzaimian2.SetActive(true);
|
||
semidaizaimian1.SetActive(false);
|
||
semidanzaimian2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
Invoke("Jiaobandanzaimainsetactive", 2f);
|
||
danzaimianTransform.SetActive(false);
|
||
for (int i = 0; i < danzaimianTransform.transform.childCount; i++)
|
||
{
|
||
danzaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
Zhudanzaimian.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhudanzaimiansetactive", 2f);
|
||
danzaimianTransform.SetActive(false);
|
||
for (int i = 0; i < danzaimianTransform.transform.childCount; i++)
|
||
{
|
||
danzaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
animationloadmark++;
|
||
}
|
||
}
|
||
|
||
//肉粽动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "肉粽")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "浸泡")
|
||
{
|
||
Jinpaorouzong.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Jinpaorouzongsetactive", 2f);
|
||
zongziTransform.SetActive(false);
|
||
animationloadmark++;
|
||
for (int i = 0; i < zongziTransform.transform.childCount; i++)
|
||
{
|
||
zongziTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhurouzong.SetActive(true);
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhurouzong2.SetActive(true);
|
||
semirouzong3.SetActive(false);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhurouzongsetactive", 2f);
|
||
zongziTransform.SetActive(false);
|
||
for (int i = 0; i < zongziTransform.transform.childCount; i++)
|
||
{
|
||
zongziTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "包")
|
||
{
|
||
Baorouzong.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semirouzong1.SetActive(false);
|
||
semirouzong2.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Baorouzongsetactive", 2f);
|
||
zongziTransform.SetActive(false);
|
||
for (int i = 0; i < zongziTransform.transform.childCount; i++)
|
||
{
|
||
zongziTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//蚵仔面动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "大肠蚵仔面线")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "卤")
|
||
{
|
||
Lukezaimian.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Lukezaimiansetactive", 2f);
|
||
kezaimianTransform.SetActive(false);
|
||
for (int i = 0; i < kezaimianTransform.transform.childCount; i++)
|
||
{
|
||
kezaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhukezaimian.SetActive(true);
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhukezaimian2.SetActive(true);
|
||
semikezaimian1.SetActive(false);
|
||
semikezaimian2.SetActive(false);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhukezaimiansetactive", 2f);
|
||
kezaimianTransform.SetActive(false);
|
||
for (int i = 0; i < kezaimianTransform.transform.childCount; i++)
|
||
{
|
||
kezaimianTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//炒米粉动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "台湾炒米粉")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "炒")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Chaochaomifen.SetActive(true);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name+ "炒米粉");
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Chaochaomifen2.SetActive(true);
|
||
semichaomifen1.SetActive(false);
|
||
semichaomifen2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
Invoke("Chaochaomifensetactive", 2f);
|
||
chaomifenTransform.SetActive(false);
|
||
for (int i = 0; i < chaomifenTransform.transform.childCount; i++)
|
||
{
|
||
chaomifenTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煎")
|
||
{
|
||
Jianchaomifen.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Jianchaomifensetactive", 2f);
|
||
chaomifenTransform.SetActive(false);
|
||
for (int i = 0; i < chaomifenTransform.transform.childCount; i++)
|
||
{
|
||
chaomifenTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//鼎边锉动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "鼎边锉")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "搅拌")
|
||
{
|
||
Jiaobandingbiancuo.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name+ "鼎边锉");
|
||
Invoke("Jiaobandingbiancuosetactive", 2f);
|
||
dingbiancuoTransform.SetActive(false);
|
||
for (int i = 0; i < dingbiancuoTransform.transform.childCount; i++)
|
||
{
|
||
dingbiancuoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
Zhudingbiancuo.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhudingbiancuosetactive", 2f);
|
||
dingbiancuoTransform.SetActive(false);
|
||
for (int i = 0; i < dingbiancuoTransform.transform.childCount; i++)
|
||
{
|
||
dingbiancuoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "装盘")
|
||
{
|
||
Zhuangpandingbiancuo.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semidingbiancuo1.SetActive(false);
|
||
semidingbiancuo2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhuanpansetactive", 1.5f);
|
||
dingbiancuoTransform.SetActive(false);
|
||
for (int i = 0; i < dingbiancuoTransform.transform.childCount; i++)
|
||
{
|
||
dingbiancuoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//豆腐动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "深坑豆腐")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "煎")
|
||
{
|
||
Jiandoufu.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Jiandoufusetactive", 2f);
|
||
doufuTransform.SetActive(false);
|
||
|
||
for (int i = 0; i < doufuTransform.transform.childCount; i++)
|
||
{
|
||
doufuTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "炒")
|
||
{
|
||
Chaodoufu.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Chaodoufusetactive", 2f);
|
||
doufuTransform.SetActive(false);
|
||
animationloadmark++;
|
||
for (int i = 0; i < doufuTransform.transform.childCount; i++)
|
||
{
|
||
doufuTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
Zhudoufu.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semidoufu1.SetActive(false);
|
||
semidoufu2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhudoufusetactive", 2f);
|
||
doufuTransform.SetActive(false);
|
||
for (int i = 0; i < doufuTransform.transform.childCount; i++)
|
||
{
|
||
doufuTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//猪蹄动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "万峦猪蹄")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhuzhuti.SetActive(true);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name+"猪蹄");
|
||
animationloadmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhuzhuti2.SetActive(true);
|
||
semizhuti2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
}
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
Invoke("Zhuzhutisetactive", 2f);
|
||
zhutiTransform.SetActive(false);
|
||
for (int i = 0; i < zhutiTransform.transform.childCount; i++)
|
||
{
|
||
zhutiTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "炒")
|
||
{
|
||
Chaozhuti.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semizhuti1.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Chaozhutisetactive", 2f);
|
||
zhutiTransform.SetActive(false);
|
||
animationloadmark++;
|
||
for (int i = 0; i < zhutiTransform.transform.childCount; i++)
|
||
{
|
||
zhutiTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
wok.SetActive(false);
|
||
}
|
||
}
|
||
|
||
//烧仙草动画
|
||
else if (txtFoodName.GetComponent<Text>().text == "烧仙草")
|
||
{
|
||
if (selectedSteps[currentStepIndex].name == "蒸")
|
||
{
|
||
Zhengshaoxiancao.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhengshaoxiancaosetactive", 2f);
|
||
shaoxiancaoTransform.SetActive(false);
|
||
for (int i = 0; i < shaoxiancaoTransform.transform.childCount; i++)
|
||
{
|
||
shaoxiancaoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "煮")
|
||
{
|
||
Zhushaoxiancao.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
wok.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhushaoxiancaosetactive", 2f);
|
||
shaoxiancaoTransform.SetActive(false);
|
||
animationloadmark++;
|
||
for (int i = 0; i < shaoxiancaoTransform.transform.childCount; i++)
|
||
{
|
||
shaoxiancaoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
|
||
}
|
||
else if (selectedSteps[currentStepIndex].name == "装盘")
|
||
{
|
||
Zhuangpanshaoxiancao.SetActive(true);
|
||
StepCenter.SetActive(false);
|
||
semishaoxiancao1.SetActive(false);
|
||
semishaoxaincao2.SetActive(false);
|
||
animator.SetTrigger(selectedSteps[currentStepIndex].name);
|
||
Invoke("Zhuanpansetactive", 1.5f);
|
||
shaoxiancaoTransform.SetActive(false);
|
||
for (int i = 0; i < shaoxiancaoTransform.transform.childCount; i++)
|
||
{
|
||
shaoxiancaoTransform.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
currentStepIndex++;
|
||
}
|
||
|
||
//关闭烹饪动画
|
||
//卤肉饭
|
||
public void Chaoluroufansetactive()
|
||
{
|
||
Chaoluroufan.SetActive(false);
|
||
wok.SetActive(true);
|
||
semiluroufan1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
luroufanTransform.SetActive(true);
|
||
}
|
||
public void Luluroufansetactive()
|
||
{
|
||
Luluroufan.SetActive(false);
|
||
wok.SetActive(true);
|
||
semiluroufan2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
luroufanTransform.SetActive(true);
|
||
}
|
||
|
||
//蚵仔煎
|
||
public void Jiaobankezaijiansetactive()
|
||
{
|
||
if (animationmark==0)
|
||
{
|
||
Jiaobankezaijian.SetActive(false);
|
||
animationmark++;
|
||
semikezaijian1.SetActive(true);
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Jiaobankezaijian2.SetActive(false);
|
||
semikezaijian2.SetActive(true);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
kezaijianTransform.SetActive(true);
|
||
}
|
||
public void Jiankezaijiansetactive()
|
||
{
|
||
Jiankezaijian.SetActive(false);
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
kezaijianTransform.SetActive(true);
|
||
}
|
||
|
||
//担仔面
|
||
public void Jiaobandanzaimainsetactive()
|
||
{
|
||
|
||
if (animationmark==0)
|
||
{
|
||
Jiaobandanzaimian.SetActive(false);
|
||
semidaizaimian1.SetActive(true);
|
||
animationmark++;
|
||
}
|
||
else if (animationmark==1)
|
||
{
|
||
Jiaobandanzaimian2.SetActive(false);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
danzaimianTransform.SetActive(true);
|
||
}
|
||
public void Zhudanzaimiansetactive()
|
||
{
|
||
Zhudanzaimian.SetActive(false);
|
||
wok.SetActive(true);
|
||
semidanzaimian2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
danzaimianTransform.SetActive(true);
|
||
}
|
||
|
||
//肉粽
|
||
public void Jinpaorouzongsetactive()
|
||
{
|
||
Jinpaorouzong.SetActive(false);
|
||
wok.SetActive(true);
|
||
semirouzong1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
zongziTransform.SetActive(true);
|
||
}
|
||
public void Zhurouzongsetactive()
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhurouzong.SetActive(false);
|
||
semirouzong2.SetActive(true);
|
||
animationmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhurouzong2.SetActive(false);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
zongziTransform.SetActive(true);
|
||
}
|
||
public void Baorouzongsetactive()
|
||
{
|
||
Baorouzong.SetActive(false);
|
||
wok.SetActive(true);
|
||
semirouzong3.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
zongziTransform.SetActive(true);
|
||
}
|
||
|
||
//大肠蚵仔面
|
||
public void Lukezaimiansetactive()
|
||
{
|
||
Lukezaimian.SetActive(false);
|
||
wok.SetActive(true);
|
||
semikezaimian1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
kezaimianTransform.SetActive(true);
|
||
}
|
||
public void Zhukezaimiansetactive()
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhukezaimian.SetActive(false);
|
||
semikezaimian2.SetActive(true);
|
||
animationmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhukezaimian2.SetActive(false);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
kezaimianTransform.SetActive(true);
|
||
}
|
||
|
||
//台湾炒米粉
|
||
public void Chaochaomifensetactive()
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Chaochaomifen.SetActive(false);
|
||
semichaomifen1.SetActive(true);
|
||
animationmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Chaochaomifen2.SetActive(false);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
chaomifenTransform.SetActive(true);
|
||
}
|
||
public void Jianchaomifensetactive()
|
||
{
|
||
Jianchaomifen.SetActive(false);
|
||
wok.SetActive(true);
|
||
semichaomifen2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
chaomifenTransform.SetActive(true);
|
||
}
|
||
|
||
//鼎边锉
|
||
public void Jiaobandingbiancuosetactive()
|
||
{
|
||
Jiaobandingbiancuo.SetActive(false);
|
||
wok.SetActive(true);
|
||
semidingbiancuo1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
dingbiancuoTransform.SetActive(true);
|
||
}
|
||
public void Zhudingbiancuosetactive()
|
||
{
|
||
Zhudingbiancuo.SetActive(false);
|
||
wok.SetActive(true);
|
||
semidingbiancuo2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
dingbiancuoTransform.SetActive(true);
|
||
}
|
||
|
||
//深坑豆腐
|
||
public void Jiandoufusetactive()
|
||
{
|
||
Jiandoufu.SetActive(false);
|
||
wok.SetActive(true);
|
||
semidoufu1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
doufuTransform.SetActive(true);
|
||
}
|
||
public void Chaodoufusetactive()
|
||
{
|
||
Chaodoufu.SetActive(false);
|
||
semidoufu2.SetActive(true);
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
doufuTransform.SetActive(true);
|
||
}
|
||
public void Zhudoufusetactive()
|
||
{
|
||
Zhudoufu.SetActive(false);
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
doufuTransform.SetActive(true);
|
||
}
|
||
|
||
//万峦猪蹄
|
||
public void Zhuzhutisetactive()
|
||
{
|
||
if (animationmark == 0)
|
||
{
|
||
Zhuzhuti.SetActive(false);
|
||
semizhuti1.SetActive(true);
|
||
animationmark++;
|
||
}
|
||
else if (animationmark == 1)
|
||
{
|
||
Zhuzhuti2.SetActive(false);
|
||
}
|
||
wok.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
zhutiTransform.SetActive(true);
|
||
}
|
||
public void Chaozhutisetactive()
|
||
{
|
||
Chaozhuti.SetActive(false);
|
||
wok.SetActive(true);
|
||
semizhuti2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
zhutiTransform.SetActive(true);
|
||
}
|
||
|
||
//烧仙草
|
||
public void Zhengshaoxiancaosetactive()
|
||
{
|
||
Zhengshaoxiancao.SetActive(false);
|
||
wok.SetActive(true);
|
||
semishaoxiancao1.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
shaoxiancaoTransform.SetActive(true);
|
||
}
|
||
public void Zhushaoxiancaosetactive()
|
||
{
|
||
Zhushaoxiancao.SetActive(false);
|
||
wok.SetActive(true);
|
||
semishaoxaincao2.SetActive(true);
|
||
Invoke("Stepstips", 0);
|
||
shaoxiancaoTransform.SetActive(true);
|
||
}
|
||
|
||
//装盘
|
||
public void Zhuanpansetactive()
|
||
{
|
||
Zhuanpanluroufan.SetActive(false);
|
||
Zhuangpandingbiancuo.SetActive(false);
|
||
Zhuangpanshaoxiancao.SetActive(false);
|
||
}
|
||
|
||
//交互音频
|
||
public AudioClip audiowin;
|
||
public AudioClip audioright;
|
||
public AudioClip audiomistake;
|
||
public AudioClip audiopage;
|
||
|
||
//烹饪动画音频
|
||
public AudioClip audiochao;
|
||
public AudioClip audiojiaoban;
|
||
public AudioClip audiojinpao;
|
||
public AudioClip audiolu;
|
||
public AudioClip audiojian;
|
||
public AudioClip audiozhu;
|
||
public AudioClip audiozheng;
|
||
public AudioClip audiozhuangpan;
|
||
|
||
//音频控制
|
||
public void PlayAudioByName(string name)
|
||
{
|
||
AudioManager.Instance.PlayAudio(name);
|
||
|
||
//AudioClip audio = null;
|
||
//if (name == "win") audio = audiowin;
|
||
//else if (name == "right") audio = audioright;
|
||
//else if (name == "mistake") audio = audiomistake;
|
||
//else if (name == "page") audio = audiopage;
|
||
|
||
//else if (name == "炒") audio = audiochao;
|
||
//else if (name == "搅拌") audio = audiojiaoban;
|
||
//else if (name == "浸泡") audio = audiojinpao;
|
||
//else if (name == "卤") audio = audiolu;
|
||
//else if (name == "煎") audio = audiojian;
|
||
//else if (name == "煮") audio = audiozhu;
|
||
//else if (name == "蒸") audio = audiozheng;
|
||
//else if (name == "装盘") audio = audiozhuangpan;
|
||
////else if (name == "包") audio = null;
|
||
|
||
//AudioSource.PlayClipAtPoint(audio, Camera.main.transform.position);
|
||
}
|
||
//动画预载
|
||
public void AnimationLoad()
|
||
{
|
||
GameObject obj = EventSystem.current.currentSelectedGameObject;
|
||
//卤肉饭动画素材
|
||
if (txtFoodName.GetComponent<Text>().text == "卤肉饭")
|
||
{
|
||
luroufanTransform.SetActive(true);
|
||
if (obj.name == "洋葱")
|
||
{
|
||
onions.SetActive(true);
|
||
}
|
||
else if (obj.name == "香菇")
|
||
{
|
||
mushroom.SetActive(true);
|
||
}
|
||
else if (obj.name == "五花肉")
|
||
{
|
||
pork.SetActive(true);
|
||
}
|
||
else if (obj.name == "白米饭")
|
||
{
|
||
rice.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//蚵仔煎动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "蚵仔煎")
|
||
{
|
||
kezaijianTransform.SetActive(true);
|
||
if (obj.name == "鸡蛋"&& animationloadmark == 0)
|
||
{
|
||
egg.SetActive(true);
|
||
}
|
||
else if (obj.name == "蚵仔"&& animationloadmark == 0)
|
||
{
|
||
oysters.SetActive(true);
|
||
}
|
||
else if (obj.name == "鸡蛋"&&animationloadmark==1)
|
||
{
|
||
eggliquid.SetActive(true);
|
||
semikezaijian1.SetActive(false);
|
||
}
|
||
else if (obj.name == "蚵仔" && animationloadmark == 1)
|
||
{
|
||
oyster2.SetActive(true);
|
||
semikezaijian2.SetActive(false);
|
||
}
|
||
else if (obj.name == "香葱" )
|
||
{
|
||
onionskezaijian.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//担仔面动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "担仔面")
|
||
{
|
||
danzaimianTransform.SetActive(true);
|
||
if (obj.name == "五花肉")
|
||
{
|
||
porkdanzaimian.SetActive(true);
|
||
}
|
||
else if (obj.name == "面条"&& animationloadmark == 0)
|
||
{
|
||
noodles.SetActive(true);
|
||
}
|
||
else if (obj.name == "面条" && animationloadmark == 1)
|
||
{
|
||
noodles2.SetActive(true);
|
||
}
|
||
else if (obj.name == "虾仁")
|
||
{
|
||
shrimpdanzaimian.SetActive(true);
|
||
}
|
||
else if (obj.name == "香菜")
|
||
{
|
||
coriander.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//肉粽动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "肉粽")
|
||
{
|
||
zongziTransform.SetActive(true);
|
||
if (obj.name == "糯米" && animationloadmark == 0)
|
||
{
|
||
ricezongzi.SetActive(true);
|
||
}
|
||
else if (obj.name == "洋葱")
|
||
{
|
||
onionszongzi.SetActive(true);
|
||
}
|
||
else if (obj.name == "香菇")
|
||
{
|
||
mushroomzongzi.SetActive(true);
|
||
}
|
||
else if (obj.name == "猪肉")
|
||
{
|
||
porkzongzi.SetActive(true);
|
||
}
|
||
else if (obj.name == "糯米" && animationloadmark == 1)
|
||
{
|
||
ricezongzi2.SetActive(true);
|
||
semirouzong1.SetActive(false);
|
||
}
|
||
else if (obj.name == "粽叶")
|
||
{
|
||
leaves.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//蚵仔面动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "大肠蚵仔面线")
|
||
{
|
||
kezaimianTransform.SetActive(true);
|
||
if (obj.name == "大肠")
|
||
{
|
||
intestine.SetActive(true);
|
||
}
|
||
else if (obj.name == "蚵仔")
|
||
{
|
||
oysterskezaimian.SetActive(true);
|
||
}
|
||
else if (obj.name == "面条")
|
||
{
|
||
nooldeskezaimian.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//炒米粉动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "台湾炒米粉")
|
||
{
|
||
chaomifenTransform.SetActive(true);
|
||
if (obj.name == "香菇"&& animationloadmark == 0)
|
||
{
|
||
mushroomchaomifen.SetActive(true);
|
||
}
|
||
else if (obj.name == "洋葱"&& animationloadmark == 0)
|
||
{
|
||
onionschaomifen.SetActive(true);
|
||
}
|
||
else if (obj.name == "猪肉"&& animationloadmark == 0)
|
||
{
|
||
porkchaomifen.SetActive(true);
|
||
}
|
||
else if (obj.name == "鸡蛋")
|
||
{
|
||
eggchaomifen.SetActive(true);
|
||
}
|
||
else if (obj.name == "米粉")
|
||
{
|
||
flour.SetActive(true);
|
||
}
|
||
else if (obj.name == "香菇" && animationloadmark == 1)
|
||
{
|
||
mushroomchaomifen2.SetActive(true);
|
||
}
|
||
else if (obj.name == "洋葱" && animationloadmark == 1)
|
||
{
|
||
onionschaomifen2.SetActive(true);
|
||
}
|
||
else if (obj.name == "猪肉" && animationloadmark == 1)
|
||
{
|
||
porkchaomifen2.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//鼎边锉动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "鼎边锉")
|
||
{
|
||
dingbiancuoTransform.SetActive(true);
|
||
if (obj.name == "木薯粉")
|
||
{
|
||
powderdingbiancuo.SetActive(true);
|
||
}
|
||
else if (obj.name == "香菇")
|
||
{
|
||
mushroomdingbiancuo.SetActive(true);
|
||
}
|
||
else if (obj.name == "虾仁")
|
||
{
|
||
shrimpdingbiancuo.SetActive(true);
|
||
}
|
||
else if (obj.name == "蚵仔")
|
||
{
|
||
oysterdingbiancuo.SetActive(true);
|
||
}
|
||
else if (obj.name == "香葱")
|
||
{
|
||
chive.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//豆腐动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "深坑豆腐")
|
||
{
|
||
doufuTransform.SetActive(true);
|
||
if (obj.name == "豆腐"&& animationloadmark == 0)
|
||
{
|
||
doufu.SetActive(true);
|
||
}
|
||
else if (obj.name == "蒜瓣"&& animationloadmark == 0)
|
||
{
|
||
garlic.SetActive(true);
|
||
}
|
||
else if (obj.name == "豆腐" && animationloadmark == 1)
|
||
{
|
||
doufu2.SetActive(true);
|
||
semidoufu1.SetActive(false);
|
||
}
|
||
else if (obj.name == "蒜瓣" && animationloadmark == 1)
|
||
{
|
||
garlic2.SetActive(true);
|
||
semidoufu2.SetActive(false);
|
||
}
|
||
|
||
}
|
||
|
||
//猪蹄动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "万峦猪蹄")
|
||
{
|
||
zhutiTransform.SetActive(true);
|
||
if (obj.name == "猪蹄"&&animationloadmark == 0)
|
||
{
|
||
trotters.SetActive(true);
|
||
}
|
||
else if (obj.name == "冰糖")
|
||
{
|
||
candy.SetActive(true);
|
||
}
|
||
else if (obj.name == "猪蹄" && animationloadmark == 1)
|
||
{
|
||
trotters2.SetActive(true);
|
||
semizhuti1.SetActive(false);
|
||
}
|
||
else if (obj.name == "猪蹄" && animationloadmark == 2)
|
||
{
|
||
trotters3.SetActive(true);
|
||
}
|
||
}
|
||
|
||
//烧仙草动画素材
|
||
else if (txtFoodName.GetComponent<Text>().text == "烧仙草")
|
||
{
|
||
shaoxiancaoTransform.SetActive(true);
|
||
if (obj.name == "紫薯")
|
||
{
|
||
potato.SetActive(true);
|
||
}
|
||
else if (obj.name == "芋圆" && animationloadmark == 0)
|
||
{
|
||
ball.SetActive(true);
|
||
}
|
||
else if (obj.name == "珍珠" && animationloadmark == 0)
|
||
{
|
||
pearl.SetActive(true);
|
||
}
|
||
else if (obj.name == "仙草")
|
||
{
|
||
grass.SetActive(true);
|
||
}
|
||
else if (obj.name == "牛奶")
|
||
{
|
||
milk.SetActive(true);
|
||
}
|
||
else if (obj.name == "芋圆" && animationloadmark == 1)
|
||
{
|
||
ball2.SetActive(true);
|
||
semishaoxaincao2.SetActive(false);
|
||
}
|
||
else if (obj.name == "珍珠" && animationloadmark == 1)
|
||
{
|
||
pearl2.SetActive(true);
|
||
semishaoxaincao2.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
//选项随机排序
|
||
private void TransRandom(Transform transPar)
|
||
{
|
||
System.Random ran = new System.Random();
|
||
int index = 0;
|
||
Transform temp;
|
||
for (int i = 0; i < transPar.childCount; i++)
|
||
{
|
||
index = ran.Next(0, transPar.childCount - 1);
|
||
if (index!=i)
|
||
{
|
||
temp = transPar.GetChild(index);
|
||
transPar.GetChild(i).SetSiblingIndex(index);
|
||
temp.SetSiblingIndex(i);
|
||
}
|
||
}
|
||
}
|
||
}
|