void BecomeAKeeper()
    {
        toSubscribe.OnQuestComplete -= BecomeAKeeper;
        PawnInstance pawn = GameManager.Instance.PawnDataBase.CreatePawn(idKeeper, transform.position, transform.rotation, null).GetComponent <PawnInstance>();

        GameManager.Instance.PersistenceLoader.SetPawnUnlocked(idKeeper, true);
        if (GameManager.Instance.PersistenceLoader.Pd.dicPersistencePawns.ContainsKey(idKeeper))
        {
            GameManager.Instance.PersistenceLoader.Pd.dicPersistencePawns[idKeeper] = true;
        }
        GameManager.Instance.PawnDataBase.InitPawn(pawn);
        GameManager.Instance.AllKeepersList.Add(pawn);
        GameManager.Instance.CharacterInitializer.InitCharacterUI(pawn);
        TileManager.Instance.AddKeeperOnTile(GetComponentInParent <Tile>(), pawn);
        GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>().IsSelected = false;
        GameManager.Instance.ClearListKeeperSelected();
        pawn.GetComponent <Behaviour.Keeper>().IsSelected = true;
        GameManager.Instance.AddKeeperToSelectedList(pawn);
        GlowController.RegisterObject(pawn.GetComponent <GlowObjectCmd>());
        pawn.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = true;
        Transform feed = GetComponent <Interactable>().Feedback;

        feed.GetChild(feed.childCount - 1).SetParent(GameManager.Instance.Ui.transform);
        GameManager.Instance.PersistenceLoader.SetPawnUnlocked(idKeeper, true);
        DestroyImmediate(gameObject);
    }
Example #2
0
    private void MoveWithoutConfirmation(int _i)

    {
        if (GameManager.Instance.ListOfSelectedKeepers.Count > 0)

        {
            PawnInstance toMove = GameManager.Instance.GetFirstSelectedKeeper();



            TileManager.Instance.MoveKeeper(toMove, toMove.CurrentTile, (Direction)_i, actionCostMove);



            GameManager.Instance.Ui.HideInventoryPanels();



            if (toMove.GetComponent <Fighter>() != null)
            {
                toMove.GetComponent <Fighter>().IsTargetableByMonster = false;
            }
        }

        else

        {
            Debug.Log("No keeper selected");
        }
    }
Example #3
0
    public void AddEscortableOnTile(PawnInstance escortable)
    {
        Tile tile = escortable.GetComponentInParent <Tile>();

        if (escortable.GetComponent <Behaviour.Escortable>() == null)
        {
            Debug.Log("Can't add escortable to tile, missing component Escortable.");
            return;
        }
        if (escortable.GetComponent <Behaviour.Prisoner>() != null)
        {
            Debug.Log("Can't add an escortable with a Prisoner component.");
            return;
        }

        if (tile == null)
        {
            Debug.Log("Can't add escortable to tile, no Tile component found in parent.");
            return;
        }

        if (escortablesOnTile.ContainsKey(tile))
        {
            escortablesOnTile[tile].Add(escortable);
        }
        else
        {
            List <PawnInstance> newList = new List <PawnInstance>();
            newList.Add(escortable);
            escortablesOnTile.Add(tile, newList);
        }
        escortable.CurrentTile = tile;
    }
Example #4
0
    public void AddEscortableOnTile(Tile tile, PawnInstance escortable)
    {
        if (tile == null)
        {
            Debug.Log("Can't add escortable to tile, tile given is null");
            return;
        }

        if (escortable.GetComponent <Behaviour.Escortable>() == null)
        {
            Debug.Log("Can't add escortable to tile, missing component Escortable.");
            return;
        }
        if (escortable.GetComponent <Behaviour.Prisoner>() != null)
        {
            Debug.Log("Can't add an escortable with a Prisoner component.");
            return;
        }
        if (escortablesOnTile.ContainsKey(tile))
        {
            escortablesOnTile[tile].Add(escortable);
        }
        else
        {
            List <PawnInstance> newList = new List <PawnInstance>();
            newList.Add(escortable);
            escortablesOnTile.Add(tile, newList);
        }
        escortable.CurrentTile = tile;
        if (EventManager.OnPawnMove != null)
        {
            EventManager.OnPawnMove(escortable, tile);
        }
    }
