Esempio n. 1
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;
    }
Esempio n. 2
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);
        }
    }
Esempio n. 3
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);
        }
    }
 public void UpdateProgress(PawnInstance pi, Tile tile)
 {
     if (pi.Data.PawnId == escortablePawnID && tile == destination)
     {
         CheckProgressWithEvent();
     }
 }
Esempio n. 5
0
    public void UpdateCameraPosition(PawnInstance pi)
    {
        isUpdateNeeded = true;
        oldPosition    = tClose.position;

        activeTile = pi.CurrentTile;
    }
Esempio n. 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);
        }
    }
Esempio n. 7
0
    public static void ResetCurrentBattleMonsters()
    {
        if (currentBattleMonsters.Length <= 1)
        {
            return;
        }

        int deathNbr = 0;

        for (int i = 0; i < currentBattleMonsters.Length; i++)
        {
            if (currentBattleMonsters[i] == null)
            {
                deathNbr++;
            }
        }
        PawnInstance[] newCurrentMonsters = new PawnInstance[currentBattleMonsters.Length - deathNbr];

        int j = 0;

        for (int i = 0; i < currentBattleMonsters.Length - deathNbr; i++)
        {
            if (currentBattleMonsters[i + j] == null)
            {
                j++;
            }
            newCurrentMonsters[i] = currentBattleMonsters[i + j];
        }

        currentBattleMonsters = null;
        currentBattleMonsters = newCurrentMonsters;
    }
Esempio n. 8
0
 void Awake()
 {
     instance = GetComponent <PawnInstance>();
     green    = new Color32(0x00, 0xFF, 0x6B, 0x92);
     red      = new Color32(0xFF, 0x00, 0x00, 0x92);
     yellow   = new Color32(0xD1, 0xFF, 0x00, 0x92);
 }
Esempio n. 9
0
    void UpdateKeepersPosition()
    {
        fLerp += Time.unscaledDeltaTime * 5;

        if (fLerp > 1)
        {
            fLerp = 1;
        }

        if (previousTransform == keepersPositions.transform.GetChild(previousIndex))
        {
            pawnMoving.transform.localPosition = Vector3.Lerp(keepersPositions.transform.GetChild(previousIndex).position, keepersPositionTarget.transform.GetChild(firstFreeIndex).position, fLerp);
            pawnMoving.transform.localRotation = Quaternion.Lerp(keepersPositions.transform.GetChild(previousIndex).rotation, keepersPositionTarget.transform.GetChild(firstFreeIndex).rotation, fLerp);
        }
        else if (previousTransform == keepersPositionTarget.transform.GetChild(previousIndex))
        {
            pawnMoving.transform.localPosition = Vector3.Lerp(keepersPositionTarget.transform.GetChild(previousIndex).position, keepersPositions.transform.GetChild(firstFreeIndex).position, fLerp);
            pawnMoving.transform.localRotation = Quaternion.Lerp(keepersPositionTarget.transform.GetChild(previousIndex).rotation, keepersPositions.transform.GetChild(firstFreeIndex).rotation, fLerp);
        }

        if (fLerp == 1)
        {
            if (previousTransform == keepersPositions.transform.GetChild(previousIndex))
            {
                pawnMoving.transform.SetParent(keepersPositionTarget.transform.GetChild(firstFreeIndex));
            }
            else if (previousTransform = keepersPositionTarget.transform.GetChild(previousIndex))
            {
                pawnMoving.transform.SetParent(keepersPositions.transform.GetChild(firstFreeIndex));
            }
            isAPawnMoving = false;
            fLerp         = 0;
            pawnMoving    = null;
        }
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
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");
        }
    }
Esempio n. 12
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);
    }
Esempio n. 13
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;
        }
Esempio n. 14
0
 private static void ResetBattleHandler()
 {
     ClearDiceForNextThrow();
     isProcessingABattle = false;
     if (lastThrowResult != null)
     {
         lastThrowResult.Clear();
     }
     isPrisonerOnTile      = false;
     battleLogger.text     = "";
     currentBattleMonsters = null;
     currentBattleKeepers  = null;
     nbTurn               = 0;
     nextMonsterIndex     = 0;
     isVictorious         = false;
     currentTargetMonster = null;
     isKeepersTurn        = false;
     //currentTurnDice = null;
     hasDiceBeenThrown          = false;
     wasTheLastToPlay           = false;
     PendingSkill               = null;
     isWaitingForSkillEnd       = false;
     battleEndConditionsReached = false;
     currentBattleLoot.Clear();
     archerPreviousTile = null;
 }
