예제 #1
0
    private IEnumerator DecreaseTextNormalState(Behaviour.Keeper ki)
    {
        Vector3 origin = ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().transform.position;

        for (float f = 3.0f; f >= 0; f -= 0.1f)
        {
            Vector3 decal = new Vector3(0.0f, f, 0.0f);
            ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().transform.position += decal;
            yield return(null);
        }
        ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().transform.position = origin;
        ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().gameObject.SetActive(false);
        yield return(null);
    }
예제 #2
0
    public void ZeroActionTextAnimation(Behaviour.Keeper ki)
    {
        foreach (Image i in ki.ShortcutActionPointUi.GetComponentsInChildren <Image>())
        {
            i.color = Color.red;
            //i.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
        }

        foreach (Image i in ki.SelectedActionPointsUI.GetComponentsInChildren <Image>())
        {
            i.color = Color.red;
            //i.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
        }

        StartCoroutine(TextAnimationNormalState(ki));
    }
예제 #3
0
    private IEnumerator TextAnimationNormalState(Behaviour.Keeper ki)
    {
        yield return(new WaitForSeconds(1));

        foreach (Image i in ki.ShortcutActionPointUi.GetComponentsInChildren <Image>())
        {
            i.color = Color.white;
            //i.transform.localScale = Vector3.one;
        }

        foreach (Image i in ki.SelectedActionPointsUI.GetComponentsInChildren <Image>())
        {
            i.color = Color.white;
            //i.transform.localScale = Vector3.one;
        }

        yield return(null);
    }
예제 #4
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);
                }
            }
        }
    }
예제 #5
0
        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();
        }
예제 #6
0
 public void DecreaseActionTextAnimation(Behaviour.Keeper ki, int amount)
 {
     ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().text = "- " + amount.ToString();
     ki.SelectedActionPointsUI.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>().gameObject.SetActive(true);
     StartCoroutine(DecreaseTextNormalState(ki));
 }
예제 #7
0
        void Update()
        {
            if (GameManager.Instance != null && (GameManager.Instance.CurrentState == GameState.Normal || GameManager.Instance.CurrentState == GameState.InTuto))
            {
                if (GetComponent <Keeper>() != null)
                {
                    Keeper     keeper            = GetComponent <Keeper>();
                    GameObject goDestinationTemp = gameObject;
                    for (int i = 0; i < GetComponent <Keeper>().GoListCharacterFollowing.Count; i++)
                    {
                        if (!keeper.GoListCharacterFollowing[i].GetComponent <AnimatedPawn>().IsMovingBetweenTiles)
                        {
                            if (keeper.GoListCharacterFollowing[i].GetComponentInParent <NavMeshAgent>() != null && keeper.GoListCharacterFollowing[i].GetComponentInParent <NavMeshAgent>().isActiveAndEnabled)
                            {
                                keeper.GoListCharacterFollowing[i].GetComponentInParent <NavMeshAgent>().destination = goDestinationTemp.transform.position;
                            }
                            goDestinationTemp = keeper.GoListCharacterFollowing[i];
                        }
                    }
                    if (bIsRotating)
                    {
                        Rotate();
                    }
                }
            }

            if (IsMovingBetweenTiles)
            {
                timerNeFaitRienPendantDixATrenteSecondes = Random.Range(10, 30);
                lerpMoveParam += Time.deltaTime;
                if (lerpMoveParam >= 1.0f)
                {
                    IsMovingBetweenTiles = false;
                }
                if (lerpMoveParam >= 0.25f && !isCameraUpdated)
                {
                    if (GameManager.Instance.CameraManagerReference.IsFollowingKeeper)
                    {
                        GameManager.Instance.UpdateCameraPosition(instance);
                    }
                    isCameraUpdated = true;
                }
                transform.position = Vector3.Lerp(lerpStartPosition, lerpEndPosition, Mathf.Clamp(lerpMoveParam, 0, 1));
                transform.rotation = Quaternion.Lerp(lerpStartRotation, lerpEndRotation, Mathf.Clamp(lerpMoveParam, 0, 1));
            }

            if (isMovingToBattlePosition)
            {
                timerNeFaitRienPendantDixATrenteSecondes = Random.Range(10, 30);
                lerpMoveParam += Time.deltaTime;
                if (lerpMoveParam >= 1.0f)
                {
                    IsMovingToBattlePosition = false;
                }
                transform.position = Vector3.Lerp(lerpStartPosition, lerpEndPosition, Mathf.Clamp(lerpMoveParam, 0, 1));
                transform.rotation = Quaternion.Lerp(lerpStartRotation, lerpEndRotation, Mathf.Clamp(lerpMoveParam, 0, 1));
            }

            if (anim != null && agent != null && anim.isActiveAndEnabled == true && agent.isActiveAndEnabled == true)
            {
                if (GetComponent <ItemInstance>() == null)
                {
                    anim.SetFloat("velocity", agent.velocity.magnitude);
                }
            }

            // ne fait rien pendant 10 secondes
            if (timerNeFaitRienPendantDixATrenteSecondes <= 0)
            {
                if (GetComponent <ItemInstance>() == null)
                {
                    anim.SetTrigger("idle");
                }
                timerNeFaitRienPendantDixATrenteSecondes = 10.0f;
            }
            else if (GameManager.Instance.CurrentState == GameState.Normal)
            {
                timerNeFaitRienPendantDixATrenteSecondes -= Time.deltaTime;
            }

            if (doesAgentNeedReset)
            {
                if (timerResetAgentDestination > 0.0f)
                {
                    timerResetAgentDestination -= Time.deltaTime;
                }
                else
                {
                    if (agent != null && agent.isActiveAndEnabled)
                    {
                        agent.ResetPath();
                    }
                    doesAgentNeedReset = false;
                }
            }
        }
