예제 #1
0
    new void Awake()
    {
        Debug.Log("*** GUEST ***");

        Assert.IsNotNull(context);

        state = GuestState.LoggingIn;

        InitializePlatformSDK(GetEntitlementCallback);

        Matchmaking.SetMatchFoundNotificationCallback(MatchFoundCallback);

        Rooms.SetUpdateNotificationCallback(RoomUpdatedCallback);

        Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);

        Net.SetPeerConnectRequestCallback(PeerConnectRequestCallback);

        Net.SetConnectionStateChangedCallback(ConnectionStateChangedCallback);

        Voip.SetVoipConnectRequestCallback((Message <NetworkingPeer> msg) =>
        {
            Debug.Log("Accepting voice connection from " + msg.Data.ID);
            Voip.Accept(msg.Data.ID);
        });

        Voip.SetVoipStateChangeCallback((Message <NetworkingPeer> msg) =>
        {
            Debug.LogFormat("Voice state changed to {1} for user {0}", msg.Data.ID, msg.Data.State);
        });
    }
예제 #2
0
    protected new void FixedUpdate()
    {
        base.FixedUpdate();
        //if (state != GuestState.JoinAndWait)
        //	print (state);
        switch (state)
        {
        case GuestState.FirstGo2Chair:
            if (ownChair != null)
            {
                if (ownChair.isFull)
                {
                    state = GuestState.Want2Eat;
                }
            }
            break;

        // Check state is 'Want2Eat'
        case GuestState.Want2Eat:
            // if don't have food
            // then take food
            // Start State machine
            StartCoroutine(LetsTakeFood());
            break;
        }

        if (isAngry)
        {
            belongGroup.StandUpTableWithAngry();
        }
    }
예제 #3
0
    IEnumerator StartEat()
    {
        state = GuestState.Eat;
        Say(ScriptM.eatting);
        dishForEat.EatFoodThisGuest(this);
        // Eat all?
        yield return(new WaitForSeconds(1));

        Say(ScriptM.doneEatting);
        // Dish place to EatupPoint
        ownChair.rootTable.PlaceEatUpPoint(dishForEat);

        yield return(new WaitForSeconds(1));

        // If is hungry yet
        if (hungryAmount > 0)
        {
            yield return(LetsTakeFood());
        }
        // Else
        else
        {               // Leave restaurant
            yield return(GoEntryTableThenPayMoney());
        }
    }
예제 #4
0
 void OnCollisionEnter(Collision other)
 {
     if (isFalling)
     {
         isFalling  = false;
         guestState = GuestState.Vampier;
     }
 }
예제 #5
0
    void WalkIn()
    {
        consumer.EnablePlayerInteraction(false);
        CurrentState = GuestState.WaitingAtTheDoor;

        lastRingTime = -Mathf.Infinity;

        RingTillDoorIsOpen();
    }
예제 #6
0
 void ConnectToServer(int id)
 {
     Assert.IsTrue(id >= 1);
     Assert.IsTrue(id < MaxClients);
     localAvatar.transform.position = context.GetAvatar(id).gameObject.transform.position;
     localAvatar.transform.rotation = context.GetAvatar(id).gameObject.transform.rotation;
     state    = Connected;
     clientId = id;
     context.Init(id);
     OnConnectToServer(id);
 }
예제 #7
0
파일: Guest.cs 프로젝트: SonGit/NailGame
    void StandUp()
    {
        _state = GuestState.STAND_UP;

        iTween.MoveTo(_anim.gameObject, iTween.Hash("position", (_anim.transform.localPosition + new Vector3(0, 10, 0)),
                                                    "easetype", iTween.EaseType.easeInSine,
                                                    "islocal", true,
                                                    "time", 0.5f,
                                                    "oncomplete", "WalkOut",
                                                    "oncompletetarget", this.gameObject));
    }
