void OnTriggerEnter(Collider col) { if (col.GetComponent <ThirdPersonVehicleInteraction> ()) { ThirdPersonInventory.staticInv.AddItemAmmo(bulletID, amount); if (glow) { GlowController.UnregisterObject(glow); } Destroy(gameObject); //gameObject.SetActive (false); } }
public void UpdateSpotLightIntensity() { fLerp += Time.unscaledDeltaTime * 0.8f; if (fLerp > 1) { fLerp = 1; } if (isBoxOpen) { spotLight.range = Mathf.Lerp(12.0f, 13.0f, fLerp); spotLight.spotAngle = Mathf.Lerp(120.0f, 130.0f, fLerp); spotLight.transform.localPosition = Vector3.Lerp(SpotLightTransformPos, newSpotLightTransform.localPosition, fLerp); spotLight.transform.localRotation = Quaternion.Lerp(SpotLightTransformRot, newSpotLightTransform.localRotation, fLerp); } else { spotLight.range = Mathf.Lerp(13.0f, 12.0f, fLerp); spotLight.spotAngle = Mathf.Lerp(130.0f, 120.0f, fLerp); spotLight.transform.localPosition = Vector3.Lerp(newSpotLightTransform.localPosition, SpotLightTransformPos, fLerp); spotLight.transform.localRotation = Quaternion.Lerp(newSpotLightTransform.localRotation, SpotLightTransformRot, fLerp); } if (fLerp == 1) { if (isBoxOpen) { menuUi.whereTheCardInfoiS.Clear(); menuUi.whereTheCardInfoiSrotation.Clear(); for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { menuUi.whereTheCardInfoiS.Add(menuManager.GoCardsInfo[i].transform.position); menuUi.whereTheCardInfoiSrotation.Add(menuManager.GoCardsInfo[i].transform.rotation); menuManager.GoCardsInfo[i].transform.SetParent(null); GlowController.UnregisterObject(menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>()); } menuUi.startButtonImg.gameObject.SetActive(true); boxIsReady = true; for (int i = 0; i < GameManager.Instance.AllKeepersList.Count; i++) { GlowController.UnregisterObject(GameManager.Instance.AllKeepersList[i].GetComponent <GlowObjectCmd>()); } } spotlightneedUpdate = false; fLerp = 0; } }
public void BoxControls() { if (menuManager.DuckhavebringThebox && !spotlightneedUpdate && !menuUi.ACardIsShown && !menuUi.ACardInfoIsShown && (menuManager.ListeSelectedKeepers.Count == 0 && menuManager.CardLevelSelected == -1 && menuManager.DeckOfCardsSelected == string.Empty)) { if (menuController.OncePressR) { boxLock.GetComponent <GlowObjectCmd>().ActivateBlinkBehaviour(false); } //if (isBoxOpen) //{ // //foreach (Opener o in GameObject.FindObjectsOfType<Opener>()) // //{ // // o.Fold(); // //} //} IsBoxOpen = !IsBoxOpen; animatorBox.SetBool("bOpen", isBoxOpen); animatorCam.SetBool("bOpen", isBoxOpen); spotlightneedUpdate = true; //spotLight.enabled = !isBoxOpen; //directionnalLight.enabled = isBoxOpen; // Force reset go cards info if (isBoxOpen == false) { for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { boxIsReady = false; menuUi.hasReachStepOneInfo = false; menuUi.hasReachStepTwoInfo = false; menuUi.indexInfo = 0; menuUi.cardInfofLerp = 0; menuUi.cardsInfoAreReady = false; menuManager.GoCardsInfo[i].transform.localPosition = menuUi.levelCardInfoKeyPoses[i][0].v3Pos + new Vector3(0, i * 0.02f, 0); menuManager.GoCardsInfo[i].transform.localRotation = menuUi.levelCardInfoKeyPoses[i][0].quatRot; GlowController.UnregisterObject(menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>()); } } //boxLock.GetComponent<GlowObjectCmd>().ActivateBlinkBehaviour(!isBoxOpen); UpdateLockAspect(); } }
private void OnDestroy() { GlowController.UnregisterObject(this); }
public static void PostBattleCommonProcess() { for (int i = 0; i < currentBattleKeepers.Length; i++) { currentBattleKeepers[i].GetComponent <Fighter>().ResetValuesAfterBattle(); if (GameManager.Instance.ArcherInstance != null && currentBattleKeepers[i].Data.Behaviours[(int)BehavioursEnum.Archer]) { if (archerPreviousTile != null) { GameManager.Instance.ArcherInstance.CurrentTile = archerPreviousTile; currentBattleKeepers[i].CurrentTile = archerPreviousTile; } } currentBattleKeepers[i].GetComponent <AnimatedPawn>().StartMoveFromBattlePositionAnimation(); } if (isPrisonerOnTile) { GameManager.Instance.PrisonerInstance.GetComponent <AnimatedPawn>().StartMoveFromBattlePositionAnimation(); GameManager.Instance.PrisonerInstance.GetComponent <Fighter>().ResetValuesAfterBattle(); } for (int i = 0; i < currentBattleMonsters.Length; i++) { // TODO: test death cases if (currentBattleMonsters[i] != null) { if (currentBattleMonsters[i].GetComponent <Mortal>().CurrentHp > 0) { currentBattleMonsters[i].GetComponent <AnimatedPawn>().StartMoveFromBattlePositionAnimation(); currentBattleMonsters[i].GetComponent <Fighter>().HasRecentlyBattled = true; currentBattleMonsters[i].transform.GetChild(1).gameObject.SetActive(true); GlowController.UnregisterObject(currentBattleMonsters[i].GetComponent <GlowObjectCmd>()); currentBattleMonsters[i].GetComponent <Fighter>().EffectiveBoeufs.Clear(); currentBattleMonsters[i].GetComponent <Fighter>().UpdateActiveBoeufs(); currentBattleMonsters[i].GetComponentInChildren <BuffFeedback>().ShowBuffs(false); if (currentBattleMonsters[i].GetComponent <QuestDealerFeedbackUpdater>() != null) { currentBattleMonsters[i].GetComponent <QuestDealerFeedbackUpdater>().feedbackContainer.SetActive(true); } } else { GameObject.Destroy(currentBattleMonsters[i].gameObject, 0.5f); } } } GameManager.Instance.GetBattleUI.gameObject.SetActive(false); GameManager.Instance.ClearListKeeperSelected(); for (int i = 0; i < currentBattleKeepers.Length; i++) { if (currentBattleKeepers[i].GetComponent <Mortal>().CurrentHp > 0) { GameManager.Instance.AddKeeperToSelectedList(currentBattleKeepers[i]); currentBattleKeepers[i].GetComponent <Keeper>().IsSelected = true; currentBattleKeepers[i].GetComponent <Fighter>().EffectiveBoeufs.Clear(); currentBattleKeepers[i].GetComponent <Fighter>().UpdateActiveBoeufs(); currentBattleKeepers[i].GetComponentInChildren <BuffFeedback>().ShowBuffs(false); } } if (isPrisonerOnTile) { GameManager.Instance.PrisonerInstance.GetComponent <Fighter>().EffectiveBoeufs.Clear(); GameManager.Instance.PrisonerInstance.GetComponent <Fighter>().UpdateActiveBoeufs(); GameManager.Instance.PrisonerInstance.GetComponentInChildren <BuffFeedback>().ShowBuffs(false); } ItemManager.AddItemOnTheGround(GameManager.Instance.ActiveTile, GameManager.Instance.ActiveTile.transform, currentBattleLoot.ToArray()); ResetBattleHandler(); }
public void OnEnable() { GlowController.UnregisterObject(GetComponent <GlowObjectCmd>()); }
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 UpdateCardLevelSelectedPosition() { if (carLevelSelectedfLerp == 0 && !levelCardSelected.GetComponent <CardLevel>().IsSelected&& indexCardSelected == 0) { GlowController.UnregisterObject(levelCardSelected.GetComponent <GlowObjectCmd>()); for (int i = 0; i < menuManager.GoCardChildren.Count; i++) { for (int j = 0; j < menuManager.GoCardChildren[i].Count; j++) { menuManager.GoCardChildren[i][j].SetActive(false); menuManager.GoCardChildren[i][j].transform.localPosition = Vector3.zero; } } } carLevelSelectedfLerp += Time.unscaledDeltaTime * 4f; if (carLevelSelectedfLerp > 1) { carLevelSelectedfLerp = 1; } if (levelCardSelected.GetComponent <CardLevel>().IsSelected) { Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().bloomIntensity = 0.35f + (carLevelSelectedfLerp * 0.65f); Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().sepBlurSpread = 0.1f + (carLevelSelectedfLerp * 1.4f); levelCardSelected.transform.position = Vector3.Lerp(cameraWhere.position, levelCardSelectedPosition.position, carLevelSelectedfLerp); levelCardSelected.transform.rotation = Quaternion.Lerp(cameraWhere.rotation, levelCardSelectedPosition.rotation, carLevelSelectedfLerp); } else { if (indexCardSelected == 2) { levelCardSelected.transform.position = Vector3.Lerp(levelCardKeyPoses[0][1].v3Pos, levelCardKeyPoses[0][0].v3Pos, carLevelSelectedfLerp); levelCardSelected.transform.rotation = Quaternion.Lerp(levelCardKeyPoses[0][1].quatRot, levelCardKeyPoses[0][0].quatRot, carLevelSelectedfLerp); } else if (indexCardSelected == 1) { levelCardSelected.transform.position = Vector3.Lerp(levelCardSelectedPosition2.position, levelCardKeyPoses[0][1].v3Pos, carLevelSelectedfLerp); levelCardSelected.transform.rotation = Quaternion.Lerp(levelCardSelectedPosition2.rotation, levelCardKeyPoses[0][1].quatRot, carLevelSelectedfLerp); } else { levelCardSelected.transform.position = Vector3.Lerp(levelCardSelectedPosition.position, levelCardSelectedPosition2.position, carLevelSelectedfLerp); levelCardSelected.transform.rotation = Quaternion.Lerp(levelCardSelectedPosition.rotation, levelCardSelectedPosition2.rotation, carLevelSelectedfLerp); } } if (carLevelSelectedfLerp == 1) { if (levelCardSelected.GetComponent <CardLevel>().IsSelected) { for (int i = 0; i < menuManager.GoCardChildren.Count; i++) { for (int j = 0; j < menuManager.GoCardChildren[i].Count; j++) { if (levelCardSelected == menuManager.GoCardChildren[i][j].GetComponentInParent <CardLevel>().gameObject) { menuManager.GoCardChildren[i][j].SetActive(true); menuManager.GoCardChildren[i][j].transform.localPosition = new Vector3(0.1f, -0.01f, 0.0f) * (j + 1); } else { menuManager.GoCardChildren[i][j].SetActive(false); menuManager.GoCardChildren[i][j].transform.localPosition = Vector3.zero; } } } for (int i = 0; i < GameManager.Instance.AllKeepersList.Count; i++) { GlowController.RegisterObject(GameManager.Instance.AllKeepersList[i].GetComponent <GlowObjectCmd>()); } for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { GlowController.RegisterObject(menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>()); } } else { if (indexCardSelected == 2) { levelCardSelected = null; for (int i = 0; i < GameManager.Instance.AllKeepersList.Count; i++) { GlowController.UnregisterObject(GameManager.Instance.AllKeepersList[i].GetComponent <GlowObjectCmd>()); } for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { GlowController.UnregisterObject(menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>()); } } } //box.UpdateLockAspect(); if (levelCardSelected != null && levelCardSelected.GetComponent <CardLevel>().IsSelected) { aCardLevelSelectedIsMoving = false; } else if (indexCardSelected != 2) { indexCardSelected++; } else if (indexCardSelected == 2) { aCardLevelSelectedIsMoving = false; } carLevelSelectedfLerp = 0; if (!initCardInfo) { initCardInfo = true; } } }
public void UpdateCardInfoShowingPositions() { if (cardInfoShownfLerp == 0) { for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { if (menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().NeedToBeShown) { GlowController.RegisterObject((menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>())); } else { GlowController.UnregisterObject((menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>())); } } menuManager.SetActiveChatBoxes(false); } cardInfoShownfLerp += Time.unscaledDeltaTime * 10f; if (cardInfoShownfLerp > 1) { cardInfoShownfLerp = 1; } for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { if (menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().NeedToBeShown) { Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().bloomIntensity = 1f - (cardInfoShownfLerp * 0.65f); Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().sepBlurSpread = 1.5f - (cardInfoShownfLerp * 1.4f); menuManager.GoCardsInfo[i].transform.position = Vector3.Lerp(levelCardInfoKeyPoses[i][levelCardInfoKeyPoses[i].Count - 1].v3Pos, cameraWhere.transform.position + new Vector3(0, 0.5f, -0.2f), cardInfoShownfLerp); menuManager.GoCardsInfo[i].transform.rotation = Quaternion.Lerp(levelCardInfoKeyPoses[i][levelCardInfoKeyPoses[i].Count - 1].quatRot, cameraWhere.transform.rotation, cardInfoShownfLerp); } else if (ACardInfoIsShown) { if (menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().IsShown) { Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().bloomIntensity = 0.35f + (cardInfoShownfLerp * 0.65f); Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().sepBlurSpread = 0.1f + (cardInfoShownfLerp * 1.4f); menuManager.GoCardsInfo[i].transform.position = Vector3.Lerp(cameraWhere.transform.position + new Vector3(0, 0.5f, -0.2f), levelCardInfoKeyPoses[i][levelCardInfoKeyPoses[i].Count - 1].v3Pos, cardInfoShownfLerp); menuManager.GoCardsInfo[i].transform.rotation = Quaternion.Lerp(cameraWhere.transform.rotation, levelCardInfoKeyPoses[i][levelCardInfoKeyPoses[i].Count - 1].quatRot, cardInfoShownfLerp); } } } if (cardInfoShownfLerp == 1) { isACardInfoMovingForShowing = false; cardInfoShownfLerp = 0; bool isACardShow = false; for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { if (menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().NeedToBeShown) { ACardInfoIsShown = true; isACardShow = true; // menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().NeedToBeShown = false; } else { //GlowController.UnregisterObject((menuManager.GoCardsInfo[i].GetComponentInChildren<GlowObjectCmd>())); menuManager.GoCardsInfo[i].GetComponentInChildren <Displayer>().IsShown = false; } } if (!isACardShow) { for (int i = 0; i < menuManager.GoCardsInfo.Count; i++) { GlowController.RegisterObject((menuManager.GoCardsInfo[i].GetComponentInChildren <GlowObjectCmd>())); menuManager.SetActiveChatBoxes(true); } ACardInfoIsShown = false; } box.UpdateLockAspect(); } }
void UpdateCardLevelPositions() { carLevelfLerp += Time.unscaledDeltaTime * 3.5f; if (carLevelfLerp > 1) { carLevelfLerp = 1; } if (carLevelfLerp > (!menuManager.GoDeck.GetComponent <Deck>().IsOpen ? 0.4 : 0.4f) && !hasReachStepOne) { whereTheCardiS.Clear(); whereTheCardiSrotation.Clear(); for (int i = 0; i < menuManager.GoCardsLevels.Count; i++) { whereTheCardiS.Add(menuManager.GoCardsLevels[i].transform.position); whereTheCardiSrotation.Add(menuManager.GoCardsLevels[i].transform.rotation); } hasReachStepOne = true; carLevelfLerp = 0; index = 1; } if (carLevelfLerp > (!menuManager.GoDeck.GetComponent <Deck>().IsOpen? 0.5 : 0.95f) && !hasReachStepTwo && hasReachStepOne) { whereTheCardiS.Clear(); whereTheCardiSrotation.Clear(); for (int i = 0; i < menuManager.GoCardsLevels.Count; i++) { whereTheCardiS.Add(menuManager.GoCardsLevels[i].transform.localPosition); whereTheCardiSrotation.Add(menuManager.GoCardsLevels[i].transform.localRotation); } carLevelfLerp = 0; hasReachStepTwo = true; index = 2; if (menuManager.GoDeck.GetComponent <Deck>().IsOpen) { for (int i = 0; i < menuManager.GoCardsLevels.Count; i++) { GlowController.UnregisterObject(menuManager.GoCardsLevels[i].GetComponent <GlowObjectCmd>()); } menuManager.SetActiveChatBoxes(true); } else { for (int i = 0; i < menuManager.GoCardsLevels.Count; i++) { GlowController.RegisterObject(menuManager.GoCardsLevels[i].GetComponent <GlowObjectCmd>()); } menuManager.SetActiveChatBoxes(false); } } for (int i = 0; i < menuManager.GoCardsLevels.Count; i++) { if (!menuManager.GoDeck.GetComponent <Deck>().IsOpen) { if (menuManager.GoCardsLevels[i] != LevelCardSelected) { if (index == 2) { Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().bloomIntensity = 1f - (carLevelfLerp * 0.65f); Camera.main.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>().sepBlurSpread = 1.5f - (carLevelfLerp * 1.4f); } menuManager.GoCardsLevels[i].transform.position = Vector3.Lerp(whereTheCardiS[i], levelCardKeyPoses[i][index].v3Pos, carLevelfLerp); menuManager.GoCardsLevels[i].transform.rotation = Quaternion.Lerp(whereTheCardiSrotation[i], levelCardKeyPoses[i][index].quatRot, carLevelfLerp); } } else { if (menuManager.GoCardsLevels[i] != LevelCardSelected && menuManager.GoCardsLevels[i] != previousCardSelected) { menuManager.GoCardsLevels[i].transform.position = Vector3.Lerp(whereTheCardiS[i], levelCardKeyPoses[i][levelCardKeyPoses[i].Count - (index) - 1].v3Pos, carLevelfLerp); menuManager.GoCardsLevels[i].transform.rotation = Quaternion.Lerp(whereTheCardiSrotation[i], levelCardKeyPoses[i][levelCardKeyPoses[i].Count - (index) - 1].quatRot, carLevelfLerp); } else { if (previousCardSelected != null && menuManager.GoCardsLevels[i] == previousCardSelected && previousCardSelected.GetComponent <CardLevel>().IsSelected) { if (hasReachStepTwo) { previousCardSelected.transform.position = Vector3.Lerp(levelCardKeyPoses[0][1].v3Pos, levelCardKeyPoses[0][0].v3Pos, carLevelfLerp); previousCardSelected.transform.rotation = Quaternion.Lerp(levelCardKeyPoses[0][1].quatRot, levelCardKeyPoses[0][0].quatRot, carLevelfLerp); } else if (hasReachStepOne) { previousCardSelected.transform.position = Vector3.Lerp(levelCardSelectedPosition2.position, levelCardKeyPoses[0][1].v3Pos, carLevelfLerp); previousCardSelected.transform.rotation = Quaternion.Lerp(levelCardSelectedPosition2.rotation, levelCardKeyPoses[0][1].quatRot, carLevelfLerp); } else { previousCardSelected.transform.position = Vector3.Lerp(levelCardSelectedPosition.position, levelCardSelectedPosition2.position, carLevelfLerp); previousCardSelected.transform.rotation = Quaternion.Lerp(levelCardSelectedPosition.rotation, levelCardSelectedPosition2.rotation, carLevelfLerp); } } } } } if (carLevelfLerp == 1) { menuManager.GoDeck.GetComponent <Deck>().IsOpen = !menuManager.GoDeck.GetComponent <Deck>().IsOpen; aCardIsShown = !aCardIsShown; box.UpdateLockAspect(); isACardMoving = false; carLevelfLerp = 0; index = 1; hasReachStepOne = false; hasReachStepTwo = false; } }
// Use this for initialization void Start() { GlowController.UnregisterObject(menuManager.GetComponent <BoxOpener>().boxLock.GetComponent <GlowObjectCmd>()); menuManager.GetComponent <BoxOpener>().boxLock.GetComponent <GlowObjectCmd>().UpdateColor(false); }
public void Harvest(int _i = 0) { int costAction = 0; if (GetComponent <Behaviour.Monster>() == null) { costAction = InteractionImplementer.Get("Harvest").costAction; } else { costAction = InteractionImplementer.Get("Fish").costAction; } if (GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>().ActionPoints >= costAction) { int previousQuantity = itemContainer.Quantity; if (GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.LuckBased>() != null) { GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.LuckBased>().HandleLuckForHarvest(itemContainer); } if (GameManager.Instance.GetFirstSelectedKeeper().Data.Behaviours[(int)BehavioursEnum.Harvester]) { itemContainer.Quantity = (int)(itemContainer.Quantity * 1.25f) + 1; } bool isNoLeftOver = InventoryManager.AddItemToInventory(GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Items, itemContainer); if (isNoLeftOver) { // TODO : bug here miscellenous interactions with feedback action UI if (GetComponent <Behaviour.Monster>() != null) { TileManager.Instance.RemoveDefeatedMonster(GetComponent <PawnInstance>()); GameManager.Instance.Ui.GoActionPanelQ.transform.parent.SetParent(null); Destroy(this.gameObject); } else { Destroy(this); GlowController.UnregisterObject(GlowCmd); if (this.transform.childCount > 0) { // Si sa plante ici appeller rémi DestroyImmediate(this.transform.GetChild(transform.childCount - 1).gameObject); } } GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>().ActionPoints -= (short)costAction; } GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().UpdateInventories(); if (!isNoLeftOver && previousQuantity == itemContainer.Quantity) { for (int i = 0; i < GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Data.NbSlot; i++) { GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().SelectedInventoryPanel.transform.GetChild(i).GetComponent <Image>().color = Color.red; } StartCoroutine(InventoryNormalState()); } } else { GameManager.Instance.Ui.ZeroActionTextAnimation(GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>()); } }
private void SwitchToBattleStateProcess() { // Pause keepers foreach (PawnInstance pi in allKeepersList) { bool mustBeDisabled = false; for (int i = 0; i < currentFighters.Length && i < 3; i++) { if (pi == currentFighters[i]) { mustBeDisabled = true; } } if (mustBeDisabled) { pi.GetComponent <NavMeshAgent>().enabled = false; } else { NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>(); if (currentAgent != null && currentAgent.isActiveAndEnabled) { currentAgent.Stop(); pausedAgents.Add(currentAgent); pi.transform.GetChild(0).gameObject.SetActive(false); disabledModels.Add(pi.transform.GetChild(0).gameObject); if (pi.GetComponent <GlowObjectCmd>() != null) { GlowController.UnregisterObject(pi.GetComponent <GlowObjectCmd>()); unregisteredGlows.Add(pi.GetComponent <GlowObjectCmd>()); } } } pi.GetComponent <Keeper>().ShowSelectedPanelUI(false); ui.ClearActionPanel(); ui.HideInventoryPanels(); } // Pause NPCs // If needed, we should register all PNJ on tiles in TileManager so we can handle AI behaviours when the game paused // For now we'll only deal with the prisoner if (currentFighters[currentFighters.Length - 1].GetComponent <Prisoner>() != null) { NavMeshAgent prisonerAgent = currentFighters[currentFighters.Length - 1].GetComponent <NavMeshAgent>(); if (prisonerAgent != null && prisonerAgent.isActiveAndEnabled) { prisonerAgent.enabled = false; } } else { if (prisonerInstance != null) { NavMeshAgent prisonerAgent = prisonerInstance.GetComponent <NavMeshAgent>(); if (prisonerAgent != null && prisonerAgent.isActiveAndEnabled) { prisonerAgent.Stop(); pausedAgents.Add(prisonerAgent); } } } // Pause monsters foreach (Tile tile in tileManagerReference.MonstersOnTile.Keys) { if (tile != cameraManagerReference.ActiveTile) { List <PawnInstance> monsterList = tileManagerReference.MonstersOnTile[tile]; foreach (PawnInstance pi in monsterList) { NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>(); if (currentAgent != null && currentAgent.isActiveAndEnabled) { currentAgent.Stop(); pausedAgents.Add(currentAgent); } } } else { List <PawnInstance> monsterList = tileManagerReference.MonstersOnTile[tile]; foreach (PawnInstance pi in monsterList) { NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>(); if (currentAgent != null) { pi.GetComponent <AnimatedPawn>().WasAgentActiveBeforeBattle = currentAgent.isActiveAndEnabled; if (currentAgent.isActiveAndEnabled) { currentAgent.enabled = false; } } if (pi.GetComponent <GlowObjectCmd>() != null) { GlowController.RegisterObject(pi.GetComponent <GlowObjectCmd>()); } if (pi.GetComponentInChildren <AggroBehaviour>() != null) { pi.GetComponentInChildren <AggroBehaviour>().gameObject.SetActive(false); } } } } // Mask tile portals Transform tilePortals = currentFighters[0].CurrentTile.transform.GetChild(0).GetChild((int)TilePrefabChildren.PortalTriggers); for (int i = 0; i < tilePortals.childCount; i++) { if (tilePortals.GetChild(i).gameObject.activeSelf) { tilePortalsDisabled.Add(tilePortals.GetChild(i).gameObject); tilePortals.GetChild(i).gameObject.SetActive(false); } } // Mask quest reminder button gameScreens.transform.GetChild(0).GetChild((int)IngameScreensEnum.QuestReminderButton).gameObject.SetActive(false); Transform tileModel = ActiveTile.transform.GetChild(0).GetChild((int)TilePrefabChildren.Model); for (int i = 0; i < tileModel.childCount; i++) { if (tileModel.GetChild(i).name.Equals("Center")) { tileModel.GetChild(i).gameObject.SetActive(false); disabledModels.Add(tileModel.GetChild(i).gameObject); } } PawnInstance[] toDisable = ActiveTile.GetComponentsInChildren <PawnInstance>(); foreach (PawnInstance pi in toDisable) { if (pi.GetComponent <Monster>() == null) { pi.gameObject.SetActive(false); disabledModels.Add(pi.gameObject); } } LootInstance[] lootToDisable = ActiveTile.GetComponentsInChildren <LootInstance>(); foreach (LootInstance li in lootToDisable) { li.gameObject.SetActive(false); disabledModels.Add(li.gameObject); } // Make escortable disappear if (TileManager.Instance.EscortablesOnTile.ContainsKey(ActiveTile)) { foreach (PawnInstance pi in TileManager.Instance.EscortablesOnTile[ActiveTile]) { pi.gameObject.SetActive(false); disabledModels.Add(pi.gameObject); } } // Hide item instance for (int i = 1; i < ActiveTile.transform.childCount; i++) { ItemInstance curItem = ActiveTile.transform.GetChild(i).GetComponentInChildren <ItemInstance>(); if (curItem != null) { curItem.transform.parent.gameObject.SetActive(false); disabledModels.Add(curItem.transform.parent.gameObject); } } Ui.GoActionPanelQ.transform.parent.SetParent(Ui.transform); }