public ProgressBar(IProgressAction action) { InitializeComponent(); BarAction = action; Canceled = false; Init(); }
/// <summary> /// For progress action system internal use only. Please use ProgressAction.ServerStartProgress to initiate a progress action /// on the server side. /// /// Initiate this progress bar's behavior on server side. Assumes position is already set to where the progress /// bar should appear. /// </summary> /// <param name="progressAction">progress action being performed</param> /// <param name="startInfo">info on the started action</param> public void _ServerStartProgress(IProgressAction progressAction, StartProgressInfo startInfo) { done = true; progress = 0f; lastSpriteIndex = 0; timeToFinish = startInfo.TimeForCompletion; registerPlayer = startInfo.Performer.GetComponent <RegisterPlayer>(); this.progressAction = progressAction; id = GetInstanceID(); if (startInfo.Performer != PlayerManager.LocalPlayer) { //server should not see clients progress bar spriteRenderer.enabled = false; } else { spriteRenderer.enabled = true; } spriteRenderer.sprite = progressSprites[0]; CommonStartProgress(); //Start the progress for the player: //note: using transform position for the offset, because progress bar has no register tile and //otherwise it would give an incorrect offset if player is on moving matrix ProgressBarMessage.SendCreate(startInfo.Performer, 0, (transform.position - startInfo.Performer.transform.position).To2Int(), id); }
/// <summary> /// Start a progress action targeting a specific object. /// Tries to create and begin animating a progress bar for a specific player. Returns null /// if progress did not begin for some reason. /// </summary> /// <param name="progressAction">progress action being performed</param> /// <param name="target">targeted object of the progress action</param> /// <param name="timeForCompletion">how long in seconds the action should take</param> /// <param name="player">player performing the action</param> /// <returns>progress bar associated with this action (can use this to interrupt progress). Null if /// progress was not started for some reason (such as already in progress for this action on the specified tile).</returns> public static ProgressBar ServerStartProgress(this IProgressAction progressAction, RegisterTile target, float timeForCompletion, GameObject player) { return(UIManager._ServerStartProgress(progressAction, ActionTarget.Object(target), timeForCompletion, player)); }
/// <summary> /// Start a progress action targeting a specific tile. /// Tries to create and begin animating a progress bar for a specific player. Returns null /// if progress did not begin for some reason. /// </summary> /// <param name="progressAction">progress action being performed</param> /// <param name="worldTilePos">tile position the action is being performed on</param> /// <param name="timeForCompletion">how long in seconds the action should take</param> /// <param name="player">player performing the action</param> /// <returns>progress bar associated with this action (can use this to interrupt progress). Null if /// progress was not started for some reason (such as already in progress for this action on the specified tile).</returns> public static ProgressBar ServerStartProgress(this IProgressAction progressAction, Vector3 worldTilePos, float timeForCompletion, GameObject player) { return(UIManager._ServerStartProgress(progressAction, ActionTarget.Tile(worldTilePos), timeForCompletion, player)); }