예제 #8
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void WalkOut()
	{
		_state = GuestState.WALK_OUT;

		_anim.transform.localPosition = Vector3.zero;
		iTween.MoveTo(_anim.gameObject,iTween.Hash("position", new Vector3(-1000,0,0),
												"easetype",iTween.EaseType.easeInSine,
												"islocal",true,
												"time",3f,
												"oncomplete" , "OnEndWalkOut",
												"oncompletetarget" , this.gameObject));
	}
예제 #9
0
파일: Guest.cs 프로젝트: SonGit/NailGame
    void WalkOut()
    {
        _state = GuestState.WALK_OUT;

        _anim.transform.localPosition = Vector3.zero;
        iTween.MoveTo(_anim.gameObject, iTween.Hash("position", new Vector3(-1000, 0, 0),
                                                    "easetype", iTween.EaseType.easeInSine,
                                                    "islocal", true,
                                                    "time", 3f,
                                                    "oncomplete", "OnEndWalkOut",
                                                    "oncompletetarget", this.gameObject));
    }
예제 #10
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void WalkIn()
	{
		_state = GuestState.WALK_IN;

		_anim.transform.localPosition = new Vector3 ( DEFAULT_X_POS, 0 , BACK_CHAIR_Z );

		iTween.MoveTo(_anim.gameObject,iTween.Hash("position",Vector3.zero,
												   "easetype",iTween.EaseType.easeInSine,
												   "islocal",true,
												   "time",3f,
											       "oncomplete" , "OnEndWalkIn",
												   "oncompletetarget" , this.gameObject));
	}
예제 #11
0
    void StartMatchmaking()
    {
        var options = new MatchmakingOptions();

        options.SetEnqueueQueryKey("quickmatch_query");
        options.SetCreateRoomJoinPolicy(RoomJoinPolicy.Everyone);
        options.SetCreateRoomMaxUsers(MaxClients);
        options.SetEnqueueDataSettings("version", Constants.Version.GetHashCode());

        Matchmaking.Enqueue2("quickmatch", options).OnComplete(MatchmakingEnqueueCallback);
        timeMatchmakingStarted = renderTime;
        state = InMatchmaking;
    }
예제 #12
0
파일: Guest.cs 프로젝트: SonGit/NailGame
    void WalkIn()
    {
        _state = GuestState.WALK_IN;

        _anim.transform.localPosition = new Vector3(DEFAULT_X_POS, 0, BACK_CHAIR_Z);

        iTween.MoveTo(_anim.gameObject, iTween.Hash("position", Vector3.zero,
                                                    "easetype", iTween.EaseType.easeInSine,
                                                    "islocal", true,
                                                    "time", 3f,
                                                    "oncomplete", "OnEndWalkIn",
                                                    "oncompletetarget", this.gameObject));
    }
예제 #13
0
    void RetryUntilConnectedToServer()
    {
        Matchmaking.Cancel();
        DisconnectFromServer();
        if (isConnected)
        {
            return;
        }

        Debug.Log("Retrying in " + RetryTime + " seconds...");
        timeRetryStarted = renderTime;
        state            = WaitingForRetry;
    }
예제 #14
0
    // OK!! Let's take some food
    // First take a dish
    IEnumerator LetsTakeFood()
    {
        state = GuestState.TakeDish;
        Say("Take Dish!");
        yield return(new WaitForSeconds(.5f));

        // Let's take Dish
        var tDishTable = DishTable.allDishTables[0];

        // If Don't have more dishes??
        // This guy will be angry
        GoToSocketAndUse(TakeDishFormDishTable, tDishTable, tDishTable.socket);
        yield return(new WaitUntil(() => isReachToPoint));

        yield return(new WaitForSeconds(.5f));

        if (isAngry)
        {
            yield break;
        }
        // Taked dish

        if (dishes.Count == 0)
        {
            Say("접시 어디??");
            GoToSocketAndUse(ownChair);
            yield return(new WaitUntil(() => isReachToPoint));

            yield return(LetsTakeFood());
        }
        // Let's take Food
        state = GuestState.TakeFood;
        Say("음식가져와야지");
        var tFood = PerferFoodM.self.GetRandomFood();

        GoToSocketAndUse(TakeFood, tFood, tFood.socket);
        yield return(new WaitUntil(() => isReachToPoint));

        // Taked Food on dish

        // Get back to your own chair
        // He can Throw dish on Ground
        // ownChair can be null
        GoToSocketAndUse(ownChair);
        yield return(new WaitUntil(() => isReachToPoint));

        dishForEat         = ThrowAwayDish(ownChair.GetDishPoint());
        dishForEat.isClean = false;

        yield return(StartEat());
    }
