Example #1
0
    /// <summary>
    /// 检测战斗是否结束
    /// </summary>
    public bool CheckEventEnd()
    {
        if (MiniGameHandler.Instance.handlerForCombat.GetMiniGameStatus() != MiniGameStatusEnum.Gameing)
        {
            if (npcLocation == TownBuildingEnum.Town)
            {
                SetRandomBuildingToGo();
            }
            else
            {
                int randomIntent = UnityEngine.Random.Range(0, 2);
                //一半概率继续留在该建筑
                if (randomIntent == 0)
                {
                    //开始逛街
                    SceneTownManager sceneTownManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneTownManager>();
                    movePosition = sceneTownManager.GetRandomBuildingInsidePosition(npcLocation);
                    characterMoveCpt.SetDestination(movePosition);
                    //开始逛街
                    StartCoroutine(CoroutineForStayTimeCountdown(npcLocation));
                }
                //一半概率离开该建筑
                else
                {
                    SetIntent(PasserIntentEnum.LeaveBuilding);
                }
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #2
0
    /// <summary>
    /// 镇上闲逛
    /// </summary>
    public void IntentForStayInTown()
    {
        //开始逛街
        SceneTownManager sceneTownManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneTownManager>();

        movePosition = sceneTownManager.GetRandomBuildingInsidePosition(TownBuildingEnum.Town);
        characterMoveCpt.SetDestination(movePosition);
    }
Example #3
0
    /// <summary>
    /// 协程-逗留倒计时
    /// </summary>
    /// <param name="buildingEnum"></param>
    /// <returns></returns>
    public IEnumerator CoroutineForStayTimeCountdown(TownBuildingEnum buildingEnum)
    {
        SceneTownManager sceneTownManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneTownManager>();

        for (int i = 0; i < 3; i++)
        {
            //重新设置地点
            movePosition = sceneTownManager.GetRandomBuildingInsidePosition(buildingEnum);
            characterMoveCpt.SetDestination(movePosition);
            yield return(new WaitForSeconds(20));
        }
        SetIntent(PasserIntentEnum.LeaveBuilding);
    }
Example #4
0
    /// <summary>
    /// 在建筑物内逗留
    /// </summary>
    public void IntentForStayInBuilding(TownBuildingEnum buildingEnum)
    {
        //暂时关闭自动寻路(不关闭的话 无法跨范围移动NPC)
        // characterMoveCpt.CloseNavMeshAgent();
        //进入建筑内部
        transform.position = buildingInDoorPosition;
        //设置当前所在地
        SetLocation(buildingEnum);
        //进入建筑后开启自动寻路
        // characterMoveCpt.OpenNavMeshAgent();
        //开始逛街
        SceneTownManager sceneTownManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneTownManager>();

        movePosition = sceneTownManager.GetRandomBuildingInsidePosition(buildingEnum);
        characterMoveCpt.SetDestination(movePosition);
        //开始逛街
        StartCoroutine(CoroutineForStayTimeCountdown(buildingEnum));
    }