Example #5
0
        public void GoToKeeper(int direction)
        {
            GameManager.Instance.ClearListKeeperSelected();
            int currentKeeperSelectedIndex = GameManager.Instance.AllKeepersList.FindIndex(x => x == instance);

            PawnInstance nextKeeper   = null;
            int          nbIterations = 1;

            while (nextKeeper == null && nbIterations <= GameManager.Instance.AllKeepersList.Count)
            {
                if ((currentKeeperSelectedIndex + direction * nbIterations) % GameManager.Instance.AllKeepersList.Count < 0)
                {
                    nextKeeper = GameManager.Instance.AllKeepersList[GameManager.Instance.AllKeepersList.Count - 1];
                }
                else
                {
                    nextKeeper = GameManager.Instance.AllKeepersList[(currentKeeperSelectedIndex + direction * nbIterations) % GameManager.Instance.AllKeepersList.Count];
                }

                if (!nextKeeper.GetComponent <Behaviour.Mortal>().IsAlive)
                {
                    nextKeeper = null;
                }
                nbIterations++;
            }

            GameManager.Instance.ListOfSelectedKeepers.Add(nextKeeper);
            nextKeeper.GetComponent <Keeper>().IsSelected = true;
        }
Example #6
0
    public void RemoveDefeatedMonster(PawnInstance _deadMonster)
    {
        List <ItemContainer> lootList            = new List <ItemContainer>();
        Transform            lastMonsterPosition = null;

        monstersOnTile[_deadMonster.CurrentTile].Remove(_deadMonster);

        lastMonsterPosition = _deadMonster.transform;
        if (_deadMonster.GetComponent <Behaviour.Mortal>().DeathParticles != null)
        {
            ParticleSystem ps = Instantiate(_deadMonster.GetComponent <Behaviour.Mortal>().DeathParticles, _deadMonster.transform.parent);
            ps.transform.position = _deadMonster.transform.position;
            ps.Play();
            Destroy(ps.gameObject, ps.main.duration);
        }

        _deadMonster.GetComponent <Behaviour.Inventory>().ComputeItems();
        lootList.AddRange(_deadMonster.GetComponent <Behaviour.Inventory>().Items);

        if (EventManager.OnMonsterDie != null)
        {
            EventManager.OnMonsterDie(_deadMonster.GetComponent <Behaviour.Monster>());
        }

        if (lootList.Count > 0)
        {
            BattleHandler.CurrentBattleLoot.AddRange(lootList);
        }

        if (monstersOnTile[_deadMonster.CurrentTile].Count == 0)
        {
            monstersOnTile.Remove(_deadMonster.CurrentTile);
        }
    }
Example #7
0
    public static void ActivateFeedbackSelection(bool _activateOnKeepers, bool _activateOnMonsters)
    {
        if (currentBattleKeepers == null || currentBattleMonsters == null)
        {
            return;
        }

        if (_activateOnKeepers)
        {
            for (int i = 0; i < currentBattleKeepers.Length; i++)
            {
                if (currentBattleKeepers[i] != null && currentBattleKeepers[i].GetComponent <Mortal>().CurrentHp > 0)
                {
                    if (!currentBattleKeepers[i].GetComponent <Fighter>().HasPlayedThisTurn)
                    {
                        currentBattleKeepers[i].GetComponent <Keeper>().FeedbackSelection.SetActive(true);
                        GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().UpdateAvatar(currentBattleKeepers[i], true);
                    }
                    else
                    {
                        currentBattleKeepers[i].GetComponent <Keeper>().FeedbackSelection.SetActive(false);
                        GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().UpdateAvatar(currentBattleKeepers[i], false);
                    }
                }
            }
            if (isPrisonerOnTile)
            {
                PawnInstance pi = GameManager.Instance.PrisonerInstance;
                if (!pi.GetComponent <Fighter>().HasPlayedThisTurn)
                {
                    pi.GetComponent <Prisoner>().FeedbackSelection.SetActive(true);
                    GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().UpdateAvatar(pi, true);
                }
                else
                {
                    pi.GetComponent <Prisoner>().FeedbackSelection.SetActive(false);
                    GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().UpdateAvatar(pi, false);
                }
            }
        }
        // Activate on monsters
        if (_activateOnMonsters)
        {
            for (int i = 0; i < currentBattleMonsters.Length; i++)
            {
                if (currentBattleMonsters[i] != null && currentBattleMonsters[i].GetComponent <Mortal>().CurrentHp > 0)
                {
                    currentBattleMonsters[i].GetComponent <Monster>().PointerFeedback.SetActive(true);
                }
                else if (currentBattleMonsters[i] != null)
                {
                    currentBattleMonsters[i].GetComponent <Monster>().PointerFeedback.SetActive(false);
                }
            }
        }
    }