예제 #15
0
    private void GoHome(bool wasSitting = true)
    {
        consumer.EnablePlayerInteraction(false);

        Debug.Log(sittingIndex + " Going home");
        CurrentState = GuestState.GoingOut;
        if (wasSitting)
        {
            GuestManager.I.SittingPlaceAvailable(this, sittingIndex);
        }

        AI.GoToExit();
        followAI = true;
    }
예제 #16
0
    IEnumerator GoEntryTableThenPayMoney()
    {
        state = GuestState.Want2Exit;
        Say("갈시간이네");
        belongGroup.StandUpTable(this);
        yield return(new WaitUntil(() => belongGroup.state == GuestGroup.GuestGroupState.Want2Exit));

        GoToSocketAndUse(EntryTable.self);
        yield return(new WaitUntil(() => isReachToPoint));

        Say("Take my money!");
        belongGroup.state = GuestGroup.GuestGroupState.Exit;
        state             = GuestState.Exit;
        yield return(LeaveRestaurant());
    }
예제 #17
0
    void DisconnectFromServer()
    {
        if (IsConnectedToServer())
        {
            ResetContext();
        }

        Net.Close(hostUserId);
        LeaveRoom(roomId, LogLeaveRoomResult);
        roomId     = 0;
        hostUserId = 0;
        state      = Disconnected;
        info.Clear();
        connections.Clear();
        isConnectionAccepted = false;
    }
예제 #18
0
    void ConnectToServer(int clientIndex)
    {
        Assert.IsTrue(clientIndex >= 1);
        Assert.IsTrue(clientIndex < Constants.MaxClients);

        localAvatar.transform.position = context.GetRemoteAvatar(clientIndex).gameObject.transform.position;
        localAvatar.transform.rotation = context.GetRemoteAvatar(clientIndex).gameObject.transform.rotation;

        state = GuestState.Connected;

        this.clientIndex = clientIndex;

        context.Initialize(clientIndex);

        OnConnectToServer(clientIndex);
    }
예제 #19
0
    private void TransfromToBat()
    {
        InstaniateSmoke();

        //ChangeRenderView(1);

        SetTransformToBat();
        guestState = GuestState.Bat;

        gameObject.transform.DOMoveY(
            transform.position.y + floatDistance, 2f).SetEase(Ease.Linear);

        Vector3 targetCameraTransform = playerCamera.transform.localPosition - Vector3.forward * zoomOutDistance;

        playerCamera.transform.DOLocalMove(
            targetCameraTransform, 1f).SetEase(Ease.OutExpo);
    }
예제 #20
0
    void DisconnectFromServer()
    {
        if (IsConnectedToServer())
        {
            OnDisconnectFromServer();
        }

        Net.Close(hostUserId);

        LeaveRoom(roomId, LeaveRoomCallback);

        roomId = 0;

        hostUserId = 0;

        state = GuestState.Disconnected;

        serverInfo.Clear();

        connectionRequests.Clear();

        acceptedConnectionRequest = false;
    }
예제 #21
0
파일: Guest.cs 프로젝트: SonGit/NailGame
 void OnEndWalkIn()
 {
     _anim.transform.localPosition += new Vector3(0, 50, FRONT_CHAIR_Z);
     _state = GuestState.SIT_DOWN;
 }
