/* ----------------------------------------------- Functions */ #region Functions public void CleanUp() { Status = FlagBitStatus.CLEAR; ArgumentContainer.CleanUp(); TimeDelay = 0.0f; TimeElapsed = 0.0f; RateTime = 1.0f; TimeElapsedNow = 0.0f; TimesPlay = -1; CountLoop = -1; CountLoopNow = -1; FramePerSecond = 60; TimePerFrame = 0.0f; TimePerFrameConsideredRateTime = 0.0f; FrameStart = -1; FrameEnd = -1; FrameRange = 0; TimeRange = 0.0f; TimeElapsedTransition = 0.0f; TimeLimitTransition = 0.0f; RateTransition = 0.0f; IndexTrackSecondary = -1; TimeElapseReplacement = 0.0f; TimeElapseInRangeReplacement = 0.0f; }
private bool CallBackFunctionPlayEnd(Script_SpriteStudio6_Root scriptRoot, GameObject objectControl) { /* Progress Step */ IndexStep++; int countStep = CountGetStep(); if (countStep <= IndexStep) { /* Range Over */ if (null != FunctionPlayEnd) { FunctionPlayEnd(this); } /* Set behavior after finished */ switch (TypeLoop) { case Library_SpriteStudio6.Data.Sequence.Type.LAST: IndexStep = countStep - 1; break; case Library_SpriteStudio6.Data.Sequence.Type.TOP: IndexStep = 0; break; case Library_SpriteStudio6.Data.Sequence.Type.KEEP: default: /* MEMO: Step is not changed. */ return(true); } } Status |= FlagBitStatus.UPDATE_STEP; return(true); }
/* ******************************************************** */ //! Start playing the animation /*! * @param FrameInitial * Offset frame-number of starting Play in animation (0 origins). <br> * At the time of the first play-loop, Animation is started "LabelStart + FrameOffsetStart + FrameInitial". * -1 == use "FrameNoInitial" Value<br> * default: -1 * @param RateTime * Coefficient of time-passage of animation.<br> * Minus Value is given, Animation is played backwards.<br> * 0.0f is given, the now-setting is not changed) <br> * default: 0.0f (Setting is not changed) * @param KindStylePlay * PlayStyle.NOMAL == Animation is played One-Way.<br> * PlayStyle.PINGPONG == Animation is played Wrap-Around.<br> * PlayStyle.NO_CHANGE == use "Play-Pingpong" Setting. * default: PlayStyle.NO_CHANGE * @retval Return-Value * true == Success <br> * false == Failure (Error) * * The playing of animation begins. <br> * <br> * The update speed of animation quickens when you give a value that is bigger than 1.0f to "RateTime". */ public bool AnimationPlay(int PlayTimes = 0, float RateSpeedTimeProgress = 1.0f ) { /* Check Fatal-Error */ if ((null == DataCellMap) || (null == DataEffect)) { return(false); } /* Pool Refresh */ if (null != PoolParts) { PoolParts.PartsFlush(); } TimeElapsed = 0.0f; RateSpeed = RateSpeedTimeProgress; /* Status Set */ Status |= FlagBitStatus.PLAYING; Status |= FlagBitStatus.PLAYING_START; return(true); }
/* ********************************************************* */ //! Set the pause-status /*! * @param flagSwitch * true == Set pause (Suspend)<br> * false == Rerease pause (Resume) * @retval Return-Value * true == Success<br> * false == Failure (Error) * * The playing of sequence suspends or resumes.<br> */ public bool PauseSet(bool flagSwitch) { if ((null == DataProject) || (null == DataStep)) { return(false); } if (false == StatusIsPlaying) { /* Not Playing */ return(false); } if (true == flagSwitch) { if (false == StatusIsPausing) { Status |= FlagBitStatus.PAUSING; Status |= FlagBitStatus.UPDATE_PAUSE; } } else { if (true == StatusIsPausing) { Status &= FlagBitStatus.PAUSING; Status |= FlagBitStatus.UPDATE_PAUSE; } } return(true); }
/* ******************************************************** */ //! Start playing the animation /*! * @param FrameInitial * Offset frame-number of starting Play in animation (0 origins). <br> * At the time of the first play-loop, Animation is started "LabelStart + FrameOffsetStart + FrameInitial". * -1 == use "FrameNoInitial" Value<br> * default: -1 * @param RateTime * Coefficient of time-passage of animation.<br> * Minus Value is given, Animation is played backwards.<br> * 0.0f is given, the now-setting is not changed) <br> * default: 0.0f (Setting is not changed) * @retval Return-Value * true == Success <br> * false == Failure (Error) * * The playing of animation begins. <br> * <br> * The update speed of animation quickens when you give a value that is bigger than 1.0f to "RateTime". */ public bool AnimationPlay(bool PlayLoop = false, float RateSpeedTimeProgress = 1.0f ) { /* Check Fatal-Error */ if ((null == DataCellMap) || (null == DataEffect)) { return(false); } /* Pool Refresh */ if (null == PoolParts) { PoolBootUpParts(); } RateSpeed = RateSpeedTimeProgress; RateTimeToFrame = (null != InstanceRootParent) ? (1.0f / InstanceRootParent.TimePerFrame) : (float)DataEffect.CountFramePerSecond; TimeElapsed = (0.0f > RateSpeed) ? (FrameLength * TimePerFrame) : 0.0f; /* Status Set */ Status |= FlagBitStatus.PLAYING; Status |= FlagBitStatus.PLAYING_START; return(true); }
/* ******************************************************** */ //! Change "Cell-Map"-Table /*! * @param InstanceTableCellChange * New "Cell-Map"-Table<br> * null == Disable the changed * @param FlagChangeInstance * true == Set "InstanceTableCellChangeInstance" to "Instance" Animation-Objects.<br> * false == Do not affect "Instance" Animation-Objects.<br> * default: false * @param InstanceTableCellChangeInstance * New "Cell-Map"-Table for "Instance" Animation-Objects.<br> * null == Disable the changed (When "FlagChangeInstance" is true).<br> * default: null * @param FlagChangeEffect * true == Set "InstanceTableCellChangeEffect" to "Effect" Animation-Objects.<br> * false == Do not affect "Effect" Animation-Objects.<br> * default: false * @param InstanceTableCellChangeEffect * New "Cell-Map"-Table for "Effect" Animation-Objects.<br> * null == Disable the changed (When "FlagChangeEffect" is true).<br> * default: null * @retval Return-Value * true == Success <br> * false == Failure (Error) * * Replace the Material-Table that is used in the Animation.<br> * <br> * This function must be called after "Start" and "Awake" are executed. * <br> * Following the format of the "Cell-Map"-Table.<br> * Table[0][0]: Replacing Cell Data (Cell-Map No.:0, Cell No.:0)<br> * Table[0][1]: Replacing Cell Data (Cell-Map No.:0, Cell No.:1)<br> * Table[0][2]: Replacing Cell Data (Cell-Map No.:0, Cell No.:2)<br> * ...<br> * Table[0][x]: Replacing Cell Data (Cell-Map No.:0, The last of the cell owned by Cell-Map 0)<br> * --- (End of Table[0])<br> * Table[1][0]: Replacing Cell Data (Cell-Map No.:1, Cell No.:0)<br> * Table[1][1]: Replacing Cell Data (Cell-Map No.:1, Cell No.:1)<br> * ...<br> * Table[1][y]: Replacing Cell Data (Cell-Map No.:1, The last of the cell owned by Cell-Map 1)<br> * ---(End of Table[1])<br> * Table[n][0]: Replacing Cell Data (Cell-Map No.:n, Cell No.: 0)<br> * ...<br> * Table[n][z]: Replacing Cell Data (Cell-Map No.:n, The last of the cell owned by Cell-Map n)<br> * ---(End of Table[n])<br> * <br> * Following the function of each member of the " Library_SpriteStudio.Control.CellChange". * - IndexTexture: Index of Texture (in Material-Table)<br> * - DataCellMap: Information of Texture-Atlas that Cell is stored. (".ListCell" is dis-used.)<br> * - DataCell: Cell's placement-information in Texture-Atlas.<br> * <br> * Utility for processing this table is defined in "Library_SpriteStudio.Utility.TableCellChange" class. */ public bool CellMapChange(Library_SpriteStudio.Control.CellChange[][] InstanceTableCellChange) { TableCellChange = InstanceTableCellChange; Status |= FlagBitStatus.CELL_TABLECHANGED; return(true); }
void Start() { if (0 != (Status & FlagBitStatus.VALID)) { /* Already Started */ return; } /* Base Start */ StartBase((int)Constants.LIMIT_PARTICLE); /* Initialize */ if (null != DataEffect) { /* WorkArea BootUp */ RateTimeToFrame = (float)DataEffect.CountFramePerSecond; /* Provisional */ TimePerFrame = 1.0f / RateTimeToFrame; PoolBootUpParts(); /* Status Set */ Status |= FlagBitStatus.VALID; /* Play Animation Initialize */ if (false == FlagUnderControl) { AnimationPlay(); } } }
public bool BootUp() { CleanUp(); Status |= FlagBitStatus.VALID; return(true); }
// void Update() // { // } void LateUpdate() { float TimeDelta = Time.deltaTime * RateSpeed; if ((null == DataEffect) || (null == DataCellMap)) { return; } /* DrawManager Get */ if ((null == InstanceManagerDraw) && (null == InstanceRootParent)) { /* MEMO: "Instance" and "Effect" cannot have Manager-Draw. */ InstanceManagerDraw = Library_SpriteStudio.Utility.Parts.ManagerDrawGetParent(gameObject); } /* DrawParts-Cluster Create */ LateUpdateBase(); /* Animation Play-Check */ if (0 == (Status & FlagBitStatus.PLAYING)) { /* Not-Playing */ return; } /* Particle&Emitter Control WorkArea Create */ if (null == PoolParts) { PoolBootUpParts(); } /* Update Emitter & Particle */ ChainClusterDrawParts.ChainCleanUp(); /* DrawParts-Cluster-Chain Clear */ TimeElapsed += ((0 != (Status & FlagBitStatus.PAUSING)) || (0 != (Status & FlagBitStatus.PLAYING_START))) ? 0.0f : TimeDelta; FrameNow = TimeElapsed * RateTimeToFrame; if (0 != (Status & FlagBitStatus.PLAYING_INFINITY)) { /* Independent */ // FrameNow %= FrameLength; } else { /* Dependent */ FrameNow = Mathf.Clamp(FrameNow, 0.0f, FrameLength); } PoolParts.Update(this); /* Set to DrawManager */ /* MEMO: Test */ if (((null != InstanceManagerDraw) && (null != DrawObject)) && (false == FlagHideForce)) { /* Set To Draw-Manager */ InstanceManagerDraw.DrawSet(this); } /* Status Update */ Status &= ~FlagBitStatus.PLAYING_START; Status &= ~FlagBitStatus.CELL_TABLECHANGED; }
/* ******************************************************** */ //! Stop playing the animation /*! * @param FlagWarpEnd * Specifying Display-Frame<br> * true == End-Frame<br> * false == Status-quo<br> * default: false * @retval Return-Value * (None) * * The playing of animation stops. */ public void AnimationStop() { /* Pool Refresh */ if (null != PoolParts) { PoolParts.ParticleReset(); } /* Status Set */ Status &= ~FlagBitStatus.PLAYING; return; }
public bool Stop() { if (0 == (Status & FlagBitStatus.VALID)) { return(false); } if (0 == (Status & FlagBitStatus.PLAYING)) { return(true); } Status &= ~(FlagBitStatus.PLAYING | FlagBitStatus.PAUSING); return(true); }
internal void StartMain() { /* Boot up master datas */ /* MEMO: Reason why initial setting of ScriptableObject is done here */ /* (without processing with ScriptableObject's Awake or OnEnable) */ /* is to stabilize execution such when re-compile. */ if ((null == DataCellMap) || (null == DataEffect)) { /* Data invalid */ goto Start_ErrorEnd; } if ((false == DataCellMap.VersionCheckRuntime()) || (false == DataEffect.VersionCheckRuntime())) { /* Data-Version invalid */ goto Start_ErrorEnd; } FunctionBootUpDataEffect(); /* Start Base-Class */ BaseStart(); /* Boot up Draw-Cluster */ /* MEMO: Need to run before "ControlEffect.BootUp". */ if (false == ClusterBootUpDraw()) { goto Start_ErrorEnd; } /* Boot up Effect-Control */ if (false == ControlEffect.BootUp(this)) { goto Start_ErrorEnd; } FrameRange = (float)ControlEffect.DurationFull; Status |= FlagBitStatus.VALID; /* Play Animation Initialize */ if (null == InstanceRootParent) { AnimationPlay(); } return; Start_ErrorEnd :; Status &= ~FlagBitStatus.VALID; return; }
void Start() { /* Base Start */ StartBase((int)Constants.LIMIT_PARTS); /* Parts-WorkArea Start */ PoolBootUpParts(); /* Status Set */ Status |= FlagBitStatus.VALID; /* Play Animation Initialize */ if (false == FlagUnderControl) { AnimationPlay(); } }
public bool Pause(bool flagSwitch) { if (0 == (Status & FlagBitStatus.VALID)) { return(false); } if (true == flagSwitch) { Status |= FlagBitStatus.PAUSING; } else { Status &= ~FlagBitStatus.PAUSING; } return(true); }
/* ********************************************************* */ //! Start playing current sequence /*! * @param step * Step to start playback * 0 == From the top * @param rateTime * Coefficient of time-passage of animation.<br> * Must not be negative or 0.0f. * "float.NaN" is given, Apply previous setting.<br> * default: float.NaN * * @retval Return-Value * true == Success<br> * false == Failure (Error) * * The playing of current sequence begins. <br> * <br> * When "step" is given a value from 0 to CountGetStep()-1, * will play from the middle of the sequence.<br> */ public bool Play(int step = 0, float rateTime = float.NaN) { if ((null == DataProject) || (null == DataStep)) { return(false); } if (true == StatusIsPlaying) { /* Now playing */ return(false); } int countStep = CountGetStep(); if ((0 > step) || (0 > countStep) || (countStep <= step)) { return(false); } if (true == float.IsNaN(rateTime)) { rateTime = RateTime; if (rateTime <= 0.0f) { rateTime = 1.0f; } } else { if (0.0f >= rateTime) { return(false); } } IndexStep = step; RateTime = rateTime; Status |= FlagBitStatus.PLAYING; Status &= ~FlagBitStatus.PAUSING; Status |= FlagBitStatus.UPDATE_ALL; return(true); }
/* ********************************************************* */ //! Stop playing the current sequence /*! * @param flagJumpEndStep * Not working, now (Reserved) * false == Sequence is stopped with maintaining the current state.<br> * true == Sequence is stop and jump to last step.<br> * default: false * @param flagJumpEndFrame * false == Sequence is stopped with maintaining the current state.<br> * true == Sequence is stop and jump to animation's last frame.<br> * default: false * @retval Return-Value * (None) * * The playing of sequence stops.<br> */ public void Stop(bool flagJumpEndStep, bool flagJumpEndFrame) { if ((null == DataProject) || (null == DataStep)) { return; } if (false == StatusIsPlaying) { /* Not playing */ return; } if (null != ScriptRoot) { ScriptRoot.AnimationPause(-1, false); ScriptRoot.AnimationStop(-1, true); } Status &= ~(FlagBitStatus.PLAYING | FlagBitStatus.PAUSING | FlagBitStatus.UPDATE_ALL ); }
/* ********************************************************* */ //! Set the step of current sequence /*! * @param step * true == Set pause (Suspend)<br> * false == Rerease pause (Resume) * @retval Return-Value * true == Success<br> * false == Failure (Error) * * Force jump the playback step of current sequence. */ public bool StepSet(int step) { if ((null == DataProject) || (null == DataStep)) { return(false); } if (false == StatusIsPlaying) { /* Not Playing */ return(false); } int countStep = CountGetStep(); if ((0 > step) || (0 > countStep) || (countStep <= step)) { return(false); } IndexStep = step; Status |= FlagBitStatus.UPDATE_STEP; return(true); }
/* ******************************************************** */ //! Set the pause-status of the animation /*! * @param FlagSwitch * true == Set pause (Suspend)<br> * false == Rerease pause (Resume) * @retval Return-Value * true == Success <br> * false == Failure (Error) * * The playing of animation suspends or resumes.<br> * This function fails if the animation is not playing. */ public bool AnimationPause(bool FlagSwitch) { if (0 == (Status & FlagBitStatus.PLAYING)) { return(false); } if (true == FlagSwitch) { if (0 == (Status & FlagBitStatus.PAUSING)) { Status |= FlagBitStatus.PAUSING; } } else { if (0 != (Status & FlagBitStatus.PAUSING)) { Status &= ~FlagBitStatus.PAUSING; } } return(false); }
void Update() #endif { if (false == StatusIsValid) { /* Not Initialized (Not Running) */ StartMain(); if (false == StatusIsValid) { /* Failure to Initialize */ return; } } if (false == StatusIsPlaying) { /* Not Playing */ return; } /* Updates */ /* MEMO: Even when be hidden, playback continue. */ /* Otherwise, interfere with animation's instance changes and frame synchronization. */ /* MEMO: Make sure to run "StepProgress" first in the Animation-playing process. */ /* Because, Animation-object is instantiated in StepProgress. */ if (true == StatusIsUpdateStep) { StepProgress(); Status &= ~FlagBitStatus.UPDATE_STEP; Status |= (FlagBitStatus.UPDATE_ALL & ~FlagBitStatus.UPDATE_STEP); } if (null == ScriptRoot) { /* Missing Instance */ return; } ScriptRoot.FlagHideForce = FlagHideForce; ScriptRoot.FlagPlanarization = FlagPlanarization; ScriptRoot.FlagColliderInterlockHideForce = FlagColliderInterlockHideForce; ScriptRoot.OrderInLayer = OrderInLayer; ScriptRoot.RateTimeSet(-1, RateTime); if (true == StatusIsUpdateRateOpacity) { ScriptRoot.RateOpacity = RateOpacityForce; Status &= ~FlagBitStatus.UPDATE_RATE_OPACITY; } if (true == StatusIsUpdateRateScaleLocal) { ScriptRoot.RateScaleLocal = RateScaleLocalForce;; Status &= ~FlagBitStatus.UPDATE_RATE_SCALELOCAL; } if (true == StatusIsUpdatePause) { ScriptRoot.AnimationPause(-1, StatusIsPausing); Status &= ~FlagBitStatus.UPDATE_PAUSE; } if (0 != (Status & FlagBitStatus.INITIAL_EXECUTE_UPDATE)) { if (true == FlagStopInitial) { Stop(false, false); } } Status &= ~FlagBitStatus.INITIAL_EXECUTE_UPDATE; }
/* ******************************************************** */ //! Change Part's-Cell /*! * @param IDParts * IDParts(Part-Index) * @param IndexCellMap * Cell-Map Index<br> * -1 == Accorde to Animation-Data * @param IndexCell * Cell Index in Cell-Map<br> * -1 == Accorde to Animation-Data * @param FlagIgnoreAttributeCell * true == Ignore "Reference-Cell" Attribute in the Animation-Data.<br> * false == Will be updated, if the new "Reference-Cell"Attribute-Data has appeared after changing.<br> * default: false * @retval Return-Value * true == Success <br> * false == Failure (Error) * * Change the cells that are displayed in the parts.<br> * <br> * This function must be called after "Start" and "Awake" are executed. */ public bool CellChange(int IDParts, int IndexCellMap, int IndexCell, bool FlagIgnoreAttributeCell = false) { if ((null == PoolParts) || (null == PoolParts.PoolEmitter)) { return(false); } if ((0 > IDParts) || (PoolParts.PoolEmitter.Length <= IDParts)) { return(false); } Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus Status = PoolParts.PoolEmitter[IDParts].Status; if (0 == (Status & (Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.VALID | Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.RUNNING))) { return(false); } if (null == TableCellChange) { /* Default */ if ((null == DataCellMap) || (null == DataCellMap.ListDataCellMap)) { /* Error */ return(false); } if ((0 > IndexCellMap) || (0 > IndexCell)) { /* Clear Changing */ goto CellChange_Clear; } if (DataCellMap.ListDataCellMap.Length <= IndexCellMap) { /* Error */ return(false); } if (DataCellMap.ListDataCellMap[IndexCellMap].CountGetCell() <= IndexCell) { /* Error */ return(false); } } else { /* Cell-Table Changed */ if ((0 > IndexCellMap) || (0 > IndexCell)) { /* Clear Changing */ goto CellChange_Clear; } if (false == Library_SpriteStudio.Utility.TableCellChange.TableCheckValidIndex(TableCellChange, IndexCellMap, IndexCell)) { /* Error */ return(false); } } PoolParts.PoolEmitter[IDParts].IndexCellMapOverwrite = IndexCellMap; PoolParts.PoolEmitter[IDParts].IndexCellOverwrite = IndexCell; Status = (false == FlagIgnoreAttributeCell) ? (Status & ~Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.OVERWRITE_CELL_IGNOREATTRIBUTE) : (Status | Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.OVERWRITE_CELL_IGNOREATTRIBUTE); Status |= Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.OVERWRITE_CELL_UNREFLECTED; PoolParts.PoolEmitter[IDParts].Status = Status; return(true); CellChange_Clear :; PoolParts.PoolEmitter[IDParts].IndexCellMapOverwrite = -1; PoolParts.PoolEmitter[IDParts].IndexCellOverwrite = -1; Status &= ~Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.OVERWRITE_CELL_IGNOREATTRIBUTE; Status |= Library_SpriteStudio.Control.PartsEffectEmitter.FlagBitStatus.OVERWRITE_CELL_UNREFLECTED; PoolParts.PoolEmitter[IDParts].Status = Status; return(true); }
// void Update() // { // } void LateUpdate() { float TimeDelta = Time.deltaTime * RateSpeed; if((null == DataEffect) || (null == DataCellMap)) { return; } /* DrawManager Get */ if((null == InstanceManagerDraw) && (null == InstanceRootParent)) { /* MEMO: "Instance" and "Effect" cannot have Manager-Draw. */ InstanceManagerDraw = Library_SpriteStudio.Utility.Parts.ManagerDrawGetParent(gameObject); } /* DrawParts-Cluster Create */ LateUpdateBase(); /* Animation Play-Check */ if(0 == (Status & FlagBitStatus.PLAYING)) { /* Not-Playing */ return; } bool FlagPause = (0 != (Status & FlagBitStatus.PAUSING)) ? true : false; /* Random Create */ if(null == InstanceRandom) { InstanceRandom = new RandomGenerator(); SeedRandom = (uint)SeedRandomInitialize; InstanceRandom.InitSeed(SeedRandom); } /* Particle&Emitter Control WorkArea Create */ if(null == PoolParts) { PoolBootUpParts(); } if(0 != (Status & FlagBitStatus.PLAYING_START)) { /* Root's Emitter Generate */ PoolParts.PartsGenerate(null, this); } /* Update Emitter & Particle */ ChainClusterDrawParts.ChainCleanUp(); /* DrawParts-Cluster-Chain Clear */ TimeElapsed += TimeDelta; int Index = 0; int CountExecuteParts = 0; Library_SpriteStudio.Control.PartsEffect InstanceParts = null; for( ; ; ) { InstanceParts = PoolParts.InstancePeekRunning(ref Index); if(null == InstanceParts) { break; } if(false == InstanceParts.Update(ref CountExecuteParts, TimeDelta, PoolParts, FlagPause)) { /* Duration is over. (Delete) */ PoolParts.InstanceSetWaiting(ref Index); } } Status &= ~FlagBitStatus.PLAYING_START; /* End Check */ if(0 >= CountExecuteParts) { /* All Emitter & Particle is waiting ... Play-End */ if(null != FunctionPlayEnd) { if(false == FunctionPlayEnd(this)) { /* Destroy (Request) */ /* MEMO: Destroy at end of "LateUpdate" */ Status |= FlagBitStatus.REQUEST_DESTROY; } } AnimationStop(); } else { /* Set to DrawManager */ /* MEMO: Test */ if(((null != InstanceManagerDraw) && (null != DrawObject)) && (false == FlagHideForce)) { /* Set To Draw-Manager */ InstanceManagerDraw.DrawSet(this); } } /* Checking Destroy-Request */ if(0 != (Status & FlagBitStatus.REQUEST_DESTROY)) { Object.Destroy(gameObject); } }
// void Update() // { // } void LateUpdate() { float TimeDelta = Time.deltaTime * RateSpeed; if ((null == DataEffect) || (null == DataCellMap)) { return; } /* DrawManager Get */ if ((null == InstanceManagerDraw) && (null == InstanceRootParent)) { /* MEMO: "Instance" and "Effect" cannot have Manager-Draw. */ InstanceManagerDraw = Library_SpriteStudio.Utility.Parts.ManagerDrawGetParent(gameObject); } /* DrawParts-Cluster Create */ LateUpdateBase(); /* Animation Play-Check */ if (0 == (Status & FlagBitStatus.PLAYING)) { /* Not-Playing */ return; } bool FlagPause = (0 != (Status & FlagBitStatus.PAUSING)) ? true : false; /* Random Create */ if (null == InstanceRandom) { InstanceRandom = new RandomGenerator(); SeedRandom = (uint)SeedRandomInitialize; InstanceRandom.InitSeed(SeedRandom); } /* Particle&Emitter Control WorkArea Create */ if (null == PoolParts) { PoolBootUpParts(); } if (0 != (Status & FlagBitStatus.PLAYING_START)) { /* Root's Emitter Generate */ PoolParts.PartsGenerate(null, this); } /* Update Emitter & Particle */ ChainClusterDrawParts.ChainCleanUp(); /* DrawParts-Cluster-Chain Clear */ TimeElapsed += TimeDelta; int Index = 0; int CountExecuteParts = 0; Library_SpriteStudio.Control.PartsEffect InstanceParts = null; for ( ; ;) { InstanceParts = PoolParts.InstancePeekRunning(ref Index); if (null == InstanceParts) { break; } if (false == InstanceParts.Update(ref CountExecuteParts, TimeDelta, PoolParts, FlagPause)) { /* Duration is over. (Delete) */ PoolParts.InstanceSetWaiting(ref Index); } } Status &= ~FlagBitStatus.PLAYING_START; /* End Check */ if (0 >= CountExecuteParts) { /* All Emitter & Particle is waiting ... Play-End */ if (null != FunctionPlayEnd) { if (false == FunctionPlayEnd(this)) { /* Destroy (Request) */ /* MEMO: Destroy at end of "LateUpdate" */ Status |= FlagBitStatus.REQUEST_DESTROY; } } AnimationStop(); } else { /* Set to DrawManager */ /* MEMO: Test */ if (((null != InstanceManagerDraw) && (null != DrawObject)) && (false == FlagHideForce)) { /* Set To Draw-Manager */ InstanceManagerDraw.DrawSet(this); } } /* Checking Destroy-Request */ if (0 != (Status & FlagBitStatus.REQUEST_DESTROY)) { Object.Destroy(gameObject); } }
/* ******************************************************** */ //! Start playing the animation /*! @param FrameInitial Offset frame-number of starting Play in animation (0 origins). <br> At the time of the first play-loop, Animation is started "LabelStart + FrameOffsetStart + FrameInitial". -1 == use "FrameNoInitial" Value<br> default: -1 @param RateTime Coefficient of time-passage of animation.<br> Minus Value is given, Animation is played backwards.<br> 0.0f is given, the now-setting is not changed) <br> default: 0.0f (Setting is not changed) @param KindStylePlay PlayStyle.NOMAL == Animation is played One-Way.<br> PlayStyle.PINGPONG == Animation is played Wrap-Around.<br> PlayStyle.NO_CHANGE == use "Play-Pingpong" Setting. default: PlayStyle.NO_CHANGE @retval Return-Value true == Success <br> false == Failure (Error) The playing of animation begins. <br> <br> The update speed of animation quickens when you give a value that is bigger than 1.0f to "RateTime". */ public bool AnimationPlay( int PlayTimes = 0, float RateSpeedTimeProgress = 1.0f ) { /* Check Fatal-Error */ if((null == DataCellMap) || (null == DataEffect)) { return(false); } /* Pool Refresh */ if(null != PoolParts) { PoolParts.PartsFlush(); } TimeElapsed = 0.0f; RateSpeed = RateSpeedTimeProgress; /* Status Set */ Status |= FlagBitStatus.PLAYING; Status |= FlagBitStatus.PLAYING_START; return(true); }
/* ******************************************************** */ //! Stop playing the animation /*! @param FlagWarpEnd Specifying Display-Frame<br> true == End-Frame<br> false == Status-quo<br> default: false @retval Return-Value (None) The playing of animation stops. */ public void AnimationStop() { /* Pool Refresh */ if(null != PoolParts) { PoolParts.PartsFlush(); } /* Status Set */ Status &= ~FlagBitStatus.PLAYING; return; }
/* ******************************************************** */ //! Set the pause-status of the animation /*! @param FlagSwitch true == Set pause (Suspend)<br> false == Rerease pause (Resume) @retval Return-Value true == Success <br> false == Failure (Error) The playing of animation suspends or resumes.<br> This function fails if the animation is not playing. */ public bool AnimationPause(bool FlagSwitch) { if(0 == (Status & FlagBitStatus.PLAYING)) { return(false); } if(true == FlagSwitch) { if(0 == (Status & FlagBitStatus.PAUSING)) { Status |= FlagBitStatus.PAUSING; } } else { if(0 != (Status & FlagBitStatus.PAUSING)) { Status &= ~FlagBitStatus.PAUSING; } } return(false); }
/* MEMO: Originally should be function, but call-cost is high(taking processing content into account). */ /* Processed directly in "Script_SpriteStudio6_Root". */ // public void StatusClearTransient() // { // if((FlagBitStatus.VALID | FlagBitStatus.PLAYING) == (Status & (FlagBitStatus.VALID | FlagBitStatus.PLAYING))) // { /* Not-Playing */ // Status &= ~( FlagBitStatus.PLAYING_START // | FlagBitStatus.DECODE_ATTRIBUTE // | FlagBitStatus.TRANSITION_START // | FlagBitStatus.IGNORE_NEXTUPDATE_USERDATA // ); // } // TimeElapseReplacement = 0.0f; // } public void TimeSkip(float time, bool flagReverseParent, bool flagWrapRange) { /* MEMO: In principle, This Function is for calling from "DrawInstance". */ if (0.0f > time) { /* Wait Infinity */ TimeDelay = -1.0f; return; } bool flagPongPong = (0 != (Status & FlagBitStatus.STYLE_PINGPONG)); /* ? true : false */ bool flagReverseStyle = (0 != (Status & FlagBitStatus.STYLE_REVERSE)); /* ? true : false */ float timeLoop = TimeRange * ((true == flagPongPong) ? 2.0f : 1.0f); float timeCursor = time; int countLoop = 0; /* Loop-Count Get */ while (timeLoop <= timeCursor) { timeCursor -= timeLoop; countLoop++; } /* Solving Play-Count */ if (0 >= TimesPlay) { /* Infinite-Loop */ /* MEMO: "TimesPlay" does not change. */ countLoop = 0; TimeDelay = 0.0f; } else { /* Limited-Loop */ if (0 >= countLoop) { /* No-Wrap-Around */ /* MEMO: "TimesPlay" does not change. */ countLoop = 0; TimeDelay = 0.0f; } else { /* Wrap-Around */ if (TimesPlay <= countLoop) { /* Over */ if (true == flagReverseParent) { /* Reverse ... Play-Delay */ /* MEMO: "TimesPlay" does not change. */ TimeDelay = ((float)(countLoop - TimesPlay) * timeLoop) + timeCursor; timeCursor = timeLoop; } else { /* Foward ... Play-End */ TimeDelay = 0.0f; TimesPlay = 0; if (true == flagPongPong) { /* Play-Style: PingPong */ timeCursor = (0 != (Status & FlagBitStatus.STYLE_REVERSE)) ? TimeRange : 0.0f; } else { /* Play-Style: OneWay */ timeCursor = (0 != (Status & FlagBitStatus.STYLE_REVERSE)) ? 0.0f : TimeRange; } Stop(); } } else { /* In-Range */ TimesPlay -= countLoop; } } } /* Time Adjust */ if (true == flagPongPong) { /* Play-Style: PingPong */ Status &= ~FlagBitStatus.PLAYING_REVERSE; if (true == flagReverseStyle) { /* Play-Stype: PingPong & Reverse */ if (TimeRange <= timeCursor) { /* Start: Foward */ timeCursor -= TimeRange; // Status &= ~FlagBitStatus.PLAYING_REVERSE; } else { /* Start: Reverse */ Status |= FlagBitStatus.PLAYING_REVERSE; } } else { /* Play-Style: PingPong & Foward */ if (TimeRange <= timeCursor) { /* Start: Reverse */ timeCursor -= TimeRange; timeCursor = TimeRange - timeCursor; Status |= FlagBitStatus.PLAYING_REVERSE; } else { /* Start: Foward */ // Status &= ~FlagBitStatus.PLAYING_REVERSE; } } } else { /* Play-Style: One-Way */ if (true == flagReverseStyle) { /* Play-Stype: One-Way & Reverse */ Status |= FlagBitStatus.PLAYING_REVERSE; if (false == flagReverseParent) { timeCursor = TimeRange - timeCursor; } } else { /* Play-Stype: One-Way & Foward */ Status &= ~FlagBitStatus.PLAYING_REVERSE; if (true == flagReverseParent) { timeCursor = TimeRange - timeCursor; } } } TimeElapsed = timeCursor; int frame = (int)(TimeElapsed / TimePerFrame); // frame = Mathf.Clamp(frame, 0, (FrameRange - 1)); frame += FrameStart; ArgumentContainer.Frame = frame; }
internal void StartMain() { /* Boot up master datas */ /* MEMO: Reason why initial setting of ScriptableObject is done here */ /* (without processing with ScriptableObject's Awake or OnEnable) */ /* is to stabilize execution such when re-compile. */ if (null == DataProject) { /* Data invalid */ goto StartMain_ErrorEnd; } if (false == DataProject.VersionCheckRuntime()) { /* Data-Version invalid */ goto StartMain_ErrorEnd; } /* Initialize parameters */ IndexStep = -1; GameObjectRoot = null; ScriptRoot = null; IndexStep = -1; /* Inittial Play */ if ((false == string.IsNullOrEmpty(NameSequencePack)) && (false == string.IsNullOrEmpty(NameDataSequence))) { int index; index = IndexGetPack(NameSequencePack); if (0 > index) { goto StartMain_End; } if (false == PackSet(index)) { goto StartMain_End; } index = IndexGetSequence(NameDataSequence); if (0 > index) { goto StartMain_End; } if (false == SequenceSet(index)) { goto StartMain_End; } int countStep = CountGetStep(); if ((0 > IndexStepInitial) || (countStep <= IndexStepInitial)) { IndexStepInitial = 0; } Play(IndexStepInitial); // if(true == FlagStopInitial) // { // Stop(false, false); // } } StartMain_End :; Status |= FlagBitStatus.VALID; Status |= FlagBitStatus.UPDATE_ALL; Status |= FlagBitStatus.INITIAL_EXECUTE_UPDATE; return; StartMain_ErrorEnd :; Status &= ~FlagBitStatus.VALID; return; }
internal void StartMain() { /* Boot up master datas */ /* MEMO: Reason why initial setting of ScriptableObject is done here */ /* (without processing with ScriptableObject's Awake or OnEnable) */ /* is to stabilize execution such when re-compile. */ if ((null == DataCellMap) || (null == DataAnimation)) { /* Data invalid */ goto StartMain_ErrorEnd; } if ((false == DataCellMap.VersionCheckRuntime() || (false == DataAnimation.VersionCheckRuntime()))) { /* Data-Version invalid */ goto StartMain_ErrorEnd; } FunctionBootUpDataAnimation(); /* Get Counts */ CountPartsSprite = DataAnimation.CountGetPartsSprite(); CountSpriteMax = 0; /* Set in ClusterBootUpDraw */ CountMeshMax = 0; /* Set in ClusterBootUpDraw */ CountParticleMax = 0; /* Set in ClusterBootUpDraw */ /* Start Base-Class */ if (false == BaseStart()) { goto StartMain_ErrorEnd; } /* Generate Play-Track */ int countTrack = ControlBootUpTrack(-1); if (0 >= countTrack) { goto StartMain_ErrorEnd; } /* Check Play-Information */ if (false == InformationCheckPlay(countTrack)) { goto StartMain_ErrorEnd; } /* Boot up Parts-Control */ if (false == ControlBootUpParts(CountSpriteMax)) { goto StartMain_ErrorEnd; } /* Boot up Draw-Chain */ if (false == ChainDrawBootUp()) { goto StartMain_ErrorEnd; } /* Boot up Draw-Cluster */ /* MEMO: CAUTION. Caution that Parent-"Root" is not necessarily initialized earlier in generation order of GameObjects on the scene. */ /* ("ClusterDraw" is set null if before the parent's start) */ if (false == ClusterBootUpDraw()) { goto StartMain_ErrorEnd; } Status |= FlagBitStatus.VALID; /* Set Initial Animations */ if (false == AnimationPlayInitial()) { goto StartMain_ErrorEnd; } return; StartMain_ErrorEnd :; TableControlTrack = null; Status &= ~FlagBitStatus.VALID; return; }
void Start() { /* Base Start */ StartBase((int)Constants.LIMIT_PARTS); /* Parts-WorkArea Start */ PoolBootUpParts(); /* Status Set */ Status |= FlagBitStatus.VALID; /* Play Animation Initialize */ if(false == FlagUnderControl) { AnimationPlay(); } }
internal void LateUpdateMain(float timeElapsed, bool flagHideDefault, Library_SpriteStudio6.KindMasking masking, ref Matrix4x4 matrixCorrection, bool flagInitializeMatrixCorrection, bool flagPlanarization ) { if (0 == (Status & FlagBitStatus.VALID)) { /* Status invalid */ return; } if ((null == TableControlTrack) || (null == TableControlParts)) { /* Can not play */ return; } if (null == DataAnimation) { /* Master data lost */ return; } if (false == DataAnimation.StatusIsBootup) { /* Re-import data? or Re-compile during playing animation? */ return; } /* Get Hidden state */ bool flagHide = flagHideDefault | FlagHideForce; /* Clear Draw-Chain */ if (false == ChainDrawBootUp()) { /* Failure Clear Draw-Chain */ return; } /* Update Base */ BaseLateUpdate(timeElapsed); /* Update Play-Track */ if (null == TableControlTrack) { /* Lost */ ControlBootUpTrack(-1); } int countControlTrack = TableControlTrack.Length; for (int i = 0; i < countControlTrack; i++) { TableControlTrack[i].Update(timeElapsed); } /* Update Parts' Common-Parameters (GameObject etc.) */ /* MEMO: In case of the most-Parent-"Root" node, if MeshRenderer's matrix is not acquired after updating Transform first, "matrixCorrection" shifts 1 frame. */ int countControlParts = TableControlParts.Length; int indexTrackRoot = TableControlParts[0].IndexControlTrack; /* (0 < countControlParts) ? TableControlParts[0].IndexControlTrack : -1; */ Status &= ~FlagBitStatus.ANIMATION_SYNTHESIZE; TableControlParts[0].Update(this, 0, flagHide, ref matrixCorrection, indexTrackRoot ); if (true == flagInitializeMatrixCorrection) { matrixCorrection = InstanceMeshRenderer.localToWorldMatrix.inverse; } for (int i = 1; i < countControlParts; i++) { TableControlParts[i].Update(this, i, flagHide, ref matrixCorrection, indexTrackRoot ); } bool flagAnimationSynthesize = (0 != (Status & FlagBitStatus.ANIMATION_SYNTHESIZE)); /* ? true : false */ /* Recover Draw-Cluster & Component for Rendering */ if (null == ClusterDraw) { /* Lost */ if (false == ClusterBootUpDraw()) { /* Recovery failure */ return; } } /* Exec Drawing */ /* MEMO: At "Pre-Draw" ... */ /* First render all "Mask"s. */ /* After that, render "Mask"s again according to priority at "Draw" timing. (Process of removing "Mask"s) */ /* Caution that rendering "Mask"s is only Highest-Parent-Root. ("Instance"s and "Effect"s do not render "Mask"s) */ /* MEMO: At "Draw" ... */ /* Caution that "Instance" and "Effect" are update in draw. */ /* Hidden "Normal" parts are not processed.(Not included in the Draw-Order-Chain) */ /* MEMO: Before 1.0.x, draw-order are baked. */ int idPartsDrawNext; if (true == flagAnimationSynthesize) { int countChainDraw; /* Sort Draw-Chain */ /* MEMO: "PreDraw"'s drawing order is reversed, but since sort-key is inversed, not necessary to exec "Reverse()" after "Sort()". */ ListPartsPreDraw.Sort(); ListPartsDraw.Sort(); if (null == InstanceRootParent) { /* Clean Draw-Cluster & Component for Rendering */ /* MEMO: Execute combining and drawing only at Highest-Parent-Root. */ ClusterDraw.DataPurge(); /* Exec "Pre-Draw" */ countChainDraw = ListPartsPreDraw.Count; for (int i = 0; i < countChainDraw; i++) { idPartsDrawNext = ListPartsPreDraw[i] & Library_SpriteStudio6.Control.Animation.MaskSortKeyIDParts; TableControlParts[idPartsDrawNext].PreDraw(this, idPartsDrawNext, flagHide, masking, ref matrixCorrection, flagPlanarization ); } } /* Exec "Draw" */ countChainDraw = ListPartsDraw.Count; for (int i = 0; i < countChainDraw; i++) { idPartsDrawNext = ListPartsDraw[i] & Library_SpriteStudio6.Control.Animation.MaskSortKeyIDParts; TableControlParts[idPartsDrawNext].Draw(this, idPartsDrawNext, flagHide, masking, ref matrixCorrection, flagPlanarization ); } } else { if (null == InstanceRootParent) { /* Clean Draw-Cluster & Component for Rendering */ /* MEMO: Execute combining and drawing only at Highest-Parent-Root. */ ClusterDraw.DataPurge(); /* Exec "Pre-Draw" */ idPartsDrawNext = TableControlParts[0].IDPartsNextPreDraw; while (0 <= idPartsDrawNext) { TableControlParts[idPartsDrawNext].PreDraw(this, idPartsDrawNext, flagHide, masking, ref matrixCorrection, flagPlanarization ); idPartsDrawNext = TableControlParts[idPartsDrawNext].IDPartsNextPreDraw; } } /* Exec "Draw" */ idPartsDrawNext = TableControlParts[0].IDPartsNextDraw; while (0 <= idPartsDrawNext) { TableControlParts[idPartsDrawNext].Draw(this, idPartsDrawNext, flagHide, masking, ref matrixCorrection, flagPlanarization ); idPartsDrawNext = TableControlParts[idPartsDrawNext].IDPartsNextDraw; } } /* Mesh Combine & Set to Renderer */ if ((null == InstanceRootParent) && (null != MeshCombined)) { /* Clear Mesh */ MeshCombined.Clear(); MeshCombined.name = NameBatchedMesh; if (false == flagHide) { /* MEMO: Set the material-array to null issue "NullReferenceException". Leave as. */ if (true == ClusterDraw.MeshCombine(MeshCombined, ref TableMaterialCombined)) { InstanceMeshRenderer.sharedMaterials = TableMaterialCombined; InstanceMeshRenderer.sortingOrder = OrderInLayer; } } InstanceMeshFilter.sharedMesh = MeshCombined; } /* Check Track-End */ int indexTrackSlave = -1; bool flagDecodeNextForce = false; bool flagStopAllTrack = true; bool flagRequestPlayEndTrack; int indexAnimation; for (int i = 0; i < countControlTrack; i++) { if (true == TableControlTrack[i].StatusIsPlaying) { flagRequestPlayEndTrack = TableControlTrack[i].StatusIsRequestPlayEnd; indexAnimation = TableControlTrack[i].ArgumentContainer.IndexAnimation; /* Check Transition-End */ flagDecodeNextForce = false; if (true == TableControlTrack[i].StatusIsRequestTransitionEnd) { indexTrackSlave = TableControlTrack[i].IndexTrackSlave; if (0 <= indexTrackSlave) { /* Change Track Slave to Master */ /* MEMO: Overwrite slave track status. */ flagRequestPlayEndTrack = TrackChangeSlaveToMaster(i, indexTrackSlave); /* CallBack Transition-End */ if ((null != FunctionPlayEndTrack) && (null != FunctionPlayEndTrack[i])) { FunctionPlayEndTrack[i](this, i, indexTrackSlave, indexAnimation, TableControlTrack[i].ArgumentContainer.IndexAnimation ); } flagDecodeNextForce = true; } } /* Check Track Play-End */ if (true == flagRequestPlayEndTrack) { /* Stop Track */ TableControlTrack[i].Stop(); /* CallBack Play-End */ /* MEMO: At Play-End callback, "indexTrackSlave" is always -1. */ if ((null != FunctionPlayEndTrack) && (null != FunctionPlayEndTrack[i])) { FunctionPlayEndTrack[i](this, i, -1, indexAnimation, -1); } } else { flagStopAllTrack = false; } TableControlTrack[i].StatusIsRequestPlayEnd = false; TableControlTrack[i].StatusIsRequestTransitionEnd = false; } #if false TableControlTrack[i].StatusClearTransient(); #else /* MEMO: Originally should call function, but directly process (taking call-cost into account). */ /* MEMO: Since clear bits only, VALID is not judged. */ /* (Even if clearing those bits of stopping track, processing is not affected.) */ TableControlTrack[i].Status &= ~(Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.PLAYING_START | Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.DECODE_ATTRIBUTE | Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.TRANSITION_START ); if (true == flagDecodeNextForce) { TableControlTrack[i].Status |= Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.DECODE_ATTRIBUTE; } TableControlTrack[i].TimeElapseReplacement = 0.0f; #endif } /* Clear Transient-Status */ Status &= ~(FlagBitStatus.UPDATE_RATE_SCALELOCAL | FlagBitStatus.UPDATE_RATE_OPACITY | FlagBitStatus.CHANGE_TABLEMATERIAL | FlagBitStatus.CHANGE_CELLMAP ); if (null != AdditionalColor) { AdditionalColor.Status &= ~Library_SpriteStudio6.Control.AdditionalColor.FlagBitStatus.CHANGE; } /* Check Animation-End */ if (true == flagStopAllTrack) { if (0 != (Status & FlagBitStatus.PLAYING)) { /* Playing -> Stop */ if (null != FunctionPlayEnd) { if (false == FunctionPlayEnd(this, InstanceGameObjectControl)) { if (null == InstanceRootParent) { /* MEMO: When "FunctionPlayEnd" returns false, destroy self. */ /* If have "Control-Object", will destroy as well. */ /* However, can not destroy when "Instance". */ if (null != InstanceGameObjectControl) { UnityEngine.Object.Destroy(InstanceGameObjectControl); } else { UnityEngine.Object.Destroy(gameObject); } } } } } Status &= ~FlagBitStatus.PLAYING; } else { Status |= FlagBitStatus.PLAYING; } }
public bool Start(Script_SpriteStudio6_Root instanceRoot, Script_SpriteStudio6_DataAnimation dataAnimation, int indexAnimation, int frameRangeStart, int frameRangeEnd, int frame, int framePerSecond, float rateTime, float timeDelay, bool flagPingpong, int timesPlay ) { /* Check booted-up */ if (0 == (Status & FlagBitStatus.VALID)) { if (false == BootUp()) { return(false); } } /* Reset Animation */ ArgumentContainer.DataAnimation = dataAnimation; ArgumentContainer.IndexAnimation = indexAnimation; ArgumentContainer.FramePrevious = -1; /* Set datas */ Status &= FlagBitStatus.VALID; /* Clear */ Status = (true == flagPingpong) ? (Status | FlagBitStatus.STYLE_PINGPONG) : (Status & ~FlagBitStatus.STYLE_PINGPONG); Status &= ~FlagBitStatus.STYLE_REVERSE; RateTime = rateTime; if (0.0f > RateTime) { Status |= (FlagBitStatus.STYLE_REVERSE | FlagBitStatus.PLAYING_REVERSE); RateTime *= -1.0f; } FramePerSecond = framePerSecond; TimePerFrame = 1.0f / (float)FramePerSecond; FrameStart = frameRangeStart; FrameEnd = frameRangeEnd; if (0 != (Status & FlagBitStatus.PLAYING_REVERSE)) { /* Play-Reverse */ if (FrameStart >= frame) { frame = FrameEnd + 1; } } else { /* Play-Foward */ if ((FrameEnd + 1) <= frame) { frame = FrameStart - 1; } } ArgumentContainer.Frame = frame; TimesPlay = timesPlay; TimeDelay = timeDelay; CountLoop = 0; TimeElapsed = (ArgumentContainer.Frame - FrameStart) * TimePerFrame; TimeElapsedNow = 0.0f; // ArgumentContainer.Frame = Mathf.Clamp(ArgumentContainer.Frame, FrameStart, FrameEnd); Status |= (FlagBitStatus.PLAYING | FlagBitStatus.PLAYING_START ); Status &= ~(FlagBitStatus.IGNORE_NEXTUPDATE_USERDATA | FlagBitStatus.IGNORE_NEXTUPDATE_SIGNAL ); FrameRange = (FrameEnd - FrameStart) + 1; TimeRange = (float)FrameRange * TimePerFrame; TimePerFrameConsideredRateTime = TimePerFrame * RateTime; TimeElapseReplacement = 0.0f; TimeElapseInRangeReplacement = 0.0f; return(true); }
internal void LateUpdateMain(float timeElapsed, bool flagHideDefault, Library_SpriteStudio6.KindMasking masking, ref Matrix4x4 matrixCorrection, bool flagPlanarization ) { if (0 == (Status & FlagBitStatus.VALID)) { return; } if (null == DataEffect) { return; } if (false == DataEffect.StatusIsBootup) { /* Re-import data? or Re-compile during playing animation? */ return; } bool flagHide = flagHideDefault | FlagHideForce; /* Update Base */ BaseLateUpdate(timeElapsed); /* Update Playing-Status */ if (0 == (StatusPlaying & Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.PLAYING)) { /* Not-Playing */ Status &= ~FlagBitStatus.PLAYING; return; } Status |= FlagBitStatus.PLAYING; TimeElapsed += ((0 != (StatusPlaying & Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.PAUSING)) || (0 != (StatusPlaying & Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.PLAYING_START)) ) ? 0.0f : (timeElapsed * RateTime); Frame = TimeElapsed * FramePerSecond; if (0 != (Status & FlagBitStatus.PLAYING_INFINITY)) { /* Independent */ // Frame %= FrameRange; } else { /* Dependent */ Frame = Mathf.Clamp(Frame, 0.0f, FrameRange); } /* Recover Draw-Cluster & Component for Rendering */ if (null == ClusterDraw) { /* Lost */ if (false == ClusterBootUpDraw()) { /* Recovery failure */ return; } } /* MEMO: Execute combining and drawing only at Highest-Parent-Root. */ /* Clean Draw-Cluster & Component for Rendering */ if (null == InstanceRootParent) { ClusterDraw.DataPurge(); // if(false == RendererBootUpDraw(false)) // { /* Recovery failure */ // return; // } } /* Update & Draw Effect */ if (false == flagHide) { ControlEffect.Update(this, masking, ref matrixCorrection, flagPlanarization); } /* Mesh Combine & Set to Renderer */ if ((null == InstanceRootParent) && (null != MeshCombined)) { /* Clear Mesh */ MeshCombined.Clear(); MeshCombined.name = NameBatchedMesh; if (false == flagHide) { /* MEMO: Set the material-array to null issue "NullReferenceException". Leave as. */ if (true == ClusterDraw.MeshCombine(MeshCombined, ref TableMaterialCombined)) { InstanceMeshRenderer.sharedMaterials = TableMaterialCombined; } } InstanceMeshFilter.sharedMesh = MeshCombined; } /* Clear transient status */ StatusPlaying &= ~Library_SpriteStudio6.Control.Animation.Track.FlagBitStatus.PLAYING_START; Status &= ~(FlagBitStatus.UPDATE_RATE_SCALELOCAL | FlagBitStatus.UPDATE_RATE_OPACITY | FlagBitStatus.CHANGE_TABLEMATERIAL | FlagBitStatus.CHANGE_CELLMAP ); }
public bool Update(float timeElapsed) { float timeElapsedAnimation = timeElapsed * RateTime; bool flagStopJumpTime = (0.0f != TimeElapseReplacement); if (0 == (Status & FlagBitStatus.PLAYING)) { /* Stoping */ if (true == flagStopJumpTime) { /* MEMO: In frame-Jump, Elapsed time is absolute. */ timeElapsedAnimation = TimeElapseReplacement; } else { timeElapsedAnimation = 0.0f; } } TimeElapsedNow = timeElapsedAnimation; if (0 == (Status & FlagBitStatus.VALID)) { return(false); } /* Reset status */ CountLoopNow = 0; Status &= ~FlagBitStatus.PLAYING_TURN; if (0 != (Status & FlagBitStatus.PLAYING_REVERSE)) { Status |= FlagBitStatus.PLAYING_REVERSEPREVIOUS; } else { Status &= ~FlagBitStatus.PLAYING_REVERSEPREVIOUS; } /* Check Playng status */ if (0 == (Status & FlagBitStatus.PLAYING)) { /* Not-Playing */ /* MEMO: Even if the animation has ended, there are cases when you are transitioning. */ if (false == flagStopJumpTime) { goto Update_UpdateTransition; } } if (0 == (Status & FlagBitStatus.PLAYING_START)) { /* (Not Right-After-Starting) */ if (0 != (Status & FlagBitStatus.PAUSING)) { /* Play & Pausing */ #if false /* MEMO: Transition does not progress during paused. */ return(true); #else goto Update_UpdateTransition; #endif } } if (0.0f > TimeDelay) { /* Wait Infinite */ TimeDelay = -1.0f; Status &= ~(FlagBitStatus.PLAYING_START | FlagBitStatus.DECODE_ATTRIBUTE); /* Cancel Start & Decoding Attribute */ return(true); } else { /* Wait Limited-Time */ if (0.0f < TimeDelay) { /* Waiting */ TimeDelay -= timeElapsedAnimation; if (0.0f < TimeDelay) { Status &= ~(FlagBitStatus.PLAYING_START | FlagBitStatus.DECODE_ATTRIBUTE); /* Cancel Start & Decoding Attribute */ return(true); } /* Start */ timeElapsedAnimation += -TimeDelay * ((0 == (Status & FlagBitStatus.PLAYING_REVERSE)) ? 1.0f : -1.0f); TimeDelay = 0.0f; ArgumentContainer.FramePrevious = -1; Status |= (FlagBitStatus.PLAYING_START | FlagBitStatus.DECODE_ATTRIBUTE); } } if (0 != (Status & FlagBitStatus.PLAYING_START)) { /* Play & Right-After-Starting */ Status |= (FlagBitStatus.PLAYING_START | FlagBitStatus.DECODE_ATTRIBUTE); timeElapsedAnimation = 0.0f; goto Update_End; /* Display the first frame, force */ } /* Calculate New-Frame */ ArgumentContainer.FramePrevious = ArgumentContainer.Frame; bool FlagRangeOverPrevious = false; if (0 != (Status & FlagBitStatus.STYLE_PINGPONG)) { /* Play-Style: PingPong */ if (0 != (Status & FlagBitStatus.PLAYING_REVERSE)) { FlagRangeOverPrevious = (0.0f > TimeElapsed) ? true : false; TimeElapsed -= timeElapsedAnimation; if ((0.0f > TimeElapsed) && (true == FlagRangeOverPrevious)) { /* Still Range-Over */ goto Update_End; } } else { FlagRangeOverPrevious = (TimeRange <= TimeElapsed) ? true : false; TimeElapsed += timeElapsedAnimation; if ((TimeRange <= TimeElapsed) && (true == FlagRangeOverPrevious)) { /* Still Range-Over */ goto Update_End; } } if (0 != (Status & FlagBitStatus.STYLE_REVERSE)) { /* Play-Style: PingPong & Reverse */ while ((TimeRange <= TimeElapsed) || (0.0f > TimeElapsed)) { if (0 != (Status & FlagBitStatus.PLAYING_REVERSE)) { /* Now: Reverse */ if (TimeRange <= TimeElapsed) { /* MEMO: Follow "FlagRangeOverPrevious" */ break; } if (0.0f > TimeElapsed) { /* Frame-Over: Turn */ TimeElapsed += TimeRange; TimeElapsed = TimeRange - TimeElapsed; Status |= FlagBitStatus.PLAYING_TURN; Status &= ~FlagBitStatus.PLAYING_REVERSE; } } else { /* Now: Foward */ if (true == FlagRangeOverPrevious) { FlagRangeOverPrevious = false; Status |= FlagBitStatus.PLAYING_TURN; break; } else { CountLoop++; if (TimeRange <= TimeElapsed) { /* Frame-Over: Loop/End */ if (0 < TimesPlay) { /* Limited-Count Loop */ TimesPlay--; if (0 >= TimesPlay) { /* End */ goto Update_PlayEnd_Foward; } } /* Not-End */ TimeElapsed -= TimeRange; TimeElapsed = TimeRange - TimeElapsed; Status |= FlagBitStatus.PLAYING_REVERSE; Status |= FlagBitStatus.PLAYING_TURN; CountLoopNow++; } } } } } else { /* Play-Style: PingPong & Foward */ while ((TimeRange <= TimeElapsed) || (0.0f > TimeElapsed)) { if (0 != (Status & FlagBitStatus.PLAYING_REVERSE)) { /* Now: Reverse */ if (true == FlagRangeOverPrevious) { FlagRangeOverPrevious = false; Status |= FlagBitStatus.PLAYING_TURN; break; } else { CountLoop++; if (0.0f > TimeElapsed) { /* Frame-Over: Loop/End */ if (0 < TimesPlay) { /* Limited-Count Loop */ TimesPlay--; if (0 >= TimesPlay) { /* End */ goto AnimationUpdate_PlayEnd_Reverse; } } /* Not-End */ TimeElapsed += TimeRange; TimeElapsed = TimeRange - TimeElapsed; Status &= ~FlagBitStatus.PLAYING_REVERSE; Status |= FlagBitStatus.PLAYING_TURN; CountLoopNow++; } } } else { /* Now: Foward */ if (0.0f > TimeElapsed) { /* MEMO: Follow "FlagRangeOverPrevious" */ break; } if (TimeRange <= TimeElapsed) { /* Frame-Over: Turn */ TimeElapsed -= TimeRange; TimeElapsed = TimeRange - TimeElapsed; Status |= FlagBitStatus.PLAYING_TURN; Status |= FlagBitStatus.PLAYING_REVERSE; } } } } } else { /* Play-Style: OneWay */ if (0 != (Status & FlagBitStatus.STYLE_REVERSE)) { /* Play-Style: OneWay & Reverse */ FlagRangeOverPrevious = (0.0f > TimeElapsed) ? true : false; TimeElapsed -= timeElapsedAnimation; if ((0.0f > TimeElapsed) && (true == FlagRangeOverPrevious)) { /* Still Range-Over */ goto Update_End; } while (0.0f > TimeElapsed) { TimeElapsed += TimeRange; if (true == FlagRangeOverPrevious) { FlagRangeOverPrevious = false; Status |= FlagBitStatus.PLAYING_TURN; } else { CountLoop++; if (0 < TimesPlay) { /* Limited-Count Loop */ TimesPlay--; if (0 >= TimesPlay) { /* End */ goto AnimationUpdate_PlayEnd_Reverse; } } /* Not-End */ CountLoopNow++; Status |= FlagBitStatus.PLAYING_TURN; } } } else { /* Play-Style: OneWay & Foward */ FlagRangeOverPrevious = (TimeRange <= TimeElapsed) ? true : false; TimeElapsed += timeElapsedAnimation; if ((TimeRange <= TimeElapsed) && (true == FlagRangeOverPrevious)) { /* Still Range-Over */ goto Update_End; } while (TimeRange <= TimeElapsed) { TimeElapsed -= TimeRange; if (true == FlagRangeOverPrevious) { FlagRangeOverPrevious = false; Status |= FlagBitStatus.PLAYING_TURN; } else { CountLoop++; if (0 < TimesPlay) { /* Limited-Count Loop */ TimesPlay--; if (0 >= TimesPlay) { /* End */ goto Update_PlayEnd_Foward; } } /* Not-End */ Status |= FlagBitStatus.PLAYING_TURN; CountLoopNow++; } } } } Update_End :; { int frame = (int)(TimeElapsed / TimePerFrame); // frame = Mathf.Clamp(frame, 0, (FrameRange - 1)); frame += FrameStart; if (((frame != ArgumentContainer.FramePrevious) || (0 != (Status & FlagBitStatus.PLAYING_TURN))) || (true == flagStopJumpTime) ) { Status |= FlagBitStatus.DECODE_ATTRIBUTE; } ArgumentContainer.Frame = frame; } // goto Update_UpdateTransition; Update_UpdateTransition :; Status &= ~FlagBitStatus.REQUEST_TRANSITIONEND; if (0 <= IndexTrackSecondary) { TimeElapsedTransition += timeElapsed; /* Transition's elapsed time exclude RateTime */ if (TimeLimitTransition <= TimeElapsedTransition) { /* End */ RateTransition = 1.0f; /* Clip */ Status |= FlagBitStatus.REQUEST_TRANSITIONEND; } else { RateTransition = TimeElapsedTransition / TimeLimitTransition; } } return(true); Update_PlayEnd_Foward :; TimesPlay = 0; /* Clip */ Status |= (FlagBitStatus.REQUEST_PLAYEND | FlagBitStatus.DECODE_ATTRIBUTE); TimeElapsed = TimeRange; ArgumentContainer.Frame = FrameEnd; goto Update_UpdateTransition; AnimationUpdate_PlayEnd_Reverse :; TimesPlay = 0; /* Clip */ Status |= (FlagBitStatus.REQUEST_PLAYEND | FlagBitStatus.DECODE_ATTRIBUTE); TimeElapsed = 0.0f; ArgumentContainer.Frame = FrameStart; goto Update_UpdateTransition; }