Example #1
0
 /// <summary>
 /// 设置算账数据
 /// </summary>
 public bool SetPay(OrderForBase order, NpcAIWorkerCpt workNpc)
 {
     if (workNpc != null)
     {
         if (order.counter.counterStatus == BuildCounterCpt.CounterStatusEnum.Idle)
         {
             order.counter.SetCounterStatus(BuildCounterCpt.CounterStatusEnum.Ready);
             if (order as OrderForCustomer != null)
             {
                 workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.Accounting, (OrderForCustomer)order);
             }
             else if (order as OrderForHotel != null)
             {
                 workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.Accounting, (OrderForHotel)order);
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Example #2
0
 /// <summary>
 /// 意图-闲置
 /// </summary>
 public void SetIntentForIdle()
 {
     sendPro.SetActive(false);
     cleanPro.SetActive(false);
     bedPro.SetActive(false);
     order = null;
     npcAIWorker.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.Idle);
 }
Example #3
0
    /// <summary>
    /// 关闭客栈
    /// </summary>
    public void CloseInn()
    {
        AudioHandler.Instance.StopMusic();
        innStatus = InnStatusEnum.Close;

        //删除所有顾客
        //驱除所有顾客
        NpcHandler.Instance.builderForCustomer.ClearNpc();
        //清理事件NPC
        NpcHandler.Instance.builderForEvent.ClearNpc();
        //清理家族NPC
        NpcHandler.Instance.builderForFamily.ClearNpc();

        for (int i = 0; i < listOrder.Count; i++)
        {
            OrderForBase orderForBase = listOrder[i];
            if (orderForBase as OrderForCustomer != null)
            {
                OrderForCustomer orderCusomer = orderForBase as OrderForCustomer;
                //清理所有食物
                if (orderCusomer.foodCpt != null && orderCusomer.foodCpt.gameObject != null)
                {
                    Destroy(orderCusomer.foodCpt.gameObject);
                }
            }
        }
        //清理所有桌子
        innTableHandler.CleanAllTable();
        //清理所有柜台
        innPayHandler.CleanAllCounter();
        //清理所有灶台
        innCookHandler.CleanAllStove();
        //清理所有的床
        innHotelHandler.CleanAllBed();

        //结束所有拉人活动
        //结束所有引路活动
        for (int i = 0; i < NpcHandler.Instance.builderForWorker.listNpcWorker.Count; i++)
        {
            NpcAIWorkerCpt itemWorker = NpcHandler.Instance.builderForWorker.listNpcWorker[i];
            if (itemWorker != null && itemWorker.aiForAccost.npcAICustomer != null)
            {
                itemWorker.aiForAccost.npcAICustomer.SetIntent(NpcAICustomerCpt.CustomerIntentEnum.Leave);
            }
        }

        NpcHandler.Instance.builderForWorker.ClearAllWork();

        rascalrQueue.Clear();
        cusomerQueue.Clear();
        foodQueue.Clear();
        sendQueue.Clear();
        cleanQueue.Clear();
        listOrder.Clear();

        hotelQueue.Clear();
        bedCleanQueue.Clear();
    }
Example #4
0
 /// <summary>
 /// 意图-闲置
 /// </summary>
 public void SetIntentForIdle()
 {
     accountingPro.SetActive(false);
     if (order != null && order.counter != null)
     {
         order.counter.SetCounterStatus(BuildCounterCpt.CounterStatusEnum.Idle);
     }
     order = null;
     npcAIWorker.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.Idle);
 }
Example #5
0
 /// <summary>
 /// 意图-前往结算
 /// </summary>
 /// <param name="order"></param>
 public void SetIntentForGoToAccounting(OrderForBase order)
 {
     if (CheckUtil.CheckPath(transform.position, order.counter.GetAccountingPosition()))
     {
         accountingPro.SetActive(true);
         movePosition = order.counter.GetAccountingPosition();
         npcAIWorker.characterMoveCpt.SetDestination(movePosition);
     }
     else
     {
         SetIntent(AccountantIntentEnum.Idle);
     }
 }
Example #6
0
 /// <summary>
 /// 意图-结算中
 /// </summary>
 /// <param name="order"></param>
 public void SetIntentForAccounting(OrderForBase order)
 {
     //设置柜台的状态
     order.counter.SetCounterStatus(BuildCounterCpt.CounterStatusEnum.Accounting);
     if (order as OrderForCustomer != null)
     {
         //开始结算
         StartCoroutine(CoroutineForAccountingForFood(order as OrderForCustomer));
     }
     else if (order as OrderForHotel != null)
     {
         //开始结算
         StartCoroutine(CoroutineForAccountingForBed(order as OrderForHotel));
     }
 }
