void Awake() { interactions = new InteractionImplementer(); foreach (Transform child in transform) { if (child.CompareTag("FeedbackTransform")) { feedback = child; break; } } }
public void Init(string _IdItem, int _iNb) { idItem = _IdItem; if (GetComponent <Behaviour.Monster>() == null) { InteractionImplementer.Add(new Interaction(Harvest), 1, "Harvest", GameManager.Instance.SpriteUtils.spriteHarvest); } else { InteractionImplementer.Add(new Interaction(Harvest), 2, "Fish", GameManager.Instance.SpriteUtils.spriteHarvest); } itemContainer = new ItemContainer(GameManager.Instance.ItemDataBase.getItemById(_IdItem), quantity); if (itemContainer.Item.IngameVisual != null) { GameObject go = Instantiate(itemContainer.Item.IngameVisual, transform); if (go.transform.childCount > 0) { go.transform.localPosition = go.transform.GetChild(0).localPosition = Vector3.zero; } else { go.transform.localPosition = Vector3.zero; } go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; } else { Debug.Log("Pas de Visuel Ingame pour l'item :\"" + itemContainer.Item.ItemName + "\""); } }
void Start() { InteractionImplementer.Add(new Interaction(Pick), 0, "Pick", GameManager.Instance.SpriteUtils.spritePick); }
public void UpdateActionPanelUIQ(InteractionImplementer ic) { if (GameManager.Instance == null) { return; } if (goActionPanelQ == null) { return; } if (GameManager.Instance.ListOfSelectedKeepers.Count == 0) { return; } //Clear ClearActionPanel(); if (goShortcutKeepersPanel != null) { foreach (PawnInstance pi in GameManager.Instance.AllKeepersList) { if (pi.GetComponent <Behaviour.Keeper>() != null && pi.GetComponent <Behaviour.Mortal>().IsAlive) { pi.GetComponent <Behaviour.Keeper>().ShorcutUI.GetComponent <Button>().interactable = false; pi.GetComponent <Behaviour.Keeper>().ShorcutUI.GetComponent <Image>().raycastTarget = false; int k = 3; if (pi.Data.Behaviours[(int)BehavioursEnum.Archer] == true) { k = 2; } pi.GetComponent <Behaviour.Keeper>().ShorcutUI.transform.GetChild(k++).GetComponent <Image>().CrossFadeAlpha(0.3f, 1, true); for (int j = 0; j < pi.GetComponent <Behaviour.Keeper>().ShorcutUI.transform.GetChild(k).childCount; j++) { pi.GetComponent <Behaviour.Keeper>().ShorcutUI.transform.GetChild(k).GetChild(j).GetComponent <Image>().CrossFadeAlpha(0.3f, 1, true); } pi.GetComponent <Behaviour.Keeper>().ShorcutUI.transform.GetChild(++k).GetComponent <Image>().CrossFadeAlpha(0.3f, 1, true); if (pi.GetComponent <Behaviour.Mortal>() != null) { pi.GetComponent <Behaviour.Mortal>().ShortcutHPUI.GetComponentInChildren <Image>().CrossFadeAlpha(0.3f, 1, true); } if (pi.GetComponent <Behaviour.HungerHandler>() != null) { pi.GetComponent <Behaviour.HungerHandler>().ShortcutHungerUI.GetComponentInChildren <Image>().CrossFadeAlpha(0.3f, 1, true); } if (pi.GetComponent <Behaviour.MentalHealthHandler>() != null) { pi.GetComponent <Behaviour.MentalHealthHandler>().ShortcutMentalHealthUI.GetComponentInChildren <Image>().CrossFadeAlpha(0.3f, 1, true); } } } if (GameManager.Instance.PrisonerInstance != null && GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Escortable>() != null && GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Mortal>().IsAlive) { GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Escortable>().ShorcutUI.GetComponent <Button>().interactable = false; GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Escortable>().ShorcutUI.GetComponent <Image>().raycastTarget = false; GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Escortable>().ShorcutUI.transform.GetChild(2).GetComponent <Image>().CrossFadeAlpha(0.3f, 1, true); GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Escortable>().ShorcutUI.transform.GetChild(4).GetComponent <Image>().CrossFadeAlpha(0.3f, 1, true); if (GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Mortal>() != null) { GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.Mortal>().ShortcutHPUI.GetComponentInChildren <Image>().CrossFadeAlpha(0.3f, 1, true); } if (GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.HungerHandler>() != null) { GameManager.Instance.PrisonerInstance.GetComponent <Behaviour.HungerHandler>().ShortcutHungerUI.GetComponentInChildren <Image>().CrossFadeAlpha(0.3f, 1, true); } } } goActionPanelQ.GetComponent <RectTransform>().localPosition = Vector3.zero; // Actions for (int i = 0; i < ic.listActionContainers.Count; i++) { bool bIsForbiden = ic.listActionContainers[i].strName == "Quest" && !GameManager.Instance.GetFirstSelectedKeeper().Data.Behaviours[(int)BehavioursEnum.CanSpeak] && GameManager.Instance.GoTarget.GetComponent <Behaviour.Monster>() == null; bIsForbiden = bIsForbiden || (ic.listActionContainers[i].strName == "Talk" && !GameManager.Instance.GetFirstSelectedKeeper().Data.Behaviours[(int)BehavioursEnum.CanSpeak] && GameManager.Instance.GoTarget.GetComponent <Behaviour.Keeper>() != null); bIsForbiden = bIsForbiden || (ic.listActionContainers[i].strName == "Heal" && !GameManager.Instance.GetFirstSelectedKeeper().Data.Behaviours[(int)BehavioursEnum.Healer]); if (!bIsForbiden) { GameObject goAction = Instantiate(GameManager.Instance.PrefabUIUtils.PrefabActionUI, goActionPanelQ.transform); goAction.name = ic.listActionContainers[i].strName; goAction.GetComponent <RectTransform>().localPosition = Vector3.zero; goAction.GetComponent <RectTransform>().localRotation = Quaternion.identity; Button btn = goAction.GetComponent <Button>(); int n = i; int costActionTmp = ic.listActionContainers[i].costAction; if (ic.listActionContainers[i].strName == "Explore" && GameManager.Instance.GetFirstSelectedKeeper().Data.Behaviours[(int)BehavioursEnum.Explorateur] == true) { costActionTmp -= 1; } int nbActionRestantKeeper = GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>().ActionPoints; if (costActionTmp > nbActionRestantKeeper) { goAction.GetComponent <Image>().color = Color.grey; } if (ic.listActionContainers[i].strName == "Can't End Game") { goAction.GetComponent <Image>().color = Color.grey; } if (costActionTmp > 0) { GameObject actionPoints = Instantiate(GameManager.Instance.PrefabUIUtils.PrefabActionPoint, goAction.transform); actionPoints.transform.localScale = Vector3.one; actionPoints.transform.localPosition = Vector3.zero; actionPoints.transform.localRotation = Quaternion.identity; actionPoints.transform.GetComponentInChildren <Text>().text = costActionTmp + "/" + nbActionRestantKeeper; if (costActionTmp > nbActionRestantKeeper) { actionPoints.transform.GetComponentInChildren <Text>().color = redClaire; actionPoints.transform.GetComponentInChildren <Text>().GetComponent <Outline>().effectColor = redFonce; } else { actionPoints.transform.GetComponentInChildren <Text>().color = greenClaire; actionPoints.transform.GetComponentInChildren <Text>().GetComponent <Outline>().effectColor = greenFonce; } } int iParam = ic.listActionContainers[n].iParam; btn.onClick.AddListener(() => { ic.listActionContainers[n].action(iParam); GameManager.Instance.Ui.ClearActionPanel(); }); btn.transform.GetComponentInChildren <Image>().sprite = ic.listActionContainers[i].sprite; btn.transform.GetComponentInChildren <Image>().transform.localScale = Vector3.one; } } worldSpaceCanvas.transform.SetParent(GameManager.Instance.GoTarget.GetComponent <Interactable>().Feedback); worldSpaceCanvas.transform.localPosition = Vector3.zero; worldSpaceCanvas.GetComponent <WorldspaceCanvasCameraAdapter>().RecalculateActionCanvas(Camera.main); }