Example #8
0
 public void playAppearenceFeedback(PawnInstance pi)
 {
     if (pi.GetComponent <Behaviour.Mortal>().DeathParticles != null)
     {
         ParticleSystem ps = GameObject.Instantiate(pi.GetComponent <Behaviour.Mortal>().DeathParticles, pi.transform.parent);
         ps.transform.position = pi.transform.position;
         ps.Play();
         GameObject.Destroy(ps.gameObject, ps.main.duration);
     }
 }
Example #9
0
    public void InitThrow()
    {
        if (!isRunning)
        {
            GetComponent <UIBattleHandler>().ChangeState(UIBattleState.Actions);
            areDiceFeedbacksInitialized = false;
            areDiceRotatedProperly      = false;
            timerAnimation = 0.0f;
            isRunning      = false;
            upFaceIndex.Clear();
            diceInstance.Clear();
            for (int i = 0; i < BattleHandler.CurrentBattleKeepers.Length; i++)
            {
                PawnInstance currentKeeper = BattleHandler.CurrentBattleKeepers[i];
                if (currentKeeper.GetComponent <Mortal>().CurrentHp <= 0)
                {
                    continue;
                }

                diceForCurrentThrow.Add(currentKeeper, currentKeeper.GetComponent <Fighter>().Dice);

                // Create dice visuals
                diceInstance.Add(currentKeeper, new List <GameObject>());
                for (int j = 0; j < currentKeeper.GetComponent <Fighter>().Dice.Length; j++)
                {
                    Transform diePosition = TileManager.Instance.DicePositionsOnTile.GetChild(i).GetChild(j);
                    diceInstance[currentKeeper].Add(DieBuilder.BuildDie(diceForCurrentThrow[currentKeeper][j], GameManager.Instance.ActiveTile, diePosition.localPosition + diePosition.parent.localPosition));
                }
            }
            if (BattleHandler.isPrisonerOnTile)
            {
                PawnInstance prisoner = GameManager.Instance.PrisonerInstance;

                diceForCurrentThrow.Add(prisoner, prisoner.GetComponent <Fighter>().Dice);

                // Create dice visuals
                diceInstance.Add(prisoner, new List <GameObject>());
                for (int j = 0; j < prisoner.GetComponent <Fighter>().Dice.Length; j++)
                {
                    Transform diePosition = TileManager.Instance.DicePositionsOnTile.GetChild(2).GetChild(j);
                    diceInstance[prisoner].Add(DieBuilder.BuildDie(diceForCurrentThrow[prisoner][j], GameManager.Instance.ActiveTile, diePosition.localPosition + diePosition.parent.localPosition));
                }
            }

            AudioManager.Instance.PlayOneShot(AudioManager.Instance.thowDiceSound, 0.8f);
            isRunning   = true;
            throwResult = ComputeNotPhysicalResult();

            //GetComponent<UIBattleHandler>().ChangeState(UIBattleState.DiceRolling);
        }
        else
        {
            Debug.LogWarning("A dice throw is already in process.");
        }
    }
Example #10
0
 void Explore(int _i)
 {
     if (GameManager.Instance.ListOfSelectedKeepers.Count > 0)
     {
         PawnInstance toMove = GameManager.Instance.GetFirstSelectedKeeper();
         if (toMove.GetComponent <Keeper>() == null)
         {
             return;
         }
         int actionCostExploreTmp = actionCostExplore;
         if (toMove.Data.Behaviours[(int)BehavioursEnum.Explorateur] == true)
         {
             actionCostExploreTmp -= 1;
         }
         if (toMove.GetComponent <Keeper>().ActionPoints >= actionCostExploreTmp)
         {
             Tile currentTile = toMove.CurrentTile;
             // Confirmation Panel
             // TODO : refaire en mieux ?
             if (toMove.GetComponent <Keeper>().GoListCharacterFollowing.Count == 0 &&
                 currentTile == GameManager.Instance.PrisonerInstance.CurrentTile)
             {
                 if (!toMove.GetComponent <Keeper>().IsTheLastKeeperOnTheTile())
                 {
                     ExploreWithoutConfirmation(_i);
                 }
                 else
                 {
                     if (GameManager.Instance.CurrentState != GameState.InTuto || GameManager.Instance.CurrentState != GameState.InBattle)
                     {
                         GameManager.Instance.CurrentState = GameState.InPause;
                     }
                     GameManager.Instance.Ui.goConfirmationPanel.SetActive(true);
                     int n = _i;
                     GameManager.Instance.Ui.goConfirmationPanel.transform.GetChild(1).GetComponent <Button>().onClick.RemoveAllListeners();
                     GameManager.Instance.Ui.goConfirmationPanel.transform.GetChild(1).GetComponent <Button>().onClick.AddListener(() => ExploreWithoutConfirmation(n));
                     GameManager.Instance.Ui.goConfirmationPanel.transform.GetChild(1).GetComponent <Button>().onClick.AddListener(() => GameManager.Instance.Ui.goConfirmationPanel.SetActive(false));
                     if (TutoManager.s_instance != null && TutoManager.s_instance.enableTuto && TutoManager.s_instance.PlayingSequence == null &&
                         TutoManager.s_instance.GetComponent <SeqAshleyEscort>().AlreadyPlayed == false && TutoManager.s_instance.GetComponent <SeqMultiCharacters>().AlreadyPlayed == true)
                     {
                         TutoManager.s_instance.playSequence(TutoManager.s_instance.GetComponent <SeqAshleyEscort>());
                     }
                 }
             }
             else
             {
                 ExploreWithoutConfirmation(_i);
             }
         }
         else
         {
             GameManager.Instance.Ui.ZeroActionTextAnimation(GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>());
         }
     }
 }
