Example #1
0
    void Update()
    {
        if (done)
        {
            return;
        }
        if (animIdx != -1 && lastSpriteIndex >= animIdx)
        {
            anim += Time.deltaTime * animSpd;
            var deg = Mathf.Lerp(0, 360, Mathf.SmoothStep(0f, 1f, Mathf.SmoothStep(0f, 1f, anim / 360f)));
            spriteRenderer.transform.parent.localRotation = Quaternion.Euler(0, 0, deg);
            if (deg >= 360)
            {
                spriteRenderer.transform.parent.localRotation = Quaternion.identity;
                animIdx = -1;
            }
        }
        //server only
        if (registerPlayer == null)
        {
            return;
        }

        progress += Time.deltaTime;
        if (timeToNotifyPlayer)
        {
            //Update the players progress bar
            ProgressBarMessage.SendUpdate(registerPlayer.gameObject, spriteIndex, id);
            lastSpriteIndex = spriteIndex;
        }

        //Cancel the progress bar if the player moves away or faces another direction:
        if (Interrupted())
        {
            completedEndAction.OnEnd(ProgressEndReason.INTERRUPTED);
            ServerCloseProgressBar();
            return;
        }

        //Finished! Invoke the action and close the progress bar for the player
        if (progress >= timeToFinish)
        {
            completedEndAction.OnEnd(ProgressEndReason.COMPLETED);
            if (progressAction.InterruptsOverlapping)
            {
                //interrupt all other progress actions of this type at this location
                UIManager.ServerInterruptProgress(this, progressAction, transform.localPosition, transform.parent);
            }
            ServerCloseProgressBar();
        }
    }
Example #2
0
    void UpdateMe()
    {
        if (done)
        {
            return;
        }
        if (animIdx != -1 && lastSpriteIndex >= animIdx)
        {
            anim += Time.deltaTime * animSpd;
            var deg = Mathf.Lerp(0, 360, Mathf.SmoothStep(0f, 1f, Mathf.SmoothStep(0f, 1f, anim / 360f)));
            spriteRenderer.transform.parent.localRotation = Quaternion.Euler(0, 0, deg);
            if (deg >= 360)
            {
                spriteRenderer.transform.parent.localRotation = Quaternion.identity;
                animIdx = -1;
            }
        }
        //server only
        if (registerPlayer == null)
        {
            return;
        }

        progress += Time.deltaTime;
        if (timeToNotifyPlayer)
        {
            //Update the players progress bar
            ProgressBarMessage.SendUpdate(registerPlayer.gameObject, spriteIndex, id);
            lastSpriteIndex = spriteIndex;
        }

        //check if progress should continue
        if (!progressAction.OnServerContinueProgress(new InProgressInfo(progress)))
        {
            // Remove from UpdateMe before invoking action, lest action fails and so infinite loop.
            ServerCloseProgressBar();
            progressAction.OnServerEndProgress(new EndProgressInfo(false));
            Logger.LogTraceFormat("Server progress bar {0} interrupted.", Category.ProgressAction, ID);
        }

        //Finished! Invoke the action and close the progress bar for the player
        if (progress >= timeToFinish)
        {
            // Remove from UpdateMe before invoking action, lest action fails and so infinite loop.
            ServerCloseProgressBar();
            progressAction.OnServerEndProgress(new EndProgressInfo(true));
            Logger.LogTraceFormat("Server progress bar {0} completed.", Category.ProgressAction, ID);
        }
    }
Example #3
0
 private void ServerCloseProgressBar()
 {
     done = true;
     //Notify player to turn off progress bar:
     if (PlayerManager.LocalPlayer == registerPlayer.gameObject)
     {
         //server player's bar, just destroy it
         DestroyProgressBar();
     }
     else
     {
         //inform client
         ProgressBarMessage.SendUpdate(registerPlayer.gameObject, COMPLETE_INDEX, id);
         //destroy server's local copy
         DestroyProgressBar();
     }
 }
Example #4
0
    void Update()
    {
        if (done)
        {
            return;
        }
        if (animIdx != -1 && lastSpriteIndex >= animIdx)
        {
            anim += Time.deltaTime * animSpd;
            var deg = Mathf.Lerp(0, 360, Mathf.SmoothStep(0f, 1f, Mathf.SmoothStep(0f, 1f, anim / 360f)));
            spriteRenderer.transform.parent.localRotation = Quaternion.Euler(0, 0, deg);
            if (deg >= 360)
            {
                spriteRenderer.transform.parent.localRotation = Quaternion.identity;
                animIdx = -1;
            }
        }
        //server only
        if (registerPlayer == null)
        {
            return;
        }

        progress += Time.deltaTime;
        if (timeToNotifyPlayer)
        {
            //Update the players progress bar
            ProgressBarMessage.SendUpdate(registerPlayer.gameObject, spriteIndex, id);
            lastSpriteIndex = spriteIndex;
        }

        //check if progress should continue
        if (!progressAction.OnServerContinueProgress(new InProgressInfo(progress)))
        {
            progressAction.OnServerEndProgress(new EndProgressInfo(false));
            ServerCloseProgressBar();
        }

        //Finished! Invoke the action and close the progress bar for the player
        if (progress >= timeToFinish)
        {
            progressAction.OnServerEndProgress(new EndProgressInfo(true));

            ServerCloseProgressBar();
        }
    }
Example #5
0
    private void ServerCloseProgressBar()
    {
        done = true;
        //Notify player to turn off progress bar:
        if (PlayerManager.LocalPlayer == registerPlayer.gameObject)
        {
            //server player's bar, just destroy it
            DestroyProgressBar();
        }
        else
        {
            Logger.LogTraceFormat("Server telling {0} to close progress bar {1}", Category.ProgressAction, registerPlayer.gameObject, ID);
            ProgressBarMessage.SendUpdate(registerPlayer.gameObject, COMPLETE_INDEX, id);

            //destroy server's local copy
            DestroyProgressBar();
        }
    }