예제 #22
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void OnEndSitdown()
	{
		_state = GuestState.IDLE;
		Invoke ("EnableBalloon",.25f);
	}
예제 #23
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void StandUp()
	{
		_state = GuestState.STAND_UP;
	
		iTween.MoveTo(_anim.gameObject,iTween.Hash("position", (_anim.transform.localPosition + new Vector3(0,10,0)),
			"easetype",iTween.EaseType.easeInSine,
			"islocal",true,
			"time",0.5f,
			"oncomplete" , "WalkOut",
			"oncompletetarget" , this.gameObject));
	}
예제 #24
0
    private void Update()
    {
        if (!Application.isPlaying || GameController.I.IsPaused)
        {
            return;
        }

        // Follow guest

        if (followAI)
        {
            transform.position = AI.transform.position + Vector3.up;
        }

        if (!isMarina)
        {
            if (Promaja.IsActive)
            {
                if (Time.time - lastPromajaReaction > timeBetweenPromajaReactions)
                {
                    lastPromajaReaction         = Time.time;
                    timeBetweenPromajaReactions = Random.Range(5.0f, 10.0f);
                    if (Random.value > 0.5f) // not all guests should react
                    {
                        GuestManager.I.ShowPromajaQuip(this);
                    }
                }

                //lastPromajaReaction 1
            }

            if (Fleka.Prljavo)
            {
                if (Time.time - lastPrljavoReaction > timeBetweenPrljavoReactions)
                {
                    lastPrljavoReaction         = Time.time;
                    timeBetweenPrljavoReactions = Random.Range(5.0f, 10.0f);
                    if (Random.value > 0.5f)
                    {
                        GuestManager.I.ShowPrljavoQuip(this);
                    }
                }
            }
        }

        switch (CurrentState)
        {
        case GuestState.WaitingAtTheDoor:
            RingTillDoorIsOpen();
            DoMoveFlipping();

            if (Database.e.entranceDoor.IsOpen)
            {
                if (!isMarina)
                {
                    GuestManager.I.ShowEntryMessage(this);
                }
                CurrentState = GuestState.Entered;
            }
            break;

        case GuestState.Entered:
            DoMoveFlipping();

            if (isMarina)
            {
                AI.GoToSeat();
                CurrentState = GuestState.WalkingIn;
            }
            // Wait for the domacin to open the door
            else if (IsCloseTo(AI.zitoDestination.position, ZITO_RANGE))
            {
                CurrentState = GuestState.WaitingForZito;
                AI.Stop();
                consumer.EnablePlayerInteraction(true);

                if (entryWish == null)
                {
                    entryWish = new GuestWish(GuestWish.GuestWishType.Zito, 30f);
                    AllWishes.Insert(0, entryWish);
                    entryWish.ActivateWish();
                }
            }
            break;

        case GuestState.WalkingIn:
            DoMoveFlipping();

            if (IsCloseTo(seat.transform.position))
            {
                Sit();
                Delay(Random.Range(0f, 2f) * InitialDelay);
            }
            break;

        case GuestState.GoingOut:

            if (Vector3.Distance(transform.position, AI.exitDestination.position) < 1.5f)
            {
                CurrentState = GuestState.Exit;
            }
            return;

        case GuestState.Exit:
            if (!isFadeOut)
            {
                isFadeOut = true;
                Debug.Log(sittingIndex + " BYE!");
                StartCoroutine(DelayDestroy(1.2f));
            }
            break;

        case GuestState.Delay:
            // currently delayed after the wish
            timeForNewWish -= Time.deltaTime;
            if (timeForNewWish <= 0f)
            {
                Debug.Log(sittingIndex + " end delay, new wish");
                RequestingWish();
            }
            break;

        case GuestState.WaitingForZito:
        case GuestState.WaitingForService:
            var currentWish = CurrentWish;

            // update all wishes
            for (int i = 0; i < AllWishes.Count; i++)
            {
                AllWishes[i].UpdateWish(Time.deltaTime);
            }

            // check if there is no current wish
            if (currentWish == null)
            {
                // if wishes count is at max, leave
                if (AllWishes.Count == NumberOfWishes)
                {
                    GoHome();
                }
                else
                {
                    GenerateNewWish();
                }
            }
            else if (currentWish.IsFinished)
            {
                Debug.Log(sittingIndex + " Timeout active wish, start delay");

                bool wasWaitingForZito = CurrentState == GuestState.WaitingForZito;

                // Timeout
                if (currentWish.IsSuccess.Value == false)
                {
                    Debug.LogWarning($"Wish {currentWish.Type} has timed out!");

                    string quipText = "";
                    if (currentWish.IsWindowWish || currentWish.IsTvWish)
                    {
                        Debug.Log("Was window tv wish");

                        WishQuip quip = GuestManager.I.GetWishQuip(currentWish.Type);
                        Debug.Assert(quip != null, "Quip is null");
                        quipText = quip ? quip.GetToolate() : "";
                    }
                    else if (currentWish.IsFoodWish || currentWish.IsDrinkWish)
                    {
                        Debug.Log("Was drink food wish");

                        //var container = currentWish.IsDrinkWish ? consumer.drinkContainer : consumer.foodContainer;
                        Consumable.Quips q = null;
                        foreach (var consumable in Database.e.consumables)
                        {
                            if (consumable.wishType == currentWish.Type)
                            {
                                q = consumable.quips;
                                break;
                            }
                        }

                        //Consumable.Quips q = container.type.quips;
                        Debug.Assert(q != null, "Quip is null");
                        quipText = q.tooLate[Random.Range(0, q.tooLate.Length)];
                    }

                    Debug.Assert(currentWish != null, "Current wish is null before");
                    Debug.Assert(!string.IsNullOrEmpty(quipText), "No quip text");
                    FinishActiveWish(success: false, message: quipText, currentWish);
                    Delay(DelayAfterWish);
                }

                if (wasWaitingForZito)
                {
                    //if (entryWish.IsSuccess.HasValue) // && entryWish.IsSuccess.Value
                    //{
                    Debug.Log($"Waiting for zito completed with {entryWish.IsSuccess.Value}");

                    // go in
                    //AllWishes.RemoveAt(0);

                    /*
                     * if (!entryWish.IsSuccess.Value)
                     * {
                     *  //entryWish.FinishWish(false);
                     *  WishQuip quip = GuestManager.I.GetWishQuip(currentWish.Type);
                     *  string quipText = quip ? quip.GetSuccess() : "";
                     *
                     *  FinishActiveWish(message: quipText);
                     * }*/

                    AI.GoToSeat();
                    followAI = true;
                    consumer.EnablePlayerInteraction(false);
                    CurrentState = GuestState.WalkingIn;

                    if (hasDirtyShoes)
                    {
                        StartCoroutine(MakeFleka(Random.Range(1.2f, 3f)));
                    }
                    //}
                    //else
                    //{
                    // just rage-quit
                    //GoHome(false);
                    //}
                }

                //else
                //Delay(DelayAfterWish);
            }
            // if the current wish is not active, activate it
            else if (!currentWish.IsActive)
            {
                currentWish.ActivateWish();
            }
            else if (currentWish.IsTvWish)
            {
                var selectedChannel = TV.SelectedChannel;
                // correct channel is activated
                if (selectedChannel == currentWish.Type)
                {
                    // we have time set
                    if (timeForTvWish >= 0)
                    {
                        timeForTvWish -= Time.deltaTime;
                        if (timeForTvWish <= 0f)
                        {
                            WishQuip quip     = GuestManager.I.GetWishQuip(currentWish.Type);
                            string   quipText = quip ? quip.GetSuccess() : "";

                            FinishActiveWish(message: quipText);
                        }
                    }
                    else
                    {
                        // set the timer
                        timeForTvWish = 3f;
                    }
                }
                else
                {
                    timeForTvWish = -1f;
                }
            }
            else if (currentWish.IsWindowWish)
            {
                var isWindowOpen = Prozor.IsProzorOpen || Database.e.balkonDoor.IsOpen;
                // windows is as we like it
                if ((currentWish.Type == GuestWish.GuestWishType.OpenWindow && isWindowOpen) ||
                    (currentWish.Type == GuestWish.GuestWishType.CloseWindow && !isWindowOpen))
                {
                    // we have time set
                    if (timeForWindowWish >= 0)
                    {
                        timeForWindowWish -= Time.deltaTime;
                        if (timeForWindowWish <= 0f)
                        {
                            WishQuip quip     = GuestManager.I.GetWishQuip(currentWish.Type);
                            string   quipText = quip ? quip.GetSuccess() : "";

                            FinishActiveWish(message: quipText);
                        }
                    }
                    else
                    {
                        // set the timer
                        timeForWindowWish = 3f;
                    }
                }
                else
                {
                    timeForWindowWish = -1f;
                }
            }
            else if (currentWish.IsDrinkWish || currentWish.IsFoodWish)
            {
                var container = currentWish.IsDrinkWish ? consumer.drinkContainer : consumer.foodContainer;

                const float minimumAmount = 0.5f;

                bool correctConsumable  = currentWish.Type == container.type.wishType;
                bool correctTemperature = container.IsAtGoodTemperature();


                if (container.amount > minimumAmount)
                {
                    Consumable.Quips q = container.type.quips;

                    if (correctConsumable && correctTemperature)
                    {
                        FinishActiveWish(true, q.perfect[Random.Range(0, q.perfect.Length)]);
                    }
                    else if (correctConsumable)
                    {
                        FinishActiveWish(false, q.wrongTemperature[Random.Range(0, q.wrongTemperature.Length)]);
                    }
                    else
                    {
                        FinishActiveWish(false, q.wrongConsumable[Random.Range(0, q.wrongConsumable.Length)]);
                    }
                }
            }

            //Debug.Log($"Happening! {CurrentState}, {entryWish.IsFinished}");



            break;
        }
    }