Example #11
0
    private void SkillsPanelInit(PawnInstance _pawnInstanceForInit, int _index)
    {
        Transform skillsPanel      = skillsPanels.transform.GetChild(_index);
        Fighter   fighterComponent = _pawnInstanceForInit.GetComponent <Fighter>();

        if (fighterComponent.BattleSkills != null && fighterComponent.BattleSkills.Count > 0)
        {
            for (int i = 0; i < fighterComponent.BattleSkills.Count && i < 4; i++)
            {
                Transform currentSkill = skillsPanel.GetChild(i);

                SkillBattle fighterCurSkill;
                bool        isDepressed = _pawnInstanceForInit.GetComponent <MentalHealthHandler>() != null && _pawnInstanceForInit.GetComponent <MentalHealthHandler>().IsDepressed;
                if (isDepressed && fighterComponent.DepressedSkills.Count == fighterComponent.BattleSkills.Count)
                {
                    fighterCurSkill = fighterComponent.DepressedSkills[i];
                }
                else
                {
                    fighterCurSkill = fighterComponent.BattleSkills[i];
                }

                currentSkill.GetChild((int)SkillButtonChildren.SkillName).GetComponent <SkillContainer>().SkillData = fighterCurSkill;
                currentSkill.GetChild((int)SkillButtonChildren.SkillName).GetComponentInChildren <Text>().text      = fighterCurSkill.SkillName;
                currentSkill.GetComponent <SkillDescriptionUI>().SkillData = fighterCurSkill;

                currentSkill.GetChild((int)SkillButtonChildren.Atk).GetComponentInChildren <Text>().text = "0";
                currentSkill.GetChild((int)SkillButtonChildren.Def).GetComponentInChildren <Text>().text = "0";
                currentSkill.GetChild((int)SkillButtonChildren.Mag).GetComponentInChildren <Text>().text = "0";

                foreach (Face face in fighterCurSkill.Cost)
                {
                    if (face.Type == FaceType.Physical)
                    {
                        currentSkill.GetChild((int)SkillButtonChildren.Atk).GetComponentInChildren <Text>().text = face.Value.ToString();
                    }

                    if (face.Type == FaceType.Defensive)
                    {
                        currentSkill.GetChild((int)SkillButtonChildren.Def).GetComponentInChildren <Text>().text = face.Value.ToString();
                    }

                    if (face.Type == FaceType.Magical)
                    {
                        currentSkill.GetChild((int)SkillButtonChildren.Mag).GetComponentInChildren <Text>().text = face.Value.ToString();
                    }
                }
                currentSkill.gameObject.SetActive(true);
            }
        }

        skillsPanel.GetChild((int)SkillPanelChildren.CharacterAvatar).GetComponent <Image>().sprite = _pawnInstanceForInit.Data.AssociatedSpriteForBattle;
        associatedSkillsPanel.Add(_pawnInstanceForInit, skillsPanel);
    }
Example #12
0
 public void AddKeeperToSelectedList(PawnInstance pawn)
 {
     if (pawn.GetComponent <Keeper>() != null ||
         (currentState == GameState.InBattle && pawn.GetComponent <Prisoner>()) ||
         (currentState == GameState.InTuto && TutoManager.s_instance.StateBeforeTutoStarts == GameState.InBattle) && pawn.GetComponent <Prisoner>())
     {
         ListOfSelectedKeepers.Add(pawn);
     }
     else
     {
         Debug.Log("Can't add a pawn to selected keepers list without the Keeper component.");
     }
 }
