using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UIFramework;
using System;
using UniRx;
public class MonophonicWaveRegulation : MonoBehaviour
{
[SerializeField]
private GameObject m_SoundWaveRegulation;
[SerializeField]
private Button Engine;
Vector3 vectorSoundWaveRegulation = new Vector3(-135f, 52f, 0f);
[SerializeField]
private Button Close;
Vector3 vectorClose = new Vector3(139f, 52f, 0f);
[SerializeField]
private Button Sure;
[SerializeField]
private Button MaskClose;
[SerializeField]
private Image Img_PitchOn;
Vector3 vectorPitchOnStart = new Vector3(-135f, 52f, 0f);
private PitchOn _currentlySelected = PitchOn.PitchEngine;
private PitchOn _savelySelected = PitchOn.PitchEngine;
private bool isClick = false;
enum PitchOn
{
PitchEngine,
PitchInductance,
PitchClose
}
private static readonly string TAG = "SoundWaveRegulation";
private void Start()
{
DataCenter.savesoundvalue.Subscribe(i =>
{
Log.I(TAG, "savesoundvalue value:" + i);
if (i == 2)
{
Img_PitchOn.transform.localPosition = vectorSoundWaveRegulation;
}
else
{
Img_PitchOn.transform.localPosition = vectorClose;
}
}).AddTo(this);
//Img_PitchOn.transform.localPosition = vectorPitchOnStart;
Engine.onClick.AddListener(() =>
{
Log.I(TAG, "Engine Button Clicked!");
isClick = true;
_currentlySelected = PitchOn.PitchEngine;
OnMonophonicWaveRegulation(_currentlySelected);
});
//点击关按钮 只是声浪的一种模式 不保存则数据无效 保存则静音
Close.onClick.AddListener(() =>
{
Log.I(TAG, "Close Button Clicked!");
_currentlySelected = PitchOn.PitchClose;
OnMonophonicWaveRegulation(_currentlySelected);
});
//点击弹窗以外区域关闭当前弹窗 不保存数据
MaskClose.onClick.AddListener(() =>
{
Log.I(TAG, "MaskClose Button Clicked!");
m_SoundWaveRegulation.SetActive(false);
});
//点击确定按钮 并保存数据
Sure.onClick.AddListener(() =>
{
_savelySelected = _currentlySelected;
Log.I(TAG, "Sure Button Clicked!");
Log.I(TAG, "_savelySelected:" + _savelySelected);
switch (_currentlySelected)
{
case PitchOn.PitchEngine:
SuperSportNative.SwitchSoundWave(2);
break;
case PitchOn.PitchClose:
SuperSportNative.SwitchSoundWave(0);
break;
default:
break;
}
m_SoundWaveRegulation.SetActive(false);
});
}
private void OnEnable()
{
OnMonophonicWaveRegulation(_savelySelected);
}
private void OnMonophonicWaveRegulation(PitchOn pitchOn)
{
Log.I(TAG, "pitchOn:" + pitchOn);
if (pitchOn == PitchOn.PitchEngine)
{
Img_PitchOn.transform.localPosition = vectorSoundWaveRegulation;
//if (isClick == true)
//{
// Log.I(TAG, "Play TOPSPEEDINDUCTANCE!");
// SoundManager.Instance.Play(new Sound
// {
// BeginTime = 0,
// ESound = ESound.TOPSPEEDINDUCTANCE
// });
//}
//else
//{
// return;
//}
}
if (pitchOn == PitchOn.PitchClose)
{
Img_PitchOn.transform.localPosition = vectorClose;
//SuperSportNative.PlayVoice((int)ESound.TOPSPEEDINDUCTANCE, false);
}
}
}