Esempio n. 1
0
    /// <summary>
    /// 获取人少的柜台
    /// </summary>
    /// <param name="position"></param>
    /// <returns></returns>
    public BuildCounterCpt GetLessCounter()
    {
        BuildCounterCpt lessCounter = null;
        int             number      = int.MaxValue;

        for (int i = 0; i < listCounterCpt.Count; i++)
        {
            BuildCounterCpt itemCounter = listCounterCpt[i];
            if (number > itemCounter.payQueue.Count)
            {
                lessCounter = itemCounter;
                number      = itemCounter.payQueue.Count;
            }
            else if (number == itemCounter.payQueue.Count)
            {
                int randomTemp = Random.Range(0, 2);
                if (randomTemp == 0)
                {
                    lessCounter = itemCounter;
                    number      = itemCounter.payQueue.Count;
                }
            }
        }
        return(lessCounter);
    }
Esempio n. 2
0
 /// <summary>
 /// 清理所有柜台
 /// </summary>
 public void CleanAllCounter()
 {
     if (listCounterCpt == null)
     {
         return;
     }
     for (int i = 0; i < listCounterCpt.Count; i++)
     {
         BuildCounterCpt buildCounterCpt = listCounterCpt[i];
         buildCounterCpt.ClearCounter();
     }
     ;
 }
Esempio n. 3
0
    /// <summary>
    /// 获取柜台
    /// </summary>
    /// <returns></returns>
    public BuildCounterCpt GetCounter(Vector3 position)
    {
        BuildCounterCpt counterCpt = null;
        GameConfigBean  gameConfig = GameDataHandler.Instance.manager.GetGameConfig();

        if (gameConfig.statusForCheckOut == 0)
        {
            //选择最近的柜台
            counterCpt = innPayHandler.GetCloseCounter(position);
        }
        else if (gameConfig.statusForCheckOut == 1)
        {
            //随机选择一个柜台
            counterCpt = RandomUtil.GetRandomDataByList(innPayHandler.listCounterCpt);
        }
        else
        {
            //选择人少柜台
            counterCpt = innPayHandler.GetLessCounter();
        }
        return(counterCpt);
    }
Esempio n. 4
0
    /// <summary>
    /// 获取最近的柜台
    /// </summary>
    /// <param name="npcAICustomer"></param>
    /// <returns></returns>
    public BuildCounterCpt GetCloseCounter(Vector3 position)
    {
        BuildCounterCpt closeCounter = null;
        float           minDistance  = 0;

        for (int i = 0; i < listCounterCpt.Count; i++)
        {
            BuildCounterCpt itemCounter = listCounterCpt[i];
            float           distance    = Vector3.Distance(position, itemCounter.transform.position);
            if (minDistance == 0)
            {
                minDistance  = distance;
                closeCounter = itemCounter;
            }
            else if (distance < minDistance)
            {
                minDistance  = distance;
                closeCounter = itemCounter;
            }
        }
        return(closeCounter);
    }