Example #7
0
    /// <summary>
    /// 设置意图
    /// </summary>
    /// <param name="waiterIntent"></param>
    /// <param name="orderForCustomer"></param>
    public void SetIntent(WaiterIntentEnum waiterIntent, OrderForBase order)
    {
        if (gameObject == null)
        {
            return;
        }
        StopAllCoroutines();
        this.waiterIntent = waiterIntent;
        this.order        = order;
        switch (waiterIntent)
        {
        case WaiterIntentEnum.Idle:
            SetIntentForIdle();
            break;

        case WaiterIntentEnum.GoToGetFood:
            SetIntentForGoToGetFood(order as OrderForCustomer);
            break;

        case WaiterIntentEnum.SendFood:
            SetIntentForSendFood(order as OrderForCustomer);
            break;

        case WaiterIntentEnum.GoToCleanTable:
            SetIntentForGoToCleanTable(order as OrderForCustomer);
            break;

        case WaiterIntentEnum.CleaningTable:
            SetIntentForCleaningTable(order as OrderForCustomer);
            break;

        case WaiterIntentEnum.GoToStairsForFirst:
            SetIntentForGoToStairsForFirst();
            break;

        case WaiterIntentEnum.GoToStairsForSecond:
            SetIntentForGoToStairsForSecond();
            break;

        case WaiterIntentEnum.GoToBed:
            SetIntentForGoToBed();
            break;

        case WaiterIntentEnum.CleaningBed:
            SetIntentForCleaningBed();
            break;
        }
    }
Example #8
0
    /// <summary>
    /// 结算所有客户
    /// </summary>
    public void SettlementAllCustomer()
    {
        if (CheckUtil.ListIsNull(listOrder))
        {
            return;
        }
        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();

        for (int i = 0; i < listOrder.Count; i++)
        {
            OrderForBase itemOrder = listOrder[i];
            if (itemOrder == null)
            {
                continue;
            }
            if (itemOrder as OrderForCustomer != null)
            {
                OrderForCustomer orderForCustomer = itemOrder as OrderForCustomer;
                if (orderForCustomer.customer != null &&
                    (orderForCustomer.customer.customerIntent == NpcAICustomerCpt.CustomerIntentEnum.Eatting ||
                     orderForCustomer.customer.customerIntent == NpcAICustomerCpt.CustomerIntentEnum.GotoPay ||
                     orderForCustomer.customer.customerIntent == NpcAICustomerCpt.CustomerIntentEnum.WaitPay ||
                     orderForCustomer.customer.customerIntent == NpcAICustomerCpt.CustomerIntentEnum.Pay))
                {
                    if (orderForCustomer.foodData == null)
                    {
                        continue;
                    }
                    MenuOwnBean menuOwn = gameData.GetMenuById(orderForCustomer.foodData.id);
                    menuOwn.GetPrice(orderForCustomer.foodData, out long payMoneyL, out long payMoneyM, out long payMoneyS);
                    PayMoney(itemOrder, payMoneyL, payMoneyM, payMoneyS, false);
                }
            }
            else if (itemOrder as OrderForHotel != null)
            {
                OrderForHotel orderForHotel = itemOrder as OrderForHotel;
                BuildBedBean  buildBedData  = orderForHotel.bed.buildBedData;
                PayMoney(itemOrder,
                         buildBedData.priceL * orderForHotel.sleepTime,
                         buildBedData.priceM * orderForHotel.sleepTime,
                         buildBedData.priceS * orderForHotel.sleepTime,
                         false);
            }
        }
    }
Example #9
0
    /// <summary>
    /// 设置意图
    /// </summary>
    /// <param name="accountingIntent"></param>
    /// <param name="order"></param>
    public void SetIntent(AccountantIntentEnum accountingIntent, OrderForBase order)
    {
        StopAllCoroutines();
        this.accountantIntent = accountingIntent;
        this.order            = order;
        switch (accountingIntent)
        {
        case AccountantIntentEnum.Idle:
            SetIntentForIdle();
            break;

        case AccountantIntentEnum.GoToAccounting:
            SetIntentForGoToAccounting(order);
            break;

        case AccountantIntentEnum.Accounting:
            SetIntentForAccounting(order);
            break;
        }
    }