Example #13
0
    public void CharacterPanelInit(PawnInstance _pawnInstanceForInit)
    {
        int initIndex = 0;

        for (int i = 0; i < 3; i++)
        {
            if (_pawnInstanceForInit.GetComponent <Prisoner>())
            {
                initIndex = 2;
                break;
            }
            if (occupiedCharacterPanelIndex[i] == false)
            {
                initIndex = i;
                break;
            }
        }

        Transform characterPanel = charactersPanel.transform.GetChild(initIndex).GetChild(0);

        characterPanel.GetChild((int)CharactersPanelChildren.Avatar).GetChild(0).GetComponent <Image>().sprite = _pawnInstanceForInit.Data.AssociatedSpriteForBattle;

        Mortal mortalComponent = _pawnInstanceForInit.GetComponent <Mortal>();
        Image  lifeBarImg      = characterPanel.GetChild((int)CharactersPanelChildren.LifeBar).GetChild((int)LifeBarChildren.Remaining).GetComponent <Image>();

        lifeBarImg.fillAmount = mortalComponent.CurrentHp / (float)mortalComponent.Data.MaxHp;
        lifeBarImg.sprite     = GameManager.Instance.SpriteUtils.spritePlayerGreenLifeBar;

        if (lifeBarImg.fillAmount < 0.33f)
        {
            lifeBarImg.color = Color.red;
        }
        else
        {
            lifeBarImg.color = Color.green;
        }
        characterPanel.GetChild((int)CharactersPanelChildren.LifeBar).GetChild((int)LifeBarChildren.Text).GetComponent <Text>().text = mortalComponent.CurrentHp + " / " + mortalComponent.Data.MaxHp;

        Fighter fighterComponent = _pawnInstanceForInit.GetComponent <Fighter>();

        characterPanel.GetChild((int)CharactersPanelChildren.Attributes).GetChild((int)AttributesChildren.Attack).GetComponentInChildren <Text>().text  = fighterComponent.PhysicalSymbolStored.ToString();
        characterPanel.GetChild((int)CharactersPanelChildren.Attributes).GetChild((int)AttributesChildren.Defense).GetComponentInChildren <Text>().text = fighterComponent.DefensiveSymbolStored.ToString();
        characterPanel.GetChild((int)CharactersPanelChildren.Attributes).GetChild((int)AttributesChildren.Magic).GetComponentInChildren <Text>().text   = fighterComponent.MagicalSymbolStored.ToString();

        occupiedCharacterPanelIndex[initIndex] = true;
        characterPanel.gameObject.SetActive(true);
        associatedCharacterPanel.Add(_pawnInstanceForInit, characterPanel);
        associatedCharacterPanelReversed.Add(characterPanel, _pawnInstanceForInit);
        SkillsPanelInit(_pawnInstanceForInit, initIndex);
    }
Example #14
0
    public void CantEndGame(int i = -1)
    {
        PawnInstance pi = ((PrisonerEscortObjective)(GameManager.Instance.QuestManager.MainQuest.Objectives[0])).prisoner.GetComponent <PawnInstance>();

        GameManager.Instance.CameraManagerReference.UpdateCameraPosition(pi);
        pi.GetComponent <GlowObjectCmd>().BlinkForSeconds(4.0f);
    }
Example #15
0
    public void AddKeeperOnTile(Tile tile, PawnInstance keeper)
    {
        if (keeper.GetComponent <Behaviour.Keeper>() == null)
        {
            Debug.Log("Can't add keeper to tile, missing component Keeper.");
            return;
        }

        if (KeepersOnTile.ContainsKey(tile))
        {
            KeepersOnTile[tile].Add(keeper);
        }
        else
        {
            List <PawnInstance> newList = new List <PawnInstance>();
            newList.Add(keeper);
            KeepersOnTile.Add(tile, newList);
        }

        if (GetTileFromKeeper.ContainsKey(keeper))
        {
            GetTileFromKeeper[keeper] = tile;
        }
        else
        {
            GetTileFromKeeper.Add(keeper, tile);
        }

        keeper.CurrentTile = tile;
        if (EventManager.OnPawnMove != null)
        {
            EventManager.OnPawnMove(keeper, tile);
        }
    }
Example #16
0
    public void CheckGameState()
    {
        short nbDead     = 0;
        short nbImmortal = 0;

        foreach (PawnInstance pi in AllKeepersList)
        {
            if (pi.GetComponent <Mortal>() == null)
            {
                nbImmortal++;
            }
            else
            {
                if (!pi.GetComponent <Mortal>().IsAlive)
                {
                    nbDead++;
                }
            }
        }

        if (nbDead == allKeepersList.Count - nbImmortal)
        {
            Debug.Log("GameOver - All Keepers died");
            if (CurrentState == GameState.InBattle)
            {
                hasLost = true;
            }
            else
            {
                Lose();
            }
        }

        if (!prisonerInstance.GetComponent <Mortal>().IsAlive)
        {
            Debug.Log("GameOver - The prisoner is dead");
            if (CurrentState == GameState.InBattle)
            {
                hasLost = true;
            }
            else
            {
                Lose();
            }
        }
    }