Esempio n. 5
0
    /// <summary>
    /// 通过不同的工作类型分配不同的工作
    /// </summary>
    public bool DistributionWorkForType(WorkerDetilsEnum workDetailsType, NpcAIWorkerCpt workNpc)
    {
        switch (workDetailsType)
        {
        case WorkerDetilsEnum.AccountantForPay:
            if (!CheckUtil.ListIsNull(innPayHandler.listCounterCpt))
            {
                for (int i = 0; i < innPayHandler.listCounterCpt.Count; i++)
                {
                    BuildCounterCpt counterCpt = innPayHandler.listCounterCpt[i];
                    if (!CheckUtil.ListIsNull(counterCpt.payQueue))
                    {
                        bool isSuccess = innPayHandler.SetPay(counterCpt.payQueue[0], workNpc);
                        if (isSuccess)
                        {
                            counterCpt.payQueue.RemoveAt(0);
                            return(true);
                        }
                    }
                }
            }
            break;

        case WorkerDetilsEnum.ChefForCook:
            //排队做菜处理
            if (!CheckUtil.ListIsNull(foodQueue))
            {
                bool isSuccess = innCookHandler.SetChefForCook(foodQueue[0], workNpc);
                if (isSuccess)
                {
                    foodQueue.RemoveAt(0);
                    return(true);
                }
            }
            break;

        case WorkerDetilsEnum.WaiterForSend:
            //排队送菜处理
            if (!CheckUtil.ListIsNull(sendQueue))
            {
                OrderForCustomer orderForSend = sendQueue[0];
                bool             isSuccess    = innWaiterHandler.SetSendFood(orderForSend, workNpc);
                if (isSuccess)
                {
                    sendQueue.Remove(orderForSend);
                    return(true);
                }
            }
            break;

        case WorkerDetilsEnum.WaiterForCleanTable:
            //排队清理处理
            if (!CheckUtil.ListIsNull(cleanQueue))
            {
                //搜寻最近的桌子
                OrderForCustomer clearItem = null;
                float            distance  = float.MaxValue;
                for (int i = 0; i < cleanQueue.Count; i++)
                {
                    OrderForCustomer itemOrder    = cleanQueue[i];
                    float            tempDistance = Vector3.Distance(itemOrder.table.GetTablePosition(), workNpc.transform.position);
                    if (tempDistance < distance)
                    {
                        distance  = tempDistance;
                        clearItem = itemOrder;
                    }
                }
                if (clearItem == null)
                {
                    return(false);
                }
                bool isSuccess = innWaiterHandler.SetCleanFood(clearItem, workNpc);
                if (isSuccess)
                {
                    cleanQueue.Remove(clearItem);
                    return(true);
                }
            }
            break;

        case WorkerDetilsEnum.WaiterForCleanBed:
            //排队床单清理处理
            if (!CheckUtil.ListIsNull(bedCleanQueue))
            {
                OrderForHotel orderForHotel = bedCleanQueue[0];
                bool          isSuccess     = innWaiterHandler.SetCleanBed(orderForHotel, workNpc);
                if (isSuccess)
                {
                    bedCleanQueue.Remove(orderForHotel);
                    return(true);
                }
            }
            break;

        case WorkerDetilsEnum.AccostForSolicit:
            workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.AccostSolicit);
            return(true);

        case WorkerDetilsEnum.AccostForGuide:
            //等待接待
            if (!CheckUtil.ListIsNull(hotelQueue))
            {
                OrderForHotel orderForHotel = hotelQueue[0];
                workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.AccostGuide, orderForHotel);
                hotelQueue.Remove(orderForHotel);
                return(true);
            }
            break;

        case WorkerDetilsEnum.BeaterForDrive:
            //分派打架人选
            if (!CheckUtil.ListIsNull(rascalrQueue))
            {
                NpcAIRascalCpt npcAIRascal = innFightHandler.SetFight(rascalrQueue, workNpc);
                if (npcAIRascal)
                {
                    //rascalrQueue.Remove(npcAIRascal);
                    return(true);
                }
            }
            break;
        }
        return(false);
    }