Example #10
0
    /// <summary>
    /// 记录顾客 用于顾客正式进店
    /// </summary>
    public void RecordCustomer(OrderForBase order)
    {
        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
        //成就记录
        UserAchievementBean userAchievement = gameData.GetAchievementData();

        if (order as OrderForCustomer != null)
        {
            OrderForCustomer orderForCustomer = order as OrderForCustomer;
            //如果是团队需要记录团队ID
            if (orderForCustomer.customerType == CustomerTypeEnum.Team)
            {
                NpcTeamBean teamData = ((NpcAICustomerForGuestTeamCpt)orderForCustomer.customer).teamData;
                userAchievement.AddNumberForCustomerFood(orderForCustomer.customerType, teamData.id + "", 1);
            }
            else if (orderForCustomer.customerType == CustomerTypeEnum.Friend)
            {
                CharacterBean characterData = ((NpcAICostomerForFriendCpt)orderForCustomer.customer).characterData;
                userAchievement.AddNumberForCustomerFood(orderForCustomer.customerType, characterData.baseInfo.characterId, 1);
            }
            else
            {
                CharacterBean characterData = orderForCustomer.customer.characterData;
                userAchievement.AddNumberForCustomerFood(orderForCustomer.customerType, characterData.baseInfo.characterId, 1);
            }
            //流水记录
            innRecord.AddCutomerForFoodNumber(orderForCustomer.customerType, 1);
        }
        else if (order as OrderForHotel != null)
        {
            OrderForHotel orderForHotel = order as OrderForHotel;
            userAchievement.AddNumberForCustomerHotel(1);
            //流水记录
            innRecord.AddCutomerForHotelNumber(1);
        }
    }
Example #11
0
    /// <summary>
    /// 付钱
    /// </summary>
    /// <param name="food"></param>
    public void PayMoney(OrderForBase order, long payMoneyL, long payMoneyM, long payMoneyS, bool isPlaySound)
    {
        //最小
        if (payMoneyL == 0 && payMoneyM == 0 && payMoneyS == 0)
        {
            payMoneyS = 1;
        }
        GameDataBean        gameData           = GameDataHandler.Instance.manager.GetGameData();
        UserAchievementBean userAchievement    = gameData.GetAchievementData();
        Vector3             payEffectsPosition = Vector3.zero;

        if (order as OrderForCustomer != null)
        {
            OrderForCustomer orderForCustomer = order as OrderForCustomer;
            //账本记录
            innRecord.AddSellNumber(orderForCustomer.foodData.id, 1, payMoneyL, payMoneyM, payMoneyS);
            //根据心情评价客栈 前提订单里有他
            InnPraise(orderForCustomer.innEvaluation.GetPraise());
            //记录+1
            gameData.AddMenuSellNumber(1, orderForCustomer.foodData.id, payMoneyL, payMoneyM, payMoneyS, out bool isMenuLevelUp);
            //成就+1
            userAchievement.AddNumberForCustomerFoodComplete(orderForCustomer.customer.customerType, 1);
            if (isMenuLevelUp)
            {
                Sprite spFoodIcon = InnFoodHandler.Instance.manager.GetFoodSpriteByName(orderForCustomer.foodData.icon_key);
                ToastHandler.Instance.ToastHint(spFoodIcon, string.Format(TextHandler.Instance.manager.GetTextById(1131), orderForCustomer.foodData.name));
            }
            payEffectsPosition = orderForCustomer.customer.transform.position;
        }
        else if (order as OrderForHotel != null)
        {
            OrderForHotel orderForHotel = order as OrderForHotel;
            //账本记录
            innRecord.AddHotelNumber(1, payMoneyL, payMoneyM, payMoneyS);
            //根据心情评价客栈 前提订单里有他
            InnPraise(orderForHotel.innEvaluation.GetPraise());
            //记录+1
            gameData.AddBedSellNumber(
                orderForHotel.bed.buildBedData.remarkId,
                1,
                orderForHotel.sleepTime,
                payMoneyL, payMoneyM, payMoneyS,
                out bool isBedLevelUp);
            //成就+1
            userAchievement.AddNumberForCustomerHotelComplete(1);
            if (isBedLevelUp)
            {
                Sprite spBedIcon = IconDataHandler.Instance.manager.GetIconSpriteByName("worker_waiter_bed_pro_2");
                ToastHandler.Instance.ToastHint(spBedIcon, string.Format(TextHandler.Instance.manager.GetTextById(1131), orderForHotel.bed.buildBedData.bedName));
            }
            payEffectsPosition = orderForHotel.customer.transform.position;
        }

        //金钱增加
        GameDataHandler.Instance.AddMoney(payMoneyL, payMoneyM, payMoneyS, payEffectsPosition);
        //播放音效
        if (isPlaySound)
        {
            AudioHandler.Instance.PlaySound(AudioSoundEnum.PayMoney);
            //展示特效
            //innPayHandler.ShowPayEffects(payEffectsPosition, payMoneyL, payMoneyM, payMoneyS);
        }
    }
