using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class AlchemyNotifyBehaviour : MonoBehaviour, IInGamePush
|
{
|
[SerializeField] Button m_Goto;
|
[SerializeField] Button m_Close;
|
|
AlchemyModel model { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
|
|
private void Awake()
|
{
|
m_Goto.AddListener(Goto);
|
m_Close.AddListener(Close);
|
}
|
|
public void Initialize()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= PerSecond;
|
GlobalTimeEvent.Instance.secondEvent += PerSecond;
|
}
|
|
public void UnInitialize()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= PerSecond;
|
}
|
|
private void PerSecond()
|
{
|
var isAlchemyComplete = false;
|
|
int alchemyId;
|
if (model.IsStoveAlcheming(AlchemyType.Normal, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2 && !model.alchemyNormalNotifySymbol)
|
{
|
isAlchemyComplete = true;
|
}
|
}
|
if (model.IsStoveAlcheming(AlchemyType.Fairy, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2 && !model.alchemyFairyNotifySymbol)
|
{
|
isAlchemyComplete = true;
|
}
|
}
|
|
if (isAlchemyComplete)
|
{
|
if (!gameObject.activeSelf)
|
{
|
gameObject.SetActive(true);
|
}
|
}
|
else
|
{
|
if (gameObject.activeSelf)
|
{
|
gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void Goto()
|
{
|
int alchemyId;
|
if (model.IsStoveAlcheming(AlchemyType.Normal, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2)
|
{
|
model.alchemyNormalNotifySymbol = true;
|
gameObject.SetActive(false);
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.AlchemyNormal);
|
return;
|
}
|
}
|
if (model.IsStoveAlcheming(AlchemyType.Fairy, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2)
|
{
|
model.alchemyFairyNotifySymbol = true;
|
gameObject.SetActive(false);
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.AlchemyFairy);
|
return;
|
}
|
}
|
}
|
|
private void Close()
|
{
|
int alchemyId;
|
if (model.IsStoveAlcheming(AlchemyType.Normal, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2)
|
{
|
model.alchemyNormalNotifySymbol = true;
|
}
|
}
|
if (model.IsStoveAlcheming(AlchemyType.Fairy, out alchemyId))
|
{
|
if (model.GetStoveState(alchemyId) == 2)
|
{
|
model.alchemyFairyNotifySymbol = true;
|
}
|
}
|
|
gameObject.SetActive(false);
|
}
|
|
public int GetSiblingIndex()
|
{
|
return transform.GetSiblingIndex();
|
}
|
|
public bool IsActive()
|
{
|
return gameObject.activeSelf;
|
}
|
}
|
}
|