Example #17
0
        public void InitUI()
        {
            CreateShortcutHPPanel();
            ShortcutHPUI.name = "Mortal";

            if (instance.GetComponent <Escortable>() != null)
            {
                ShortcutHPUI.transform.SetParent(instance.GetComponent <Escortable>().ShorcutUI.transform);
                ShortcutHPUI.transform.localScale    = Vector3.one;
                ShortcutHPUI.transform.localPosition = Vector3.zero;
                ShortcutHPUI.transform.SetAsFirstSibling();
            }
            else if (instance.GetComponent <Keeper>() != null)
            {
                CreateSelectedHPPanel();
                SelectedHPUI.name = "Mortal";
                SelectedHPUI.transform.SetParent(instance.GetComponent <Keeper>().SelectedStatPanelUI.transform, false);
                SelectedHPUI.transform.localScale = Vector3.one;
                SelectedHPUI.transform.SetAsFirstSibling();
                //SelectedHPUI.transform.localPosition = Vector3.zero;

                ShortcutHPUI.transform.SetParent(instance.GetComponent <Keeper>().ShorcutUI.transform);
                ShortcutHPUI.transform.localScale    = Vector3.one;
                ShortcutHPUI.transform.localPosition = Vector3.zero;
                ShortcutHPUI.transform.SetAsFirstSibling();
            }

            UpdateHPPanel(MaxHp);
        }
Example #18
0
        private void SetInitialActionState()
        {
            var stateMachine = PawnInstance.GetComponent <IActionStateMachineInterface>();

            if (stateMachine != null)
            {
                stateMachine.RequestActionState(EActionStateMachineTrack.Locomotion, EActionStateId.Spawning, new ActionStateInfo(PawnInstance));
            }
        }
Example #19
0
 public void RemoveKeeperFromTile(Tile tile, PawnInstance keeper)
 {
     if (keeper.GetComponent <Behaviour.Keeper>() != null)
     {
         KeepersOnTile[tile].Remove(keeper);
     }
     else
     {
         Debug.Log("Could not add keeper because Keeper component missing.");
     }
 }
Example #20
0
    public void AutoEscortAshley()
    {
        PawnInstance ashley     = GameManager.Instance.PrisonerInstance;
        Tile         ashleyTile = ashley.CurrentTile;

        TileManager.Instance.KeepersOnTile[ashleyTile][0].GetComponent <Behaviour.Keeper>().GoListCharacterFollowing.Add(ashley.gameObject);
        Behaviour.Escortable escortComponent = ashley.GetComponent <Behaviour.Escortable>();
        escortComponent.escort     = TileManager.Instance.KeepersOnTile[ashleyTile][0].GetComponent <Behaviour.Keeper>();
        escortComponent.IsEscorted = true;
        escortComponent.ActivateIconNearEscort();
    }
Example #21
0
 private void RemoveMonsterFromTile(Tile tile, PawnInstance monster)
 {
     if (monster.GetComponent <Behaviour.Monster>() != null)
     {
         MonstersOnTile[tile].Remove(monster);
     }
     else
     {
         Debug.Log("Could not add monster because Monster component missing.");
     }
 }
Example #22
0
    public void SelectCharacter()
    {
        UIBattleHandler uiBattleHandler = GetComponentInParent <UIBattleHandler>();
        Transform       characterPanel  = (name.Contains("Avatar")) ? transform.parent.parent : transform;
        PawnInstance    pawnInstance    = uiBattleHandler.GetCharacterFromPanelIndex(characterPanel);

        if (pawnInstance.GetComponent <Keeper>() != null)
        {
            if (pawnInstance.GetComponent <Fighter>() != null && !pawnInstance.GetComponent <Fighter>().HasPlayedThisTurn)
            {
                for (int i = 0; i < 3; i++)
                {
                    uiBattleHandler.SkillsPanels.transform.GetChild(i).gameObject.SetActive(false);
                }
                GameManager.Instance.ClearListKeeperSelected();
                GameManager.Instance.AddKeeperToSelectedList(pawnInstance);
                pawnInstance.GetComponent <Keeper>().IsSelected = true;
                GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(pawnInstance).gameObject.SetActive(true);
            }
        }
    }
