using UnityEngine; using System.Collections; using System.Collections.Generic; public class BattleUI : MonoBehaviour { public GameObject radioPanelPrefab; public GameObject OptionPanelPrefab; public GameObject battleMissionPrefab; public GameObject myRankPanelPrefab; public GameObject battleReadyPrefab; public ScoreBar scoreBar; public MiniMap miniMap; public PowerIconContainer powerIconContainer; public BattleClockUI battleClock; public BottomTip bottomTip; public BattleInfo battleInfo; public GameObject coinBar; public GameObject replayBar; public GameObject optionBtnObj; private RadioPanel radioPanel; public Sprite[] crystalPowerIcons; public BattleController battleController; public void Init(BattleController battleController, bool isMenu = false) { this.battleController = battleController; if(isMenu) { optionBtnObj.SetActive(false); scoreBar.gameObject.SetActive(false); miniMap.gameObject.SetActive(false); battleClock.gameObject.SetActive(false); battleInfo.gameObject.SetActive(false); coinBar.SetActive (false); } if (battleController.isReplay) { coinBar.SetActive (false); } else { replayBar.SetActive (false); } Map map = battleController.GetMap(); miniMap.Init(battleController); for(int i=0; i (battleReadyPrefab); PopUpManager.AddToMainCanvas (gameObj); BattleReady br = gameObj.GetComponent (); br.Show (host, guest, callBack); } public void ShowMission(string mission) { GameObject gameObj = Instantiate(battleMissionPrefab); PopUpManager.AddToMainCanvas(gameObj); BattleMission bm = gameObj.GetComponent(); bm.infoTxt.text = mission; } public void ShowBattleInfo(string info, string combo="", bool isAlly=true) { battleInfo.Show(info, combo, isAlly); } public void ToggleRadioPanel() { if(radioPanel == null) { GameObject radioObj = Instantiate(radioPanelPrefab); PopUpManager.AddToMainCanvas(radioObj); radioPanel = radioObj.GetComponent(); } else { Destroy(radioPanel.gameObject); radioPanel = null; } } public void ToggleSwapPanel() { CraftSelectionPanel.Show(true); } public void HideRadioPanel() { if(radioPanel != null) { Destroy(radioPanel.gameObject); radioPanel = null; } } public void DealRadio(int userId, int craftId, int index) { Player player = battleController.GetBattleSession().GetPlayer(userId); if(player.team == battleController.GetMyPlayer().team) { string info = Language.GetStr ("Radio", "info"); info = info.Replace("%COLOR%", TeamUtil.GetTeamColorString(player.team)); info = info.Replace("%NICK%", player.nick); info = info.Replace("%INFO%", RadioItem.GetName(index)); ShowBottomTip(info); SoundManager.GetInstatnce().effectSound.Play(RadioItem.GetSound(index)); Craft craft = battleController.GetMap ().GetBattleObject (craftId) as Craft; if(craft != null) { craft.RadioAlert(); } } } public void ShowOptionPanel() { GameObject gameObj = Instantiate (OptionPanelPrefab); PopUpManager.AddToMainCanvas (gameObj); OptionPanel optionPanel = gameObj.GetComponent (); optionPanel.battleController = battleController; } public void ShowResultPanel() { Player me = battleController.GetMyPlayer (); Player opp = battleController.GetBattleSession ().GetPlayerByTeam (TeamUtil.GetOpponentTeam (me.team)); ResultPanel.Result result = ResultPanel.Result.Lose; if (battleController.winTeam == TeamUtil.Team.Yellow) result = ResultPanel.Result.Draw; else if(battleController.winTeam == me.team) result = ResultPanel.Result.Win; int crystalSpend = battleController.GetBattleSession ().myPlayer.coinSpend; ResultPanel.Show (new ResultPanel.ResultData(me, opp, result, crystalSpend)); } public void ShowMyRankPanel(int start, int target) { GameObject myRankPanelObj = Instantiate (myRankPanelPrefab); PopUpManager.AddToMainCanvas (myRankPanelObj); MyRankPanel myRankPanel = myRankPanelObj.GetComponent (); myRankPanel.startRank = start; myRankPanel.targetRank = target; } }