예제 #8
0
    public void OnPointerClick(PointerEventData eventData)
    {
        int tap = eventData.clickCount;

        if (tap == 2)
        {
            if (GameManager.Instance.Ui.tooltipItem != null)
            {
                GameManager.Instance.Ui.tooltipItem.SetActive(false);
            }
            // Only keeper can use items
            Behaviour.Keeper owner = eventData.pointerPress.GetComponentInParent <InventoryOwner>().Owner.GetComponent <Behaviour.Keeper>();
            if (owner == null ||
                owner != GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Keeper>())
            {
                GameObject          goOwner = eventData.pointerPress.GetComponentInParent <InventoryOwner>().Owner;
                ItemContainer[]     selectedKeeperInventory = GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Items;
                Behaviour.Inventory ownerInventory          = goOwner.GetComponent <Behaviour.Inventory>();

                ItemContainer itemDragged = eventData.pointerPress.GetComponent <ItemInstance>().ItemContainer;

                if (InventoryManager.AddItemToInventory(selectedKeeperInventory, itemDragged))
                {
                    InventoryManager.RemoveItem(ownerInventory.Items, itemDragged);
                }

                // IF trying to merge 99 with 10 should swap or merge @rémi
                // else
                // foreach item
                //int quantityLeft = InventoryManager.MergeStackables(itemDragged, item);
                //if (quantityLeft <= 0)
                //{
                //    InventoryManager.RemoveItem(ownerInventory.Items, itemDragged);
                //}


                // Destroy inventory if it is empty for loot
                if (goOwner.GetComponent <LootInstance>() != null)
                {
                    bool isEmpty = true;
                    for (int i = 0; i < ownerInventory.Items.Length; i++)
                    {
                        if (ownerInventory.Items[i] != null)
                        {
                            isEmpty = false;
                            break;
                        }
                    }
                    if (isEmpty)
                    {
                        if (goOwner.GetComponentInChildren <Canvas>() != null)
                        {
                            goOwner.GetComponentInChildren <Canvas>().transform.SetParent(null);
                        }
                        Destroy(goOwner.gameObject);

                        // Get the original parent
                        Transform      previous        = eventData.pointerPress.GetComponentInParent <DragHandler>().transform;
                        InventoryOwner inventaireDequi = previous.GetComponentInParent <InventoryOwner>();
                        Destroy(inventaireDequi.GetComponentInParent <DragHandlerInventoryPanel>().gameObject);
                    }
                }

                goOwner.GetComponent <Behaviour.Inventory>().UpdateInventories();
                GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().UpdateInventories();
                //}
                return;
            }

            // Check if an inventory is opened
            Behaviour.Inventory openInventory = null;
            for (int i = 0; i < GameManager.Instance.Ui.Panel_Inventories.transform.childCount; i++)
            {
                if (GameManager.Instance.Ui.Panel_Inventories.transform.GetChild(i).gameObject.activeSelf)
                {
                    openInventory = GameManager.Instance.Ui.Panel_Inventories.transform.GetChild(i).GetComponentInChildren <InventoryOwner>().Owner.GetComponent <Behaviour.Inventory>();
                    break;
                }
            }

            // Use the item if no inventory opened
            if (openInventory == null)
            {
                ii.ItemContainer.UseItem(owner.GetComponent <PawnInstance>());

                if (ii.ItemContainer.Quantity <= 0)
                {
                    if (GameManager.Instance.Ui.tooltipItem.activeSelf)
                    {
                        GameManager.Instance.Ui.tooltipItem.SetActive(false);
                    }
                    InventoryManager.RemoveItem(owner.GetComponent <Behaviour.Inventory>().Items, ii.ItemContainer);
                    if (GameManager.Instance.CurrentState == GameState.InTuto)
                    {
                        TutoManager.MouseClicked = true;
                    }
                }
            }
            // Change item owner if an inventory is opened when double clicking
            else
            {
                ItemContainer itemDoubleClicked = eventData.pointerPress.GetComponent <ItemInstance>().ItemContainer;

                if (InventoryManager.AddItemToInventory(openInventory.Items, itemDoubleClicked))
                {
                    InventoryManager.RemoveItem(GameManager.Instance.GetFirstSelectedKeeper().GetComponent <Behaviour.Inventory>().Items, itemDoubleClicked);
                }

                openInventory.UpdateInventories();
            }

            owner.GetComponent <Behaviour.Inventory>().UpdateInventories();
        }
    }