| | |
| | | {
|
| | | public class AlchemyStoveBehaviour : MonoBehaviour
|
| | | {
|
| | | [SerializeField] Transform m_ContainerMaterials;
|
| | | [SerializeField] AlchemyMaterial[] m_AlchemyMaterials;
|
| | |
|
| | | [SerializeField] Transform m_ContainerAlcheming;
|
| | |
| | | [SerializeField] Text m_FuncLabel;
|
| | | [SerializeField] Transform m_ContainerUnGrasp;
|
| | |
|
| | | [SerializeField] UIEffect m_AlchemingEffect;
|
| | | [SerializeField] UIEffect m_AlchemyCompleteEffect;
|
| | | [SerializeField] UIEffect[] m_AlchemyFlyEffects;
|
| | | [SerializeField] Transform m_ContainerFlyMaterials;
|
| | | [SerializeField] Transform[] m_FlyMaterials;
|
| | | [SerializeField] Image[] m_FlyIcons;
|
| | | [SerializeField] UIEffect m_AlchemyBoomEffect;
|
| | |
|
| | | int m_State = 0; //0-正常状态 1-炼丹中 2-炼丹结束
|
| | | int state
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | float timer = 0f;
|
| | |
|
| | | bool animationStep = false;
|
| | |
|
| | | AlchemyModel model { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
|
| | | PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
| | |
| | | m_ContainerNormal.gameObject.SetActive(state == 0);
|
| | | m_ContainerComplete.gameObject.SetActive(state == 2);
|
| | |
|
| | | m_AlchemingEffect.StopImediatly();
|
| | | m_AlchemyCompleteEffect.StopImediatly();
|
| | |
|
| | | m_ContainerMaterials.gameObject.SetActive(false);
|
| | | m_ContainerFlyMaterials.gameObject.SetActive(false);
|
| | |
|
| | | switch (state)
|
| | | {
|
| | | case 0:
|
| | | m_ContainerMaterials.gameObject.SetActive(true);
|
| | | m_StoveLevel.text = StringUtility.Contact("Lv.", model.stoveLevel);
|
| | | var isMax = !RefineStoveConfig.Has(model.stoveLevel + 1);
|
| | | var stoveConfig = RefineStoveConfig.Get(model.stoveLevel);
|
| | |
| | | }
|
| | | break;
|
| | | case 1:
|
| | | uint tick = 0;
|
| | | if (model.TryGetAlchemyStartTime(model.selectAlchemy, out tick))
|
| | | {
|
| | | var config = AlchemyConfig.Get(model.selectAlchemy);
|
| | | var startTime = TimeUtility.GetTime(tick);
|
| | | var seconds = (int)(config.NeedTime - (float)(TimeUtility.ServerNow - startTime).TotalSeconds);
|
| | | m_AlchemyTime.text = TimeUtility.SecondsToHMS(seconds);
|
| | | }
|
| | | m_AlchemingEffect.Play();
|
| | | DisplayAlchemyTime();
|
| | | break;
|
| | | case 2:
|
| | | m_AlchemyCompleteEffect.Play();
|
| | | break;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | void DisplayAlchemyTime()
|
| | | {
|
| | | uint tick = 0;
|
| | | if (model.TryGetAlchemyStartTime(model.selectAlchemy, out tick))
|
| | | {
|
| | | var config = AlchemyConfig.Get(model.selectAlchemy);
|
| | | var startTime = TimeUtility.GetTime(tick);
|
| | | var seconds = (int)(config.NeedTime - (float)(TimeUtility.ServerNow - startTime).TotalSeconds);
|
| | | m_AlchemyTime.text = TimeUtility.SecondsToHMS(seconds);
|
| | | }
|
| | | }
|
| | |
|
| | | void DisplayAnimation()
|
| | | {
|
| | | m_ContainerMaterials.gameObject.SetActive(false);
|
| | | m_ContainerFlyMaterials.gameObject.SetActive(true);
|
| | | List<Item> materials;
|
| | | model.TryGetAlchemyMaterials(model.selectAlchemy, out materials);
|
| | | for (int i = 0; i < m_FlyMaterials.Length; i++)
|
| | | {
|
| | | m_FlyMaterials[i].gameObject.SetActive(i < materials.Count);
|
| | | if (i < materials.Count)
|
| | | {
|
| | | var itemConfig = ItemConfig.Get(materials[i].id);
|
| | | m_FlyIcons[i].SetSprite(itemConfig.IconKey);
|
| | | m_AlchemyFlyEffects[i].Play();
|
| | | var parent = m_AlchemyFlyEffects[i].target.transform.Find("Animation/GuadianAnimation");
|
| | | if (parent != null)
|
| | | {
|
| | | m_FlyMaterials[i].SetParent(parent);
|
| | | m_FlyMaterials[i].transform.localPosition = Vector3.zero;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_AlchemyFlyEffects[i].StopImediatly();
|
| | | }
|
| | | }
|
| | |
|
| | | StartCoroutine(Co_DisplayAnimation());
|
| | | }
|
| | |
|
| | | IEnumerator Co_DisplayAnimation()
|
| | | {
|
| | | m_AlchemyBoomEffect.Play();
|
| | | yield return WaitingForSecondConst.WaitMS700;
|
| | | m_ContainerFlyMaterials.gameObject.SetActive(false);
|
| | | for (int i = 0; i < m_FlyMaterials.Length; i++)
|
| | | {
|
| | | m_FlyMaterials[i].SetParent(m_ContainerFlyMaterials);
|
| | | }
|
| | | animationStep = false;
|
| | | m_State = model.GetStoveState(model.selectAlchemy);
|
| | | DisplayStove();
|
| | | }
|
| | |
|
| | | private void SelectAlchemyRefresh()
|
| | | {
|
| | | m_State = model.GetStoveState(model.selectAlchemy);
|
| | |
| | |
|
| | | private void AlchemyStateRefresh()
|
| | | {
|
| | | m_State = model.GetStoveState(model.selectAlchemy);
|
| | | DisplayStove();
|
| | | DisplayAlchemyMaterials();
|
| | | animationStep = false;
|
| | |
|
| | | if (model.isServerPrepare)
|
| | | {
|
| | | var newState = model.GetStoveState(model.selectAlchemy);
|
| | | if (newState == 1 && state == 0)
|
| | | {
|
| | | animationStep = true;
|
| | | }
|
| | | }
|
| | | if (!animationStep)
|
| | | {
|
| | | m_State = model.GetStoveState(model.selectAlchemy);
|
| | | DisplayStove();
|
| | | DisplayAlchemyMaterials();
|
| | | }
|
| | |
|
| | | if (animationStep)
|
| | | {
|
| | | DisplayAnimation();
|
| | | }
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshEvent(PlayerDataType dataType)
|
| | |
| | |
|
| | | private void PerSecond()
|
| | | {
|
| | | if (animationStep)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | var _state = model.GetStoveState(model.selectAlchemy);
|
| | |
|
| | | if (_state == state)
|
| | | {
|
| | | if (state == 1)
|
| | | {
|
| | | DisplayStove();
|
| | | DisplayAlchemyTime();
|
| | | }
|
| | | }
|
| | | else
|
| | |
| | | model.alchemyStateRefresh -= AlchemyStateRefresh;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
| | |
|
| | | StopAllCoroutines();
|
| | | animationStep = false;
|
| | | }
|
| | | }
|
| | |
|