Exemplo n.º 1
0
 void Start()
 {
     marker                = transform.parent.GetChild(1).gameObject;
     playerState           = transform.parent.GetComponentInChildren <PlayerCharacterAnimation>();
     pointerMarker         = GetComponentInChildren <SpriteRenderer>();
     preState              = false;
     pointerMarker.enabled = false;
 }
Exemplo n.º 2
0
    void ProcessingEvent()  //플레이어(클릭)에 대한 이벤트 처리
    {
        if (targetPlayer.GetComponent <MyCharacterMove>().GetTargetGround() != accessGround)
        {   //대상 플레이어의 목적지가 바뀌면
            doWork       = false;
            timer        = 0.0f;
            targetPlayer = null;
            return;
        }

        if (targetPlayer.transform.position == accessGround.transform.position)
        {   //플레이어가 도착하면
            switch (stateOfTable)
            {
            //더러운 상태일 때 처리
            case T_STATE.DIRTY:
            {
                //플레이어가 서빙중이라면 예외처리
                if (targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isServing)
                {
                    doWork       = false;
                    timer        = 0.0f;
                    targetPlayer = null;
                    return;
                }

                targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isScrubbing = true;
                timer += Time.deltaTime;
                if (timer >= timeToScrub)
                {
                    doWork       = false;
                    stateOfTable = T_STATE.CLEAR;
                    targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isScrubbing = false;
                    targetPlayer = null;
                    timer        = 0.0f;
                }
                break;
            }

            //사용중 상태일 때 처리
            case T_STATE.USING:
            {
                //플레이어가 서빙중이라면 예외처리
                if (targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isServing)
                {
                    doWork       = false;
                    timer        = 0.0f;
                    targetPlayer = null;
                    return;
                }

                if (isGuestOrder && orderMenus.Count > 0)
                {           //주문할 메뉴가 정해져 있다면
                    timer += Time.deltaTime;
                    targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isTakeOrder = true;
                    if (timer >= timeToOrder)
                    {
                        targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>().isTakeOrder = false;

                        for (int i = 0; i < guestGroup.Count; i++)
                        {           //그룹에 속한 손님들의 상태를 WAIT로 전환
                            guestGroup[i].GetComponent <GuestAction>().SetCurrentState(G_STATE.WAIT);
                        }
                        targetPlayer.GetComponent <PlayerConfig>().TakeOrderToPlayer(gameObject, orderMenus);

                        //테이블 상태를 WAITING으로 변경하고 변수들 초기화
                        stateOfTable = T_STATE.WAITING;
                        doWork       = false;
                        isGuestOrder = false;
                        targetPlayer = null;
                    }
                }
                break;
            }

            //대기중 상태일 때 처리
            case T_STATE.WAITING:
            {
                PlayerCharacterAnimation playerState  = targetPlayer.GetComponentInChildren <PlayerCharacterAnimation>();
                PlayerConfig             playerConfig = targetPlayer.GetComponent <PlayerConfig>();
                //플레이어가 서빙 상태이고 주문을 시킨 테이블이 이 테이블 일 때
                if (playerState.isServing &&
                    playerConfig.servingOrder.table == gameObject)
                {
                    playerState.isServing     = false;
                    playerConfig.servingOrder = null;

                    //그룹에 속한 손님들의 상태를 EAT로 전환
                    for (int i = 0; i < guestGroup.Count; i++)
                    {
                        guestGroup[i].GetComponent <GuestAction>().SetCurrentState(G_STATE.EAT);
                    }
                }

                break;
            }
            }
        }   //플레이어의 처리 완료
    }