Example #23
0
        public void InitUI()
        {
            CreateShortcutMentalHealthPanel();
            ShortcutMentalHealthUI.name = "MentalHealth";


            if (instance.GetComponent <Escortable>() != null)
            {
                //selectedHPUI.transform.SetParent(instance.GetComponent<Escortable>().selectedStatPanelUI.transform);
            }
            else if (instance.GetComponent <Keeper>() != null)
            {
                CreateSelectedMentalHealthPanel();
                selectedMentalHealthUI.name = "MentalHealth";
                selectedMentalHealthUI.transform.SetParent(instance.GetComponent <Keeper>().SelectedStatPanelUI.transform, false);
                selectedMentalHealthUI.transform.localScale = Vector3.one;
                selectedMentalHealthUI.transform.SetAsFirstSibling();

                ShortcutMentalHealthUI.transform.SetParent(instance.GetComponent <Keeper>().ShorcutUI.transform);
                ShortcutMentalHealthUI.transform.localScale    = Vector3.one;
                ShortcutMentalHealthUI.transform.localPosition = Vector3.zero;
                ShortcutMentalHealthUI.transform.SetAsFirstSibling();
            }

            UpdateMentalHealthPanel(Data.MaxMentalHealth);
        }
Example #24
0
    public void MoveKeeper(PawnInstance keeper, Tile from, Direction direction, int costAction)
    {
        Tile destination = from.Neighbors[(int)direction];

        if (destination == null)
        {
            Debug.Log("Destination Unknown");
            return;
        }

        RemoveKeeperFromTile(from, keeper);
        AddKeeperOnTile(destination, keeper);
        Transform[] spawnPoints = GetSpawnPositions(destination, direction);

        // Physical movement
        keeper.GetComponent <Behaviour.AnimatedPawn>().StartBetweenTilesAnimation(spawnPoints[0].position);

        Behaviour.Keeper keeperComponent = keeper.GetComponent <Behaviour.Keeper>();
        keeperComponent.ActionPoints -= (short)costAction;
        keeperComponent.getPawnInstance.CurrentTile = destination;

        GameObject goCurrentCharacter;

        for (int i = 0; i < keeperComponent.GoListCharacterFollowing.Count; i++)
        {
            goCurrentCharacter = keeperComponent.GoListCharacterFollowing[i];

            if (goCurrentCharacter.GetComponent <Behaviour.Escortable>() != null)
            {
                goCurrentCharacter.GetComponent <PawnInstance>().CurrentTile = destination;
                goCurrentCharacter.GetComponent <Behaviour.AnimatedPawn>().StartBetweenTilesAnimation(spawnPoints[(i + 1) % spawnPoints.Length].position);
                if (goCurrentCharacter.GetComponent <Behaviour.Prisoner>() == null)
                {
                    MoveEscortable(goCurrentCharacter.GetComponent <PawnInstance>(), from, direction);
                }
            }
        }
    }
Example #25
0
 public void RemoveEscortableFromTile(Tile tile, PawnInstance escortable)
 {
     if (tile == null)
     {
         Debug.Log("Tile given is null");
         return;
     }
     if (escortable.GetComponent <Behaviour.Escortable>() != null)
     {
         escortablesOnTile[tile].Remove(escortable);
     }
     else
     {
         Debug.Log("Could not add escortable because Escortable component missing.");
     }
 }
Example #26
0
    private void ExploreWithoutConfirmation(int _i)
    {
        if (GameManager.Instance.CurrentState != GameState.InTuto && GameManager.Instance.CurrentState != GameState.InBattle)
        {
            GameManager.Instance.CurrentState = GameState.Normal;
        }
        PawnInstance toMove             = GameManager.Instance.GetFirstSelectedKeeper();
        AnimatedPawn toMoveAnimatedPawn = toMove.GetComponent <AnimatedPawn>();

        toMoveAnimatedPawn.CmdExplore = true;
        toMoveAnimatedPawn.WhereMove  = _i;
        for (int i = 0; i < GameManager.Instance.ListOfSelectedKeepers.Count; i++)
        {
            GameManager.Instance.ListOfSelectedKeepers[i].GetComponent <AnimatedPawn>().TriggerRotation(transform.position);
        }
    }
