예제 #1
0
 void OnDestroy()
 {
     if (BattleHandler.IsABattleAlreadyInProcess() && BattleHandler.IsWaitingForSkillEnd)
     {
         EndSkillProcess();
     }
 }
예제 #2
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]);
                        }
                    }
                }
            }
        }
    }
예제 #3
0
        private void Attack(int _i = 0)
        {
            if (GameManager.Instance.CurrentState == GameState.Normal)
            {
                //NavMeshAgent agent = GameManager.Instance.GetFirstSelectedKeeper().GetComponent<NavMeshAgent>();
                //if (agent != null && agent.isActiveAndEnabled)
                //    agent.SetDestination(transform.position);

                if (GetComponentInParent <Fighter>() != null && GetComponentInParent <Fighter>().IsTargetableByMonster == true)
                {
                    if (BattleHandler.IsABattleAlreadyInProcess())
                    {
                        return;
                    }

                    Tile tile = GetComponentInParent <PawnInstance>().CurrentTile;

                    BattleHandler.StartBattleProcess(tile);

                    GameManager.Instance.UpdateCameraPosition(GetComponentInParent <PawnInstance>());
                }
            }
        }
예제 #4
0
    private void InBattleControls()
    {
        if (BattleHandler.IsABattleAlreadyInProcess() && BattleHandler.IsKeepersTurn && BattleHandler.HasDiceBeenThrown && !BattleHandler.IsWaitingForSkillEnd)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0 &&
                    BattleHandler.PendingSkill != null)
                {
                    HandleActionValidationDuringBattle();
                }
                else
                {
                    if (!EventSystem.current.IsPointerOverGameObject())
                    {
                        RaycastHit hitInfo;
                        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, ~layerMaskClickGauche) == true)
                        {
                            GameObject clickTarget = hitInfo.collider.gameObject;
                            if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0)
                            {
                                // TODO: find another way
                                GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false);
                            }

                            if (clickTarget.GetComponentInParent <PawnInstance>() != null)
                            {
                                if (clickTarget.GetComponentInParent <Keeper>() != null || clickTarget.GetComponentInParent <Prisoner>() != null)
                                {
                                    if (clickTarget.GetComponentInParent <Fighter>() != null && !clickTarget.GetComponentInParent <Fighter>().HasPlayedThisTurn)
                                    {
                                        GameManager.Instance.ClearListKeeperSelected();
                                        GameManager.Instance.AddKeeperToSelectedList(clickTarget.GetComponentInParent <PawnInstance>());
                                        if (clickTarget.GetComponentInParent <Prisoner>() != null)
                                        {
                                            clickTarget.GetComponentInParent <Prisoner>().IsSelected = true;
                                        }
                                        else
                                        {
                                            clickTarget.GetComponentInParent <Keeper>().IsSelected = true;
                                        }
                                        GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(clickTarget.GetComponentInParent <PawnInstance>()).gameObject.SetActive(true);
                                    }
                                }
                            }
                            else
                            {
                                if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0)
                                {
                                    // TODO: find another way
                                    GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false);
                                }
                                GameManager.Instance.ClearListKeeperSelected();
                                CursorNormalState();
                                BattleHandler.ActivateFeedbackSelection(true, false);
                                BattleHandler.DeactivateFeedbackSelection(false, true);
                            }
                        }
                        else
                        {
                            if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0)
                            {
                                // TODO: find another way
                                GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().GetSkillsPanelIndex(GameManager.Instance.GetFirstSelectedKeeper()).gameObject.SetActive(false);
                            }
                            GameManager.Instance.ClearListKeeperSelected();
                            CursorNormalState();
                            BattleHandler.ActivateFeedbackSelection(true, false);
                            BattleHandler.DeactivateFeedbackSelection(false, true);
                        }
                    }
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                if (GameManager.Instance.ListOfSelectedKeepers != null && GameManager.Instance.ListOfSelectedKeepers.Count > 0 &&
                    BattleHandler.PendingSkill != null)
                {
                    HandleActionValidationDuringBattle();
                }
                else if (GameManager.Instance.ListOfSelectedKeepers == null || GameManager.Instance.ListOfSelectedKeepers.Count == 0)
                {
                    BattleHandler.ActivateFeedbackSelection(true, false);
                }
            }
        }
    }