private void Window_KeyUp(object sender, KeyEventArgs e) { if (monsters.SelectedItem != null) { if (e.Key == Key.Enter) { Monster m = (monsters.SelectedItem as Monster).Clone() as Monster; MonsterSelected?.Invoke(this, m); } else if (e.Key == Key.Right) { foreach (var item in (sender as AddMonsterWindow).monsters.SelectedItems) { if (string.IsNullOrEmpty((item as Monster).Name) == false) { EncounterableMonsters.Add(item as Monster); } } } else if (e.Key == Key.Left) { var selected = (sender as AddMonsterWindow).encounterableMonsters.SelectedItems; if (selected != null) { for (int i = selected.Count - 1; i >= 0; i--) { EncounterableMonsters.Remove(selected[i] as Monster); } } } } }
//自动写入选择列表,(插入空白处) int AutoAddDataToList_Selected(MonsterSelected Newdata) { for (int i = 0; i < list_selected.Count; i++) { if (list_selected[i] == null) { list_selected[i] = Newdata; return(i); } } return(-1); }
//默认选队伍,获取最近的一次战斗保存记录 public void DefalutSelect() { /*{"ID":9088,"txt":"攻击阵容"} * {"ID":9089,"txt":"防御阵容"} */ int[] last_save_pos = null; if (cur_allRolelist == list_att) { Lab_Title.text = Core.Data.stringManager.getString(9088); //获得记忆位置 last_save_pos = Core.Data.battleTeamMgr.GetBattleTeam((int)this.PVEType).m_arryAtkTeam; } else if (cur_allRolelist == list_def) { Lab_Title.text = Core.Data.stringManager.getString(9089); //获得记忆位置 last_save_pos = Core.Data.battleTeamMgr.GetBattleTeam((int)this.PVEType).m_arryDefTeam; } //初始化列表 for (int i = 0; i < list_selected.Count; i++) { list_selected[i] = null; } //初始化待选人列表 for (int i = 0; i < list_cells.Count; i++) { list_cells[i].isSelected = false; } for (int i = 0; i < this.TeamCount; i++) { if (cur_allRolelist != null && i < cur_allRolelist.Count) { //记忆下标 int key = last_save_pos[i]; if (key >= 0) { list_cells[key].isSelected = true; list_selected[i] = new MonsterSelected(key, cur_allRolelist[key]); } else { //-1:空位 list_selected[i] = null; } } } RefreshSelectedPanel(); }
public void OnBtnClick(string BtnName) { if (moveCell.gameObject.activeSelf) { //Debug.LogError("NO Click"); return; } if (BtnName.Contains("all_")) { int index = int.Parse(BtnName.Substring(4, BtnName.Length - 4)); if (!list_cells[index].isSelected) { if (CurSelectedCount < this.TeamCount) { MonsterSelected MS = new MonsterSelected(index, cur_allRolelist[index]); int insertPos = AutoAddDataToList_Selected(MS); if (insertPos > -1) { list_cells[index].isSelected = true; moveCell.ShowMonster(MS.data); PlayMoveAnimation(list_cells[index], list_SelectedRoles[insertPos], true); } } } else { if (index < list_cells.Count) { list_cells[index].isSelected = false; int key = RemoveListSelectAtListAllRollIndex(index); if (key > -1) { PlayMoveAnimation(list_cells[index], list_SelectedRoles[key], false); RefreshSelectedPanel(); } else { Debug.LogError("Not find all in select list , the all id is" + index.ToString()); } } } } else if (BtnName.Contains("sel_")) { int index = int.Parse(BtnName.Substring(4, BtnName.Length - 4)); if (index < list_selected.Count) { if (index >= 0 && index < list_selected.Count && list_selected[index] != null) { int key = list_selected[index].key; list_selected[index] = null; //list_cells[key].isSelected = false; PlayMoveAnimation(list_cells[key], list_SelectedRoles[index], false); RefreshSelectedPanel(); } } } else if (BtnName == "Btn_Close") { UIMiniPlayerController.Instance.SetActive(true); if (OnClose != null) { OnClose(); } Destroy(gameObject); if (TopMenuUI.mInstance != null) { TopMenuUI.mInstance.freshCurTeamCallback = null; } } else if (BtnName == "Btn_ATT") { if (Btn_ATK_Status != 2) { SetButtonStatus(0, 0); if (Btn_DEF_Status != 2) { cur_allRolelist = list_att; RefreshPanel(cur_allRolelist); DefalutSelect(); SetButtonStatus(1, 1); } } } else if (BtnName == "Btn_DEF") { if (Btn_DEF_Status != 2) { SetButtonStatus(1, 0); if (Btn_ATK_Status != 2) { cur_allRolelist = list_def; RefreshPanel(cur_allRolelist); DefalutSelect(); SetButtonStatus(0, 1); } } } else if (BtnName == "Btn_Fight") { List <int> result = new List <int>(); for (int i = 0; i < list_selected.Count; i++) { if (list_selected[i] != null && list_selected[i].data != null) { if (list_selected[i].data.pid < 0) { //Debug.LogError("Get realy data at pos :"+ list_selected[i].key.ToString()); list_selected[i].data = Core.Data.playerManager.RTData.curTeam.getMember(list_selected[i].key); if (list_selected[i].data.pid < 0) { SQYAlertViewMove.CreateAlertViewMove(Core.Data.stringManager.getString(17)); return; } } result.Add(list_selected[i].data.pid); } } List <int> pos = new List <int>(); for (int i = 0; i < list_selected.Count; i++) { if (list_selected[i] != null) { pos.Add(list_selected[i].key); } else { pos.Add(-1); } } int teamID = 1; if (Btn_ATK_Status == 0) { teamID = 1; Core.Data.battleTeamMgr.GetBattleTeam((int)this.PVEType).m_arryAtkTeam = pos.ToArray(); } else if (Btn_DEF_Status == 0) { teamID = 2; Core.Data.battleTeamMgr.GetBattleTeam((int)this.PVEType).m_arryDefTeam = pos.ToArray(); } CallBack_Fight(result.ToArray(), teamID); } }
void Start() { monsterScrollList = GameObject.Find("MonsterScrollList").GetComponent<UIScrollList>(); statsPanel = GameObject.Find("MonsterInfoPanel").GetComponent<UIPanel>(); magnitudeBar = statsPanel.transform.FindChild("damage").FindChild("damageBar").GetComponent<UIProgressBar>(); attackSpeedBar = statsPanel.transform.FindChild("attackSpeed").FindChild("attackSpeedBar").GetComponent<UIProgressBar>(); attackRangeBar = statsPanel.transform.FindChild("range").FindChild("rangeBar").GetComponent<UIProgressBar>(); movementSpeedBar = statsPanel.transform.FindChild("moveSpeed").FindChild("moveSpeedBar").GetComponent<UIProgressBar>(); healthBar = statsPanel.transform.FindChild("health").FindChild("healthBar").GetComponent<UIProgressBar>(); spawnRate = statsPanel.transform.FindChild("spawnRate").GetComponent<SpriteText>(); monsterName = statsPanel.transform.FindChild("name").GetComponent<SpriteText>(); monsterSprite = statsPanel.transform.FindChild("sprite").GetComponent<tk2dSprite>(); goldCost = statsPanel.transform.FindChild("goldCost").GetComponent<SpriteText>(); confirmButton = statsPanel.transform.FindChild("okayButton").GetComponent<UIButton>(); confirmButtonImage = confirmButton.GetComponent<tk2dSprite>(); monsterSaleConfirmationPanel = GameObject.Find("SellConfirmationPanel").GetComponent<UIPanel>(); monsterSaleConfirmButton = monsterSaleConfirmationPanel.transform.FindChild("okayButton").GetComponent<UIButton>(); monsterSaleCancelButton = monsterSaleConfirmationPanel.transform.FindChild("cancelButton").GetComponent<UIButton>(); monsterSaleConfirmButton.scriptWithMethodToInvoke = this; monsterSaleCancelButton.scriptWithMethodToInvoke = this; monsterSaleConfirmButton.methodToInvoke = "MonsterSaleConfirmed"; monsterSaleCancelButton.methodToInvoke = "MonsterSaleCancelled"; scrollListCamera = monsterScrollList.renderCamera; levelManager = GameObject.Find("LevelManager").GetComponent<LevelManager>(); listPanel = GameObject.Find("MonsterSelectionPanel").GetComponent<UIPanel>(); Transform attackEffectParent = GameObject.Find("attackEffectIcons").transform.FindChild("icons"); actionEffectIcons = attackEffectParent.GetComponentsInChildren<tk2dSprite>(); if (playerStatusManager == null) playerStatusManager = GameObject.Find("PlayerStatusManager").GetComponent<PlayerStatusManager>(); entityFactory = EntityFactory.GetInstance(); monsterSelectedCallback = null; LoadMonsterScrollPanel(); }
public void LaunchSellMonsterGUI(MonsterSpawner spawner, SellMonsterResults monsterSoldCallback) { DismissAll(); if (monsterSelectedCallback != null) { monsterSelectedCallback(null); monsterSelectedCallback = null; } //If we already have an active callback set then return false to that caller since it's monster wasn't sold. if (this.monsterSoldCallback != null) this.monsterSoldCallback(false); this.monsterSoldCallback = monsterSoldCallback; monsterSaleConfirmationPanel.BringIn(); }
public void DismissListPanel() { listPanel.Dismiss(); //We'll want to clean this up just to be safe. Let the subscribers know that //no monster was chosen. if (monsterSelectedCallback != null) { monsterSelectedCallback(null); monsterSelectedCallback = null; } }
public void OnMonsterCancelButtonPressed() { Debug.Log("Monster choice cancelled"); if (monsterSelectedCallback != null) { monsterSelectedCallback(null); monsterSelectedCallback = null; } listPanel.BringIn(); statsPanel.Dismiss(); monsterSelectionGUIOpen = false; }
public void OnMonsterAcceptButtonPressed() { Debug.Log("Accepted!!"); if (monsterSelectedCallback != null) { monsterSelectedCallback(monsterInfo); monsterSelectedCallback = null; } listPanel.Dismiss(); statsPanel.Dismiss(); monsterSelectionGUIOpen = false; }
/// <summary> /// Launches the monster GUI and returns the chosen monster to the last caller of this /// method at any given moment in time. /// </summary> /// <returns> /// The chosen monster. /// </returns> /// <param name='spawner'> /// The MonsterSpawner requesting that the user be allowed to choose a monster to spawn. /// </param> public void LaunchMonsterGUI(MonsterSpawner spawner, MonsterSelected monsterChosenCallback) { //If we already have an active spawner set then deactivate it if (this.monsterSelectedCallback != null) this.monsterSelectedCallback(null); this.monsterSelectedCallback = monsterChosenCallback; if (!monsterSelectionGUIOpen) { StartCoroutine(coLaunchGUI(spawner)); monsterSelectionGUIOpen = true; } }