Example #12
0
 public void StartAccounting(OrderForBase order)
 {
     SetIntent(AccountantIntentEnum.GoToAccounting, order);
 }
Example #13
0
    public IEnumerator CoroutineForAccountingForBed(OrderForHotel orderForHotel)
    {
        float time = npcAIWorker.characterData.CalculationAccountingTime();

        yield return(new WaitForSeconds(time));

        orderForHotel.bed.GetPrice(out long basePriceS, out long addPriceS);
        long payMoneyL = 0;
        long payMoneyM = 0;
        long payMoneyS = basePriceS + addPriceS;
        //是否出错
        bool isError = npcAIWorker.characterData.CalculationAccountingCheck(out float moreRate);

        long AddMoneyL = (long)(moreRate * payMoneyL);
        long AddMoneyM = (long)(moreRate * payMoneyM);
        long AddMoneyS = (long)(moreRate * payMoneyS);

        if (isError)
        {
            //出错
            //记录数据
            payMoneyL -= AddMoneyL;
            payMoneyM -= AddMoneyM;
            payMoneyS -= AddMoneyS;

            npcAIWorker.characterData.baseInfo.accountantInfo.AddAccountantFail
            (
                payMoneyL, payMoneyM, payMoneyS,
                AddMoneyL, AddMoneyM, AddMoneyS
            );
            //增加经验
            npcAIWorker.characterData.baseInfo.accountantInfo.AddExp(1, out bool isLevelUp);
            if (isLevelUp)
            {
                ToastForLevelUp(WorkerEnum.Accountant);
            }

            //工作者表示抱歉
            npcAIWorker.SetExpression(CharacterExpressionCpt.CharacterExpressionEnum.Wordless);
            //顾客生气
            orderForHotel.customer.SetExpression(CharacterExpressionCpt.CharacterExpressionEnum.Mad);
        }
        else
        {
            //成功
            payMoneyL += AddMoneyL;
            payMoneyM += AddMoneyM;
            payMoneyS += AddMoneyS;
            //记录数据
            npcAIWorker.characterData.baseInfo.accountantInfo.AddAccountantSuccess
            (
                payMoneyL, payMoneyM, payMoneyS,
                AddMoneyL, AddMoneyM, AddMoneyS
            );
            //增加经验
            npcAIWorker.characterData.baseInfo.accountantInfo.AddExp(1, out bool isLevelUp);
            if (isLevelUp)
            {
                ToastForLevelUp(WorkerEnum.Accountant);
            }
            //如果有额外的加成 工作者和店员都应该高兴
            //orderForCustomer.customer.SetExpression(CharacterExpressionCpt.CharacterExpressionEnum.Love);
        }
        //加上小时数
        payMoneyL *= orderForHotel.sleepTime;
        payMoneyM *= orderForHotel.sleepTime;
        payMoneyS *= orderForHotel.sleepTime;

        InnHandler.Instance.PayMoney(orderForHotel, payMoneyL, payMoneyM, payMoneyS, true);
        //结束订单
        InnHandler.Instance.EndOrder(orderForHotel);

        //检测该柜台是否还有订单并且依旧没有取消改职业。如果有的话继续结账
        //用于中断连续结账
        CharacterWorkerBaseBean characterWorkerData = npcAIWorker.characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Accountant);

        if (characterWorkerData.isWorking && orderForHotel.counter.payQueue.Count != 0)
        {
            OrderForBase newOrder = orderForHotel.counter.payQueue[0];
            orderForHotel.counter.payQueue.Remove(newOrder);
            StartAccounting(newOrder);
        }
        else
        {
            SetIntent(AccountantIntentEnum.Idle);
        }

        //通知离开
        orderForHotel.customer.SetIntent(NpcAICustomerForHotelCpt.CustomerHotelIntentEnum.Leave);
    }
Example #14
0
 /// <summary>
 /// 设置结账
 /// </summary>
 /// <param name="customerCpt"></param>
 public void SetIntentForAccounting(OrderForBase order)
 {
     aiForAccountant.StartAccounting(order);
 }