public void Escort(int _i = 0) { if (escort != null) { escort.GoListCharacterFollowing.Remove(gameObject); } if (GetComponentInParent <Tile>() != null) { transform.parent = null; } escort = GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Keeper>(); escort.GetComponent <Keeper>().GoListCharacterFollowing.Add(gameObject); Animator anim = GetComponentInChildren <Animator>(); if (anim != null) { anim.SetTrigger("escort"); } EscortParticles ep = GetComponentInChildren <EscortParticles>(); if (ep != null) { ep.EmitTowards(escort.transform); } GetComponent <NavMeshAgent>().enabled = true; ActivateIconNearEscort(); IsEscorted = true; }
public void MoralBuff(int _i = 0) { int costAction = GetComponent <Interactable>().Interactions.Get("Talk").costAction; Keeper from = GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Keeper>(); if (from.ActionPoints >= costAction) { from.ActionPoints -= costAction; int amountMoralBuff = 0; if (from.GetComponent <PawnInstance>().Data.Behaviours[(int)BehavioursEnum.Gaga] == true) { amountMoralBuff = Random.Range(Data.MinMoralBuff, Data.MaxMoralBuff); } else { amountMoralBuff = 15; if (GetComponent <LuckBased>() != null) { amountMoralBuff = GetComponent <LuckBased>().HandleLuckForTalk(); } } if (GetComponent <MentalHealthHandler>() != null) { GetComponent <MentalHealthHandler>().CurrentMentalHealth += amountMoralBuff; } else { GetComponent <PawnInstance>().AddFeedBackToQueue(GameManager.Instance.SpriteUtils.spriteMoralDebuff, 0); } } else { GameManager.Instance.Ui.ZeroActionTextAnimation(from); } }
public void Die() { if (GetComponent <Keeper>() != null || GetComponent <Monster>() != null) { Keeper keeper = GetComponent <Keeper>(); //Monster monster = GetComponent<Monster>(); Debug.Log("Blaeuurgh... *dead*"); PawnInstance pawnInstance = GetComponent <PawnInstance>(); if (GameManager.Instance.Ui.tooltipAction != null) { // TMP Remi GameManager.Instance.Ui.GoActionPanelQ.transform.parent.SetParent(GameManager.Instance.Ui.transform); GameManager.Instance.Ui.tooltipAction.SetActive(false); } // Remove reference from tiles if (keeper != null) { if (TileManager.Instance.KeepersOnTile.ContainsKey(keeper.GetComponent <PawnInstance>().CurrentTile)) { foreach (PawnInstance k in TileManager.Instance.KeepersOnTile[keeper.GetComponent <PawnInstance>().CurrentTile]) { if (k.GetComponent <MentalHealthHandler>() != null) { k.GetComponent <MentalHealthHandler>().CurrentMentalHealth -= 30; } } } TileManager.Instance.RemoveKilledKeeper(pawnInstance); GameManager.Instance.ClearListKeeperSelected(); keeper.IsSelected = false; // Drop items if (!GetComponent <Inventory>().IsEmpty()) { ItemManager.AddItemOnTheGround(pawnInstance.CurrentTile, transform, GetComponent <Inventory>().Items); } } else { TileManager.Instance.RemoveDefeatedMonster(pawnInstance); } // Death operations // TODO @Rémi, il me faut de quoi mettre a jour le shortcut panel pour afficher l'icone de mort GlowController.UnregisterObject(GetComponent <GlowObjectCmd>()); GetComponent <AnimatedPawn>().Anim.SetTrigger("triggerDeath"); // Try to fix glow bug Destroy(GetComponent <GlowObjectCmd>()); if (keeper != null) { keeper.ShowSelectedPanelUI(false); if (EventManager.OnKeeperDie != null) { EventManager.OnKeeperDie(GetComponent <Keeper>()); } // Deactivate pawn DeactivatePawn(); } else { if (GameManager.Instance.CurrentState != GameState.InBattle) { Destroy(gameObject, 0.1f); } } } else if (GetComponent <Prisoner>() != null) { Debug.Log("Ashley is dead"); } GameManager.Instance.CheckGameState(); }
public void OnPointerClick(PointerEventData eventData) { int tap = eventData.clickCount; if (tap == 2) { if (GameManager.Instance.Ui.tooltipItem != null) { GameManager.Instance.Ui.tooltipItem.SetActive(false); } // Only keeper can use items Behaviour.Keeper owner = eventData.pointerPress.GetComponentInParent <InventoryOwner>().Owner.GetComponent <Behaviour.Keeper>(); if (owner == null || owner != GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>()) { GameObject goOwner = eventData.pointerPress.GetComponentInParent <InventoryOwner>().Owner; ItemContainer[] selectedKeeperInventory = GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Items; Behaviour.Inventory ownerInventory = goOwner.GetComponent <Behaviour.Inventory>(); ItemContainer itemDragged = eventData.pointerPress.GetComponent <ItemInstance>().ItemContainer; if (InventoryManager.AddItemToInventory(selectedKeeperInventory, itemDragged)) { InventoryManager.RemoveItem(ownerInventory.Items, itemDragged); } // IF trying to merge 99 with 10 should swap or merge @rémi // else // foreach item //int quantityLeft = InventoryManager.MergeStackables(itemDragged, item); //if (quantityLeft <= 0) //{ // InventoryManager.RemoveItem(ownerInventory.Items, itemDragged); //} // Destroy inventory if it is empty for loot if (goOwner.GetComponent <LootInstance>() != null) { bool isEmpty = true; for (int i = 0; i < ownerInventory.Items.Length; i++) { if (ownerInventory.Items[i] != null) { isEmpty = false; break; } } if (isEmpty) { if (goOwner.GetComponentInChildren <Canvas>() != null) { goOwner.GetComponentInChildren <Canvas>().transform.SetParent(null); } Destroy(goOwner.gameObject); // Get the original parent Transform previous = eventData.pointerPress.GetComponentInParent <DragHandler>().transform; InventoryOwner inventaireDequi = previous.GetComponentInParent <InventoryOwner>(); Destroy(inventaireDequi.GetComponentInParent <DragHandlerInventoryPanel>().gameObject); } } goOwner.GetComponent <Behaviour.Inventory>().UpdateInventories(); GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().UpdateInventories(); //} return; } // Check if an inventory is opened Behaviour.Inventory openInventory = null; for (int i = 0; i < GameManager.Instance.Ui.Panel_Inventories.transform.childCount; i++) { if (GameManager.Instance.Ui.Panel_Inventories.transform.GetChild(i).gameObject.activeSelf) { openInventory = GameManager.Instance.Ui.Panel_Inventories.transform.GetChild(i).GetComponentInChildren <InventoryOwner>().Owner.GetComponent <Behaviour.Inventory>(); break; } } // Use the item if no inventory opened if (openInventory == null) { ii.ItemContainer.UseItem(owner.GetComponent <PawnInstance>()); if (ii.ItemContainer.Quantity <= 0) { if (GameManager.Instance.Ui.tooltipItem.activeSelf) { GameManager.Instance.Ui.tooltipItem.SetActive(false); } InventoryManager.RemoveItem(owner.GetComponent <Behaviour.Inventory>().Items, ii.ItemContainer); if (GameManager.Instance.CurrentState == GameState.InTuto) { TutoManager.MouseClicked = true; } } } // Change item owner if an inventory is opened when double clicking else { ItemContainer itemDoubleClicked = eventData.pointerPress.GetComponent <ItemInstance>().ItemContainer; if (InventoryManager.AddItemToInventory(openInventory.Items, itemDoubleClicked)) { InventoryManager.RemoveItem(GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Items, itemDoubleClicked); } openInventory.UpdateInventories(); } owner.GetComponent <Behaviour.Inventory>().UpdateInventories(); } }