/// <summary> /// On va aider l'utilisateur en affichant les boutons par rapport aux actions disponibles. /// </summary> private void displayButtonsInfos() { // Lorsque le curseur est sur un item dans la partie de gauche, on va permettre à l'utilisateur de spécifier que l'item courant est tel direction. Color colorButtonCurrentItem = _colorTransparent; Color colorTextCurrentItem = _colorTransparent; if (_indItemCursor < 0 && _indItemCursor != int.MinValue) { Test2_ItemsController.Item itemAssigned = _itemController.GetItem((Test2_ItemsController.enmDirectionItem)_indItemCursor); if (itemAssigned.ID != -1) { colorButtonCurrentItem = _colorWhite; colorTextCurrentItem = Color.black; } } PanelButtons.transform.Find("btnCurrentItem").GetComponent <Image>().color = colorButtonCurrentItem; PanelButtons.transform.Find("lblCurrentItem").GetComponent <Text>().color = colorTextCurrentItem; // On affiche une info différente lorsque le joueur peut assigner directement un item. if (Input.GetButton(_inputManager.GetInputName(Test2_InputManager.enmActionController.Menu_Apply)) && _idItemSelect1 != int.MinValue && _idItemSelect2 == int.MinValue) { PanelButtons.transform.Find("lblChoose").GetComponent <Text>().text = "Assigner"; PanelButtons.transform.Find("lblSelect").GetComponent <Text>().text = "(maintenir)"; } else { PanelButtons.transform.Find("lblChoose").GetComponent <Text>().text = "Déplacer"; PanelButtons.transform.Find("lblSelect").GetComponent <Text>().text = "Sélectionner"; } }
/// <summary> /// Permet d'afficher le bon item sur le bouton /// </summary> private void updateButtonsDisplay() { Color colorBlue = new Color32(60, 120, 255, 255); Color colorRed = new Color32(255, 0, 0, 255); Color colorGreen = new Color32(0, 220, 50, 255); Color colorWhite = new Color32(255, 255, 255, 255); Color colorInactive = new Color32(165, 165, 165, 255); Color colorTransparent = new Color32(255, 255, 255, 0); Color colorBlueSemiTransparent = new Color32(60, 120, 255, 125); Color colorRedSemiTransparent = new Color32(255, 0, 0, 125); Color colorGreenSemiTransparent = new Color32(0, 220, 50, 125); Color colorWhiteSemiTransparent = new Color32(255, 255, 255, 125); Test2_ItemsController.Item currentItem = _itemsController.GetCurrentItem(); if (currentItem.ID == -1 || (currentItem.State != Test2_ItemsController.enmEtatItem.Actif && currentItem.State != Test2_ItemsController.enmEtatItem.Inactif)) { // Il n'y a pas d'item courant. ImageItemUI.transform.Find("imgItem").GetComponent <Image>().color = colorTransparent; ImageItemUI.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = colorTransparent; ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = colorTransparent; } else { ImageItemUI.transform.Find("imgItem").GetComponent <Image>().color = colorWhite; ImageItemUI.transform.Find("imgItem").GetComponent <Image>().sprite = currentItem.Image; ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().text = currentItem.NbItem.ToString(); if (currentItem.NbMaxItem <= 0) { ImageItemUI.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = colorTransparent; ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = colorTransparent; } else { ImageItemUI.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = (currentItem.State == Test2_ItemsController.enmEtatItem.Actif ? colorWhite : colorWhiteSemiTransparent); if (currentItem.NbItem == 0) { ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (currentItem.State == Test2_ItemsController.enmEtatItem.Actif ? colorRed : colorRedSemiTransparent); } else if (currentItem.NbItem == currentItem.NbMaxItem) { ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (currentItem.State == Test2_ItemsController.enmEtatItem.Actif ? colorGreen : colorGreenSemiTransparent); } else { ImageItemUI.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (currentItem.State == Test2_ItemsController.enmEtatItem.Actif ? colorBlue : colorBlueSemiTransparent); } } } }
private void Update() { _itemLeft = _itemController.GetItem(Test2_ItemsController.enmDirectionItem.Left); _itemRight = _itemController.GetItem(Test2_ItemsController.enmDirectionItem.Right); _itemTop = _itemController.GetItem(Test2_ItemsController.enmDirectionItem.Up); _itemDown = _itemController.GetItem(Test2_ItemsController.enmDirectionItem.Down); updateUISwitchItem(); if (Test2_GameManager.IsGameFreeze) { PanelSwitchItem.SetActive(false); } PanelSwitchItem.SetActive(_isPanelSwitchItemShown); manageDisplaySwitchItem(); displayDebug(); }
/// <summary> /// On va afficher les items dans la partie de gauche (items qui ont été assignés à une direction, s'il a lieu). /// </summary> private void displayItemsAssigns() { for (int ind = -1; ind >= -4; ind--) { Test2_ItemsController.enmDirectionItem direction = (Test2_ItemsController.enmDirectionItem)ind; GameObject ObjAssignedItem = null; Image imgArrow = null; switch (direction) { case Test2_ItemsController.enmDirectionItem.Left: { ObjAssignedItem = ObjItemAssignedLeft; imgArrow = ObjImageItemsAssigned.transform.Find("ArrowLeft").GetComponent <Image>(); } break; case Test2_ItemsController.enmDirectionItem.Right: { ObjAssignedItem = ObjItemAssignedRight; imgArrow = ObjImageItemsAssigned.transform.Find("ArrowRight").GetComponent <Image>(); } break; case Test2_ItemsController.enmDirectionItem.Up: { ObjAssignedItem = ObjItemAssignedTop; imgArrow = ObjImageItemsAssigned.transform.Find("ArrowTop").GetComponent <Image>(); } break; case Test2_ItemsController.enmDirectionItem.Down: { ObjAssignedItem = ObjItemAssignedDown; imgArrow = ObjImageItemsAssigned.transform.Find("ArrowDown").GetComponent <Image>(); } break; } Test2_ItemsController.Item item = _itemController.GetItem(direction); ObjAssignedItem.transform.Find("imgCursorOnIt").GetComponent <Image>().color = (_indItemCursor == ind ? _colorBlue : _colorTransparent); if (item.ID == -1) { // Il n'y a aucun item qui est associé à cette direction. On n'affiche pas d'item. ObjAssignedItem.transform.Find("imgSelectedItem").GetComponent <Image>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = _colorTransparent; } else { ObjAssignedItem.transform.Find("imgSelectedItem").GetComponent <Image>().color = ((int)direction == _idItemSelect1 || (int)direction == _idItemSelect2 ? _colorGreen : _colorTransparent); ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorWhite : _colorWhiteSemiTransparent); ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().sprite = item.Image; ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().text = item.NbItem.ToString(); if (item.NbMaxItem <= 0) { ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = _colorTransparent; } else { ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorWhite : _colorWhiteSemiTransparent); } if (item.NbMaxItem <= 0) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = _colorTransparent; } else if (item.NbItem == 0) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorRed : _colorRedSemiTransparent); } else if (item.NbItem == item.NbMaxItem) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorGreen : _colorGreenSemiTransparent); } else { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorBlue : _colorBlueSemiTransparent); } } Test2_ItemsController.enmDirectionItem directionCurrentItem = _itemController.GetDirectionCurrentItem(); if (item.ID == -1 || item.State != Test2_ItemsController.enmEtatItem.Actif) { imgArrow.color = _colorInactive; } else if (_itemController.GetDirectionCurrentItem() == direction) { imgArrow.color = _colorBlue; } else { imgArrow.color = _colorWhite; } } }
private void updateUISwitchItem() { _currentDirectionAssignedItem = _itemController.GetDirectionCurrentItem(); for (int ind = -1; ind >= -4; ind--) { Test2_ItemsController.enmDirectionItem direction = (Test2_ItemsController.enmDirectionItem)ind; GameObject ObjAssignedItem = null; Image imageArrow = null; switch (direction) { case Test2_ItemsController.enmDirectionItem.Left: { ObjAssignedItem = ImageItemLeft; imageArrow = ImageArrowLeft; } break; case Test2_ItemsController.enmDirectionItem.Right: { ObjAssignedItem = ImageItemRight; imageArrow = ImageArrowRight; } break; case Test2_ItemsController.enmDirectionItem.Up: { ObjAssignedItem = ImageItemTop; imageArrow = ImageArrowTop; } break; case Test2_ItemsController.enmDirectionItem.Down: { ObjAssignedItem = ImageItemDown; imageArrow = ImageArrowDown; } break; } Test2_ItemsController.Item item = _itemController.GetItem(direction); if (item.ID == -1) { // Il n'y a aucun item qui est associé à cette direction. On n'affiche pas d'item. ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = _colorTransparent; ObjAssignedItem.transform.Find("imgItemAssigned").GetComponent <Image>().color = _colorTransparent; } else { // Il y a un item dans cette direction. // On affiche l'image. ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorWhite : _colorWhiteSemiTransparent); ObjAssignedItem.transform.Find("imgItem").GetComponent <Image>().sprite = item.Image; ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().text = item.NbItem.ToString(); // On affiche le nombre d'items (munitions) if (item.NbMaxItem <= 0) { ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = _colorTransparent; } else { ObjAssignedItem.transform.Find("imgItem/imgBackgroundAmmo").GetComponent <Image>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorWhite : _colorWhiteSemiTransparent); } if (item.NbMaxItem <= 0) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = _colorTransparent; } else if (item.NbItem == 0) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorRed : _colorRedSemiTransparent); } else if (item.NbItem == item.NbMaxItem) { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorGreen : _colorGreenSemiTransparent); } else { ObjAssignedItem.transform.Find("imgItem/txtNbAmmo").GetComponent <Text>().color = (item.State == Test2_ItemsController.enmEtatItem.Actif ? _colorBlue : _colorBlueSemiTransparent); } ObjAssignedItem.transform.Find("imgItemAssigned").GetComponent <Image>().color = (direction == _itemController.GetDirectionCurrentItem() && item.ID != -1 ? _colorBlue : _colorTransparent); } // On affiche la couleur des flèches. if (item.ID == -1 || (item.State != Test2_ItemsController.enmEtatItem.Actif && item.State != Test2_ItemsController.enmEtatItem.Inactif)) { imageArrow.color = _colorInactive; } else { imageArrow.color = (_tempDirectionAssignedItem == direction ? _colorBlue : _colorWhite); } } }