Esempio n. 15
0
    void Update()
    {
        if (GameManager.Instance.CurrentState == GameState.Normal && !BattleHandler.IsABattleAlreadyInProcess())
        {
            if (instance == null)
            {
                instance = GetComponentInParent <PawnInstance>();
            }

            // If an error appears here, call the 0646440132, thanks
            if (instance.CurrentTile != null && TileManager.Instance.KeepersOnTile.ContainsKey(instance.CurrentTile))
            {
                List <PawnInstance> keepers = TileManager.Instance.KeepersOnTile[instance.CurrentTile];
                for (int i = 0; i < keepers.Count; i++)
                {
                    if (keepers[i].CurrentTile == instance.CurrentTile)
                    {
                        if (Vector3.Distance(keepers[i].transform.position, transform.position) < 0.5f)
                        {
                            LaunchBattle(keepers[i]);
                        }
                    }
                }
            }
        }
    }
Esempio n. 16
0
 void Look(int _i)
 {
     if (GameManager.Instance.ListOfSelectedKeepers.Count > 0)
     {
         PawnInstance ki = GameManager.Instance.ListOfSelectedKeepers[0];
         if (goPanneau == null)
         {
             return;
         }
         goPanneau.SetActive(true);
         // Si le personnage peut parler
         if (ki.Data.Behaviours[(int)BehavioursEnum.CanSpeak])
         {
             goPanneau.GetComponentInChildren <Text>().text = Translater.PanelsText(level, 0, CharacterRace.Human);
         }
         else
         {
             if (ki.Data.PawnId == "lucky")
             {
                 goPanneau.GetComponentInChildren <Text>().text = Translater.PanelsText(level, 0, CharacterRace.Cat);
             }
             else
             {
                 goPanneau.GetComponentInChildren <Text>().text = Translater.PanelsText(level, 0, CharacterRace.Dog);
             }
         }
     }
 }
Esempio n. 17
0
    private static void ShiftToNextMonsterTurn()
    {
        while (currentBattleMonsters[nextMonsterIndex].GetComponent <Mortal>().CurrentHp <= 0)
        {
            nextMonsterIndex++;
            if (nextMonsterIndex >= currentBattleMonsters.Length)
            {
                break;
            }
        }

        if (nextMonsterIndex >= currentBattleMonsters.Length)
        {
            if (TutoManager.s_instance != null && TutoManager.s_instance.PlayingSequence != null && TutoManager.s_instance.PlayingSequence.CurrentState == SequenceState.WaitingForExternalEvent)
            {
                TutoManager.s_instance.PlayingSequence.Play();
            }
            ShiftTurn();
            return;
        }

        PawnInstance target            = GetTargetForAttack();
        Fighter      monsterBattleInfo = currentBattleMonsters[nextMonsterIndex].GetComponent <Fighter>();

        monsterBattleInfo.UseSkill(target);
        nextMonsterIndex++;
    }
Esempio n. 18
0
 public void UpdateProgress(PawnInstance pi, Tile t)
 {
     if (pi.gameObject == prisoner && t == destination)
     {
         CheckProgressWithEvent();
     }
 }
Esempio n. 19
0
        public void InitSelectedInventoryPanel()
        {
            PawnInstance pawnInstance     = instance.GetComponent <PawnInstance>();
            Sprite       associatedSprite = pawnInstance.Data.AssociatedSprite;
            GameObject   owner            = pawnInstance.gameObject;

            selectedInventoryPanel.GetComponent <InventoryOwner>().Owner = instance.gameObject;

            for (int i = 0; i < data.NbSlot; i++)
            {
                //Create Slots
                GameObject currentgoSlotPanel;
                if (GetComponent <Keeper>() != null)
                {
                    currentgoSlotPanel = Instantiate(GameManager.Instance.PrefabUIUtils.PrefabSlotUI, Vector3.zero, Quaternion.identity) as GameObject;
                }
                else
                {
                    currentgoSlotPanel = Instantiate(GameManager.Instance.PrefabUIUtils.PrefabSlotAshleyUI, Vector3.zero, Quaternion.identity) as GameObject;
                    Button butt = currentgoSlotPanel.GetComponentInChildren <Button>();
                    butt.onClick.AddListener(instance.GetComponent <Prisoner>().ProcessFeeding);
                }

                currentgoSlotPanel.transform.SetParent(selectedInventoryPanel.transform);

                currentgoSlotPanel.transform.localPosition = Vector3.zero;
                currentgoSlotPanel.transform.localScale    = Vector3.one;
                currentgoSlotPanel.name = "Slot" + i;
            }

            selectedInventoryPanel.GetComponent <GridLayoutGroup>().constraintCount = data.NbSlot;
        }