Example #27
0
    //void OnMouseEnter()
    //{
    //    if (!NeedToBeShown && !menuUI.IsACardInfoMovingForShowing && menuUI.cardsInfoAreReady && !menumanager.GoDeck.GetComponent<Deck>().IsOpen)
    //    {
    //        NeedToBeShown = true;
    //        isShown = true;
    //        menuUI.IsACardInfoMovingForShowing = true;

    //    }
    //}


    //void OnMouseExit()
    //{

    //    if (menuUI.ACardIsShown && !menuUI.IsACardInfoMovingForShowing && menuUI.cardsInfoAreReady && !menumanager.GoDeck.GetComponent<Deck>().IsOpen)
    //    {
    //        NeedToBeShown = false;

    //        menuUI.IsACardInfoMovingForShowing = true;
    //    }
    //}

    private void OnMouseExit()
    {
        if (menuUI.cardsInfoAreReady && associatedPawn != null)
        {
            if (!associatedPawn.GetComponent <GlowObjectCmd>().isActiveAndEnabled)
            {
                associatedPawn.GetComponent <GlowObjectCmd>().enabled = false;
            }
            associatedPawn.GetComponent <GlowObjectCmd>().UpdateColor(false);
        }
    }
Example #28
0
    public void UpdateAvatar(PawnInstance _toUpdate, bool _enableHighlightFeedback)
    {
        if (GameManager.Instance.CurrentState == GameState.InTuto)
        {
            return;
        }

        bool enableHighlightFeedback = false;

        if (!associatedCharacterPanel.ContainsKey(_toUpdate))
        {
            return;
        }

        if (!BattleHandler.HasDiceBeenThrown)
        {
            enableHighlightFeedback = false;
        }
        else
        {
            if (_toUpdate.GetComponent <Fighter>().HasPlayedThisTurn)
            {
                enableHighlightFeedback = false;
            }
            else
            {
                if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0)
                {
                    enableHighlightFeedback = !(GameManager.Instance.GetFirstSelectedKeeper() == _toUpdate);
                }
                else
                {
                    enableHighlightFeedback = true;
                }
                associatedCharacterPanel[_toUpdate].GetChild((int)CharactersPanelChildren.Avatar).GetChild(0).GetComponent <Image>().sprite = _toUpdate.Data.AssociatedSpriteForBattle;
            }
        }
        associatedCharacterPanel[_toUpdate].GetChild((int)CharactersPanelChildren.Avatar).GetComponent <Image>().enabled = enableHighlightFeedback;
        associatedCharacterPanel[_toUpdate].GetChild((int)CharactersPanelChildren.Avatar).GetComponentInChildren <Button>().interactable = enableHighlightFeedback && !isCharactersPanelLocked;
        associatedCharacterPanel[_toUpdate].GetChild((int)CharactersPanelChildren.Avatar).GetComponentInParent <Button>().interactable   = enableHighlightFeedback && !isCharactersPanelLocked;
    }
Example #29
0
    public void AddMonsterOnTile(Tile tile, PawnInstance monster)
    {
        if (monster.GetComponent <Behaviour.Monster>() == null)
        {
            Debug.Log("Can't add monster to tile, missing component Monster.");
            return;
        }

        if (MonstersOnTile.ContainsKey(tile))
        {
            MonstersOnTile[tile].Add(monster);
        }
        else
        {
            List <PawnInstance> newList = new List <PawnInstance>();
            newList.Add(monster);
            MonstersOnTile.Add(tile, newList);
        }

        monster.CurrentTile = tile;
    }
    // Init keepers and call next initialization
    public void InitKeepers(Transform[] beginPositionsKeepers)
    {
        GameManager.Instance.AllKeepersList.Clear();

        for (int i = 0; i < GameManager.Instance.AllKeeperListId.Count; i++)
        {
            string     curKeeperStr = GameManager.Instance.AllKeeperListId[i];
            GameObject curKeeper    = GameManager.Instance.PawnDataBase.CreatePawn(curKeeperStr, beginPositionsKeepers[i].position, Quaternion.identity, null);
            curKeeper.transform.localScale = Vector3.one;
            curKeeper.transform.GetComponent <NavMeshAgent>().enabled = true;
            PawnInstance curKeeperPI = curKeeper.transform.GetComponent <PawnInstance>();
            if (curKeeperPI.Data.Behaviours[(int)BehavioursEnum.Archer] == true)
            {
                GameManager.Instance.ArcherInstance = curKeeperPI;
            }

            GameManager.Instance.AllKeepersList.Add(curKeeperPI);
            InitCharacterUI(curKeeperPI);
            GameManager.Instance.RegisterKeeperPosition(curKeeperPI);
            GlowController.RegisterObject(curKeeperPI.GetComponent <GlowObjectCmd>());
        }

        // Next step, init quests
        // TODO: init quests

        // Next step, init NPCs
        // TODO: init quests and call this properly
        if (TutoManager.s_instance != null)
        {
            TutoManager.s_instance.InitDataTuto();
        }
        InitNPCs();
        if (TutoManager.s_instance != null)
        {
            TutoManager.s_instance.InitTuto();
        }

        EventManager.HandleWeather();
    }