147 lines
3.7 KiB
C#
147 lines
3.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using Logic.AI;
|
|
using Logic.Multilingual;
|
|
using MongoDB.Driver;
|
|
using NodeCanvas.Tasks.Actions;
|
|
using RuntimeData;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_Logic.Steam;
|
|
using TH1_UI.HintUI;
|
|
using TH1_UI.View.Outside;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using UI.HintUI;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIOutsideSelectCheckPanelMono : MonoBehaviour
|
|
{
|
|
|
|
public UIOutsideSelectOptionGroupMono GameMode;
|
|
public UIOutsideSelectOptionGroupMono PlayerCount;
|
|
public UIOutsideSelectOptionGroupMono MapSize;
|
|
public UIOutsideSelectOptionGroupMono Diff;
|
|
public Button StartButton;
|
|
public Button CloseButton;
|
|
public Button BlockerButton;
|
|
public AnimancerComponent Animancer;
|
|
|
|
private Action _onStartClick;
|
|
public void Init(Action onStartClick)
|
|
{
|
|
InitSetting();
|
|
_onStartClick = onStartClick;
|
|
StartButton.onClick.RemoveAllListeners();
|
|
StartButton.onClick.AddListener(() =>
|
|
{
|
|
//Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut);
|
|
_onStartClick.Invoke();
|
|
});
|
|
|
|
CloseButton.onClick.RemoveAllListeners();
|
|
CloseButton.onClick.AddListener(Hide);
|
|
|
|
BlockerButton.onClick.RemoveAllListeners();
|
|
BlockerButton.onClick.AddListener(Hide);
|
|
}
|
|
public void InitSetting()
|
|
{
|
|
|
|
uint playerCount = 2;
|
|
AIDifficult diff = AIDifficult.HARD;
|
|
GameMode gameMode = RuntimeData.GameMode.DOMINATION;
|
|
//读取玩家缺省存储值
|
|
if (Main.Instance.MapConfig != null)
|
|
{
|
|
playerCount = Main.Instance.MapConfig.PlayerCount;
|
|
diff = Main.Instance.MapConfig.AIDiff;
|
|
gameMode = Main.Instance.MapConfig.GameMode;
|
|
}
|
|
|
|
|
|
uint playerCountIdx = playerCount switch
|
|
{
|
|
2 => 0,
|
|
3 => 1,
|
|
4 => 2,
|
|
5 => 3,
|
|
6 => 4,
|
|
7 => 5,
|
|
8 => 6,
|
|
_ => 0
|
|
};
|
|
uint mapSizeIdx = playerCount switch
|
|
{
|
|
2 => 0,
|
|
3 => 1,
|
|
4 => 2,
|
|
_ => 3
|
|
};
|
|
uint diffIdx = diff switch
|
|
{
|
|
AIDifficult.EASY => 0,
|
|
AIDifficult.NORMAL => 1,
|
|
AIDifficult.HARD => 2,
|
|
_ => 3
|
|
};
|
|
uint gameModeIdx = gameMode switch
|
|
{
|
|
RuntimeData.GameMode.PERFECT => 0,
|
|
RuntimeData.GameMode.DOMINATION => 1,
|
|
_ => 2
|
|
};
|
|
//GameMode.Init(gameModeIdx);
|
|
PlayerCount.Init(playerCountIdx);
|
|
PlayerCount.OnOptionClicked = OnPlayerOptionClicked;
|
|
MapSize.Init(mapSizeIdx);
|
|
Diff.Init(diffIdx);
|
|
}
|
|
|
|
public void OnPlayerOptionClicked(uint idx)
|
|
{
|
|
uint mapSizeIdx = idx switch
|
|
{
|
|
0 => 0,
|
|
1 => 1,
|
|
2 => 2,
|
|
_ => 3
|
|
};
|
|
MapSize.Select(mapSizeIdx);
|
|
}
|
|
|
|
public void Show()
|
|
{
|
|
InitSetting();
|
|
gameObject.SetActive(true);
|
|
Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeIn);
|
|
|
|
Timer.Instance.TimerRegister(this, () =>
|
|
{
|
|
|
|
GameMode.OnShow();
|
|
PlayerCount.OnShow();
|
|
Diff.OnShow();
|
|
},0.01f,"");
|
|
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
var state = Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut);
|
|
state.Events.OnEnd = () => { gameObject.SetActive(false); };
|
|
}
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
} |