예제 #25
0
 public void ChangeState(GuestState _state)
 {
     state = _state;
 }
예제 #26
0
파일: Guest.cs 프로젝트: SonGit/NailGame
 void OnEndWalkOut()
 {
     _state = GuestState.STAND_BY;
     _guestManager.RefillGuest(this);
 }
예제 #27
0
 protected new void Start()
 {
     base.Start();
     belongGroup = transform.GetComponentInParent <GuestGroup> ();
     state       = GuestState.JoinAndWait;
 }
예제 #28
0
 void StartConnectionToServer()
 {
     state = Connecting;
     timeConnectionStarted = renderTime;
 }
예제 #29
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void OnEndWalkOut()
	{
		_state = GuestState.STAND_BY;
		_guestManager.RefillGuest (this);
	}
예제 #30
0
파일: Guest.cs 프로젝트: SonGit/NailGame
 void OnEndSitdown()
 {
     _state = GuestState.IDLE;
     Invoke("EnableBalloon", .25f);
 }
예제 #31
0
 private void Delay(float delayTime)
 {
     CurrentState   = GuestState.Delay;
     timeForNewWish = delayTime;
 }
예제 #32
0
파일: Guest.cs 프로젝트: SonGit/NailGame
	void OnEndWalkIn()
	{
		_anim.transform.localPosition += new Vector3 ( 0, 50 , FRONT_CHAIR_Z);
		_state = GuestState.SIT_DOWN;
	}
예제 #33
0
 private void RequestingWish()
 {
     CurrentState = GuestState.WaitingForService;
 }