Esempio n. 6
0
    /// <summary>
    /// 通过ID获取家具Obj
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public GameObject GetFurnitureObjById(InnResBean furnitureData, Transform tfFather, BuildBedBean buildBedData)
    {
        BuildItemBean    buildItemData     = GetBuildDataById(furnitureData.id);
        GameObject       furnitureObjModel = GetModel(dicFurnitureCpt, "model/furniture", buildItemData.model_name);
        GameObject       furnitureObj      = Instantiate(tfFather.gameObject, furnitureObjModel);
        BaseBuildItemCpt buildItemCpt      = furnitureObj.GetComponent <BaseBuildItemCpt>();
        List <string>    listIcon          = buildItemData.GetIconList();

        switch ((BuildItemTypeEnum)buildItemData.build_type)
        {
        case BuildItemTypeEnum.Counter:
            BuildCounterCpt buildCounter   = (BuildCounterCpt)buildItemCpt;
            Sprite          spLeftCounter  = GetFurnitureSpriteByName(listIcon[0] + "_0");
            Sprite          spRightCounter = GetFurnitureSpriteByName(listIcon[0] + "_1");
            Sprite          spDownCounter  = GetFurnitureSpriteByName(listIcon[0] + "_2");
            Sprite          spUpCounter    = GetFurnitureSpriteByName(listIcon[0] + "_3");
            buildCounter.SetData(buildItemData, spLeftCounter, spRightCounter, spDownCounter, spUpCounter);
            break;

        case BuildItemTypeEnum.Stove:
            BuildStoveCpt buildStove   = (BuildStoveCpt)buildItemCpt;
            Sprite        spLeftStove  = GetFurnitureSpriteByName(listIcon[0] + "_0");
            Sprite        spRightStove = GetFurnitureSpriteByName(listIcon[0] + "_1");
            Sprite        spDownStove  = GetFurnitureSpriteByName(listIcon[0] + "_2");
            Sprite        spUpStove    = GetFurnitureSpriteByName(listIcon[0] + "_3");
            buildStove.SetData(buildItemData, spLeftStove, spRightStove, spDownStove, spUpStove);
            break;

        case BuildItemTypeEnum.Table:
            BuildTableCpt buildTable = (BuildTableCpt)buildItemCpt;

            Sprite spLeftChair  = GetFurnitureSpriteByName(listIcon[1] + "_0");
            Sprite spRightChair = GetFurnitureSpriteByName(listIcon[1] + "_1");
            Sprite spDownChair  = GetFurnitureSpriteByName(listIcon[1] + "_2");
            Sprite spUpChair    = GetFurnitureSpriteByName(listIcon[1] + "_3");

            if (buildItemData.model_name.Equals("Table_1"))
            {
                Sprite spTable = GetFurnitureSpriteByName(listIcon[0]);
                buildTable.SetData(buildItemData, spTable, spLeftChair, spRightChair, spDownChair, spUpChair);
            }
            else if (buildItemData.model_name.Equals("Table_2"))
            {
                Sprite spLeftTable  = GetFurnitureSpriteByName(listIcon[0] + "_0");
                Sprite spRightTable = GetFurnitureSpriteByName(listIcon[0] + "_1");
                Sprite spDownTable  = GetFurnitureSpriteByName(listIcon[0] + "_2");
                Sprite spUpTable    = GetFurnitureSpriteByName(listIcon[0] + "_3");
                buildTable.SetData(buildItemData, spLeftTable, spRightTable, spDownTable, spUpTable, spLeftChair, spRightChair, spDownChair, spUpChair);
            }

            break;

        case BuildItemTypeEnum.Decoration:
            BuildDecorationCpt buildDecoration = (BuildDecorationCpt)buildItemCpt;
            Sprite             spDecoration    = GetFurnitureSpriteByName(buildItemData.icon_key);
            buildDecoration.SetData(buildItemData, spDecoration);
            break;

        case BuildItemTypeEnum.Door:
            BuildDoorCpt buildDoor = (BuildDoorCpt)buildItemCpt;
            Sprite       spDoor    = GetFurnitureSpriteByName(listIcon[0]);
            buildDoor.SetData(buildItemData, spDoor);
            break;

        case BuildItemTypeEnum.Floor:
            BuildFloorCpt buildFloor = (BuildFloorCpt)buildItemCpt;
            Sprite        spFloor    = GetFloorSpriteByName(buildItemData.icon_key);
            buildFloor.SetData(buildItemData, spFloor);
            break;

        case BuildItemTypeEnum.Wall:
            BuildWallCpt buildWall = (BuildWallCpt)buildItemCpt;
            Sprite       spWall    = GetWallSpriteByName(buildItemData.icon_key);
            buildWall.SetData(buildItemData, spWall);
            break;

        case BuildItemTypeEnum.Bed:
            BuildBedCpt buildBed = (BuildBedCpt)buildItemCpt;
            buildBed.SetData(buildItemData, buildBedData);
            break;

        case BuildItemTypeEnum.Stairs:
            BuildStairsCpt buildStairs = (BuildStairsCpt)buildItemCpt;
            buildStairs.SetData(buildItemData);
            buildStairs.SetRemarkId(furnitureData.remarkId);
            if (furnitureData.remark != null && furnitureData.remark.Equals("1"))
            {
                buildStairs.SetLayer(1);
            }
            else
            {
                buildStairs.SetLayer(2);
            }
            break;

        default:
            buildItemCpt.SetData(buildItemData);
            break;
        }
        return(furnitureObj);
    }