Esempio n. 20
0
    public void UpdateKeepers(PawnInstance pi, Transform _previousParent)
    {
        pawnMoving = pi;

        previousTransform = _previousParent;
        previousIndex     = previousTransform.GetSiblingIndex();
        if (previousTransform == keepersPositions.transform.GetChild(previousIndex))
        {
            for (int i = 0; i < keepersPositionTarget.transform.childCount; i++)
            {
                if (keepersPositionTarget.transform.GetChild(i).childCount == 0)
                {
                    firstFreeIndex = keepersPositionTarget.transform.GetChild(i).GetSiblingIndex();
                    break;
                }
            }
        }
        else if (previousTransform == keepersPositionTarget.transform.GetChild(previousIndex))
        {
            for (int i = 0; i < keepersPositions.transform.childCount; i++)
            {
                if (keepersPositions.transform.GetChild(i).name == pi.Data.PawnId)
                {
                    firstFreeIndex = keepersPositions.transform.GetChild(i).GetSiblingIndex();
                    break;
                }
            }
        }
        isAPawnMoving = true;

        UpdateStartButton();
    }
Esempio n. 21
0
 void LaunchBattle(PawnInstance _aggroTarget)
 {
     if (GetComponentInParent <Monster>().BattleOnCollision&& _aggroTarget.GetComponentInParent <Fighter>() != null && _aggroTarget.GetComponentInParent <Fighter>().IsTargetableByMonster == true)
     {
         BattleHandler.StartBattleProcess(instance.CurrentTile);
         GameManager.Instance.UpdateCameraPosition(_aggroTarget);
     }
 }
Esempio n. 22
0
        private void SetInitialActionState()
        {
            var stateMachine = PawnInstance.GetComponent <IActionStateMachineInterface>();

            if (stateMachine != null)
            {
                stateMachine.RequestActionState(EActionStateMachineTrack.Locomotion, EActionStateId.Spawning, new ActionStateInfo(PawnInstance));
            }
        }
Esempio n. 23
0
    public void KeeperSelectionControls(GameObject hit)
    {
        PawnInstance pi = hit.transform.gameObject.GetComponent <PawnInstance>();

        if (menuManager.CardLevelSelected == -1 && menuManager.ListeSelectedKeepers.Count == 0 && !menuManager.GoDeck.GetComponent <Deck>().IsOpen)
        {
            menuManager.GoDeck.GetComponent <GlowObjectCmd>().ActivateBlinkBehaviour(true);

            menuManager.GoDeck.GetComponent <GlowObjectCmd>().enabled = true;
        }
        else if (pi != null && menuUI.cardsInfoAreReady && !menuManager.GoDeck.GetComponent <Deck>().IsOpen&& !menuUI.IsAPawnMoving && !menuUI.ACardInfoIsShown && !menuUI.ACardInfoIsShown)
        {
            if (menuManager.ContainsSelectedKeepers(pi.Data.PawnId)) // REMOVE
            {
                AudioManager.Instance.PlayOneShot(AudioManager.Instance.deselectSound, 0.25f);
                //pi.GetComponent<OpenerContent>().Hide();
                menuManager.RemoveFromSelectedKeepers(pi.Data.PawnId);
                if (menuManager.GoDeck.GetComponent <Deck>() != null && !menuManager.GoDeck.GetComponent <Deck>().IsOpen)
                {
                    menuManager.DicPawnChatBox[pi.gameObject].SetMode(ChatBox.ChatMode.awaiting);
                    menuManager.DicPawnChatBox[pi.gameObject].Say(ChatBox.ChatMode.unchosen);
                }


                menuUI.UpdateKeepers(pi, hit.transform.parent);
                pi.transform.SetParent(null);

                boxOpener.UpdateLockAspect();

                menuUI.UpdateStartButton();
            }
            else    // ADD
            {
                if (menuManager.CardLevelSelected != -1)
                {
                    AudioManager.Instance.PlayOneShot(AudioManager.Instance.selectSound, 0.25f);
                    //pi.GetComponent<OpenerContent>().Show();

                    menuManager.AddToSelectedKeepers(pi.Data.PawnId);
                    if (menuManager.GoDeck.GetComponent <Deck>() != null && !menuManager.GoDeck.GetComponent <Deck>().IsOpen)
                    {
                        menuManager.DicPawnChatBox[pi.gameObject].SetMode(ChatBox.ChatMode.picked);
                        menuManager.DicPawnChatBox[pi.gameObject].Say(ChatBox.ChatMode.chosen);
                    }


                    menuUI.UpdateKeepers(pi, hit.transform.parent);
                    pi.transform.SetParent(null);

                    boxOpener.UpdateLockAspect();

                    menuUI.UpdateStartButton();
                }
            }
        }
    }
Esempio n. 24
0
    public void PopFeedback(Face _faceInfo, PawnInstance _owner)
    {
        if (feedback == null)
        {
            feedback = Instantiate(GameManager.Instance.PrefabUIUtils.diceFeedback, GameManager.Instance.Ui.transform.GetChild(0));
        }

        owner    = _owner;
        faceInfo = _faceInfo;
        feedback.transform.position   = Camera.main.WorldToScreenPoint(transform.position);
        feedback.transform.localScale = Vector3.one;
        feedback.GetComponentInChildren <Text>().text = "+ " + faceInfo.Value;


        Transform attributesPanel = GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetCharacterPanelIndex(owner).GetChild((int)CharactersPanelChildren.Attributes);

        if (faceInfo.Type == FaceType.Physical)
        {
            feedback.GetComponentInChildren <Image>().sprite = GameManager.Instance.SpriteUtils.spriteAttackSymbol;
            feedback.GetComponentInChildren <Image>().color  = orangeClaire;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectColor    = orangeFonce;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectDistance = new Vector2(0.001f, 0.001f);


            feedback.GetComponentInChildren <Text>().color = orangeClaire;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectColor    = orangeFonce;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectDistance = Vector2.zero;
            lerpEndPosition = attributesPanel.GetChild((int)AttributesChildren.Attack).position;
        }
        else if (faceInfo.Type == FaceType.Defensive)
        {
            feedback.GetComponentInChildren <Image>().sprite = GameManager.Instance.SpriteUtils.spriteDefenseSymbol;
            feedback.GetComponentInChildren <Image>().color  = bleuClaire;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectColor    = bleuFonce;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectDistance = new Vector2(0.001f, 0.001f);

            feedback.GetComponentInChildren <Text>().color = bleuClaire;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectColor    = violetFonce;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectDistance = Vector2.zero;
            lerpEndPosition = attributesPanel.GetChild((int)AttributesChildren.Defense).position;
        }
        else if (faceInfo.Type == FaceType.Magical)
        {
            feedback.GetComponentInChildren <Image>().sprite = GameManager.Instance.SpriteUtils.spriteMagicSymbol;
            feedback.GetComponentInChildren <Image>().color  = violetClaire;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectColor    = violetFonce;
            feedback.GetComponentInChildren <Image>().GetComponent <Outline>().effectDistance = new Vector2(0.001f, 0.001f);

            feedback.GetComponentInChildren <Text>().color = violetClaire;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectColor    = violetFonce;
            feedback.GetComponentInChildren <Text>().GetComponent <Outline>().effectDistance = Vector2.zero;
            lerpEndPosition = attributesPanel.GetChild((int)AttributesChildren.Magic).position;
        }

        isRising = true;
    }
    private void OnEnable()
    {
        int j = 0;

        transform.GetChild((int)SelectBattleCharactersScreenChildren.Header).GetComponentInChildren <Text>().text = Translater.BattleCharacterSelection();

        foreach (PawnInstance ki in TileManager.Instance.KeepersOnTile[activeTile])
        {
            if (ki.Data.Behaviours[(int)BehavioursEnum.Archer] == true)
            {
                continue;
            }

            GameObject kiImage = Instantiate(imagePrefab, transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersOnTile).GetChild(j));
            kiImage.AddComponent <UIKeeperInstance>();
            kiImage.GetComponent <UIKeeperInstance>().keeperInstance = ki;
            kiImage.AddComponent <DragHandler>();
            kiImage.AddComponent <CanvasGroup>();

            kiImage.transform.localScale          = Vector3.one;
            kiImage.transform.localPosition       = Vector3.zero;
            kiImage.GetComponent <Image>().sprite = ki.Data.AssociatedSprite;

            j++;
        }

        PawnInstance archer = GameManager.Instance.ArcherInstance;

        if (archer != null && archer.CurrentTile == activeTile)
        {
            GameObject kiImage = Instantiate(imagePrefab, transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersOnTile).GetChild(j));
            kiImage.AddComponent <UIKeeperInstance>();
            kiImage.GetComponent <UIKeeperInstance>().keeperInstance = archer;
            kiImage.AddComponent <DragHandler>();
            kiImage.AddComponent <CanvasGroup>();

            kiImage.transform.localScale          = Vector3.one;
            kiImage.transform.localPosition       = Vector3.zero;
            kiImage.GetComponent <Image>().sprite = archer.Data.AssociatedSprite;
        }

        if (TileManager.Instance.PrisonerTile != null && TileManager.Instance.PrisonerTile == activeTile)
        {
            isPrisonerOnTile = true;
            GameObject kiImage = Instantiate(imagePrefab, transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(2));
            kiImage.transform.localScale          = Vector3.one;
            kiImage.transform.localPosition       = Vector3.zero;
            kiImage.GetComponent <Image>().sprite = GameManager.Instance.PrisonerInstance.Data.AssociatedSprite;
        }
        else
        {
            isPrisonerOnTile = false;
        }

        // TODO load monsters on tile in UI (sprites only)
    }
Esempio n. 26
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);
                }
            }
        }
    }
Esempio n. 27
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);
     }
 }
Esempio n. 28
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>());
         }
     }
 }
Esempio n. 29
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.");
        }
    }
Esempio n. 30
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();
    }