/* ******************************************************** */ //! Start playing the animation /*! * @param No * Animation's Index<br> * -1 == Now-Setting Index is not changed * @param PlayTimes * 0 == Infinite-looping <br> * 1 == Not looping <br> * 2 <= Number of Plays * @param StartFrameNo * Offset frame-number of starting Play in animation (0 origins). <br> * -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> * "No" is the Animation's Index (Get the Index in the "AnimationGetIndexNo" function.). <br> * Give "0" to "No" when the animation included in (imported "ssae") data is one. <br> * When the Animation's Index not existing is given, this function returns false. <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 No, int PlayTimes, int StartFrameNo = -1, float RateTime = 0.0f) { /* Error-Check */ if (-1 != No) { animationNo = No; /* Don't Use "AnimationNo" (occur "Stack-Overflow") */ } if ((0 > animationNo) || (ListInformationPlay.Length <= animationNo)) { return(false); } /* Set Playing-Datas */ Status &= ~(BitStatus.PAUSING | BitStatus.REQUEST_PLAYEND); Status |= BitStatus.PLAYING; Status |= BitStatus.DECODE_USERDATA; /* Set Animation Information */ frameNoStart = ListInformationPlay[animationNo].FrameStart; frameNoEnd = ListInformationPlay[animationNo].FrameEnd; framePerSecond = ListInformationPlay[animationNo].FramePerSecond; int CountFrame = (frameNoEnd - frameNoStart) + 1; if (-1 == StartFrameNo) { /* Use "FrameNoInitial" */ StartFrameNo = ((0 <= FrameNoInitial) && (CountFrame > FrameNoInitial)) ? FrameNoInitial : 0; } else { /* Direct-Frame */ StartFrameNo = ((0 <= StartFrameNo) && (CountFrame > StartFrameNo)) ? StartFrameNo : 0; } frameNoNow = frameNoStart + StartFrameNo; /* Set Status */ frameNoPrevious = -1; RateTimeAnimation = (0.0f == RateTime) ? RateTimeAnimation : RateTime; TimeAnimation = StartFrameNo * TimeFramePerSecond; int CountLoop = PlayTimes - 1; if ((-1 == CountLoop) || (0 < CountLoop)) { /* Value-Valid (-1 == Infinite-Loop) */ CountLoopRemain = CountLoop; } else { /* Play-once or Value-Invalid */ CountLoopRemain = 0; } /* UserData-CallBack Buffer Create */ if (null == ListCallBackUserData) { ListCallBackUserData = new ArrayList(); } ListCallBackUserData.Clear(); return(true); }
void Awake() { var root = gameObject.GetComponent <Script_SpriteStudio_PartsRoot>(); foreach (var MaterialNow in root.TableMaterial) { MaterialNow.shader = Shader.Find(MaterialNow.shader.name); } Status = ~BitStatus.MASK_INITIAL; }
public ActionBarBits(PlayerReader playerReader, ISquareReader reader, params int[] cells) { this.playerReader = playerReader; bits = new BitStatus[cells.Length]; for (int i = 0; i < bits.Length; i++) { bits[i] = new BitStatus(reader.GetIntAtCell(cells[i])); } }
/* ******************************************************** */ //! 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 (true == FlagSwitch) { Status |= BitStatus.PAUSING; } else { Status &= ~BitStatus.PAUSING; } return(true); }
void LateUpdate() { /* Excute "UserData CallBack" */ if ((null != ListCallBackUserData) && (null != functionUserData)) { int Count = ListCallBackUserData.Count; ParameterCallBackUserData Parameter = null; for (int i = 0; i < Count; i++) { Parameter = ListCallBackUserData[i] as ParameterCallBackUserData; functionUserData(transform.parent.gameObject, Parameter.PartsName, Parameter.AnimationDataParts, AnimationNo, frameNoNow, Parameter.FrameNo, Parameter.Data, Parameter.FlagWayBack ); } ListCallBackUserData.Clear(); } /* Excute "Play-End CallBack" */ if (0 != (Status & BitStatus.REQUEST_PLAYEND)) { Status = BitStatus.CLEAR; if (null != functionPlayEnd) { if (null == InstanceGameObjectControl) { /* has no Control-Node */ if (false == functionPlayEnd(gameObject)) { Object.Destroy(gameObject); } } else { /* has Control-Node */ if (false == functionPlayEnd(InstanceGameObjectControl)) { Object.Destroy(InstanceGameObjectControl); } } } } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Contains(null) || values.Contains(DependencyProperty.UnsetValue)) { return(Brushes.Red); } LogicLevelResult res = values[1] as LogicLevelResult; if (!res.Success || res.Level == LogicLevel.Low) { return(Brushes.Red); } bool isWarningBitSet = false; for (int i = 2; i < values.Length; i++) { BitStatus bs = (BitStatus)values[i]; switch (bs) { case BitStatus.Fault: return(Brushes.Red); case BitStatus.Warning: isWarningBitSet = true; break; default: break; } } if (isWarningBitSet) { return(Brushes.Orange); } return(Brushes.Green); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(Brushes.Black); } BitStatus bs = (BitStatus)value; switch (bs) { case BitStatus.Fault: return(Brushes.White); case BitStatus.Warning: return(Brushes.Black); case BitStatus.BitNotImplemented: return(new SolidColorBrush(Color.FromArgb(0xFF, 0x83, 0x83, 0x83))); default: return(Brushes.Black); } }
void Update() { MainLoopCount++; /* Boot-Check */ if (null == InstanceCameraDraw) { InstanceCameraDraw = Library_SpriteStudio.Utility.CameraGetParent(gameObject); } if (null == InstanceDrawManagerView) { InstanceDrawManagerView = Library_SpriteStudio.Utility.DrawManagerViewGetParent(gameObject); } if (null == arrayListMeshDraw) { arrayListMeshDraw = new Library_SpriteStudio.DrawManager.ArrayListMeshDraw(); arrayListMeshDraw.BootUp(); } if (null == ListCallBackUserData) { ListCallBackUserData = new ArrayList(); ListCallBackUserData.Clear(); } /* Entry Object to Draw */ if ((null != InstanceDrawManagerView) && (null == partsRootOrigin)) { /* Not "Instance"-Object */ if (false == FlagHideForce) { InstanceDrawManagerView.DrawEntryObject(this); } } /* Animation Update */ if (null == SpriteStudioData) { return; } if (null == ListInformationPlay) { return; } if (0 == (Status & BitStatus.PLAYING)) { return; } if (0 != (Status & BitStatus.PAUSING)) { return; } int FrameCountNow = 0; int FrameCountEnd = frameNoEnd - frameNoStart; int FrameCountFull = FrameCountEnd + 1; float RateTimeProgress = (0 == (Status & BitStatus.PLAYING_REVERSE)) ? 1.0f : -1.0f; float TimeAnimationFull = (float)FrameCountFull * TimeFramePerSecond; bool FlagLoop = false; bool FlagReLoop = true; /* FrameNo Update */ Status |= BitStatus.PLAY_FIRST; if (-1 != frameNoPrevious) { /* Not Update, Just Starting */ TimeAnimation += (Time.deltaTime * rateTimePlay) * RateTimeProgress; Status &= ~BitStatus.DECODE_USERDATA; Status &= ~BitStatus.PLAY_FIRST; } FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); countLoopThisTime = 0; flagTurnBackPingPong = false; flagReversePrevious = (0 != (Status & BitStatus.PLAYING_REVERSE)) ? true : false; Status &= ~BitStatus.REDECODE_INSTANCE; if (false == FlagStylePingpong) { /* One-Way */ if (0 == (Status & BitStatus.PLAYING_REVERSE)) { /* Play foward */ /* Get Frame Count */ if (FrameCountEnd < FrameCountNow) { /* Frame-Over */ FlagLoop = true; FlagReLoop = true; while (true == FlagReLoop) { /* Loop-Count Check */ if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; FlagLoop = (0 > CountLoopRemain) ? false : FlagLoop; } /* ReCalculate Frame */ if (true == FlagLoop) { /* Loop */ countLoopThisTime++; /* ReCalculate Frame */ TimeAnimation -= TimeAnimationFull; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); FlagReLoop = (TimeAnimationFull <= TimeAnimation) ? true : false; /* Set Instance Parts Restart Request */ Status |= BitStatus.REDECODE_INSTANCE; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; } else { /* End */ TimeAnimation = ((float)FrameCountEnd) * TimeFramePerSecond; FrameCountNow = FrameCountEnd; // Status &= ~BitStatus.PLAYING; Status |= BitStatus.REQUEST_PLAYEND; FlagReLoop = false; } } } } else { /* Play backwards */ /* Get Frame Count */ if (0 > FrameCountNow) { /* Frame-Over */ FlagLoop = true; FlagReLoop = true; while (true == FlagReLoop) { /* Loop-Count Check */ if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; FlagLoop = (0 > CountLoopRemain) ? false : FlagLoop; } /* ReCalculate Frame */ if (true == FlagLoop) { /* Loop */ countLoopThisTime++; /* ReCalculate Frame */ TimeAnimation += TimeAnimationFull; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); FlagReLoop = (0.0f > TimeAnimation) ? true : false; /* Set Instance Parts Restart Request */ Status |= BitStatus.REDECODE_INSTANCE; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; } else { /* End */ TimeAnimation = 0.0f; FrameCountNow = 0; // Status &= ~BitStatus.PLAYING; Status |= BitStatus.REQUEST_PLAYEND; FlagReLoop = false; } } } } } else { /* Ping-Pong */ if (0 == (Status & BitStatus.STYLE_REVERSE)) { /* Style-Normaly */ FlagReLoop = true; while (true == FlagReLoop) { FlagReLoop = false; if (0 == (Status & BitStatus.PLAYING_REVERSE)) { /* Play foward */ if (FrameCountEnd < FrameCountNow) { /* Frame-Over */ /* Set Turn-Back */ Status |= BitStatus.PLAYING_REVERSE; /* ReCalculate Frame */ TimeAnimation -= TimeAnimationFull; TimeAnimation = TimeAnimationFull - TimeAnimation; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); flagTurnBackPingPong = true; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; /* Plural Loop Count Check */ FlagReLoop = ((TimeAnimationFull > TimeAnimation) && (0.0f <= TimeAnimation)) ? false : true; } } else { /* Play backwards */ if (0 > FrameCountNow) { /* Frame-Over */ FlagLoop = true; /* Loop-Count Check */ if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; FlagLoop = (0 > CountLoopRemain) ? false : FlagLoop; } if (true == FlagLoop) { /* Loop */ countLoopThisTime++; /* Set Turn-Back */ Status &= ~BitStatus.PLAYING_REVERSE; /* ReCalculate Frame */ TimeAnimation += TimeAnimationFull; TimeAnimation = TimeAnimationFull - TimeAnimation; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); flagTurnBackPingPong = true; /* Set Instance Parts Restart Request */ Status |= BitStatus.REDECODE_INSTANCE; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; /* Plural Loop Count Check */ FlagReLoop = ((TimeAnimationFull > TimeAnimation) && (0.0f <= TimeAnimation)) ? false : true; } else { /* End */ TimeAnimation = 0.0f; FrameCountNow = 0; // Status &= ~BitStatus.PLAYING; Status |= BitStatus.REQUEST_PLAYEND; FlagReLoop = false; } } } } } else { /* Style-Reverse */ FlagReLoop = true; while (true == FlagReLoop) { FlagReLoop = false; if (0 != (Status & BitStatus.PLAYING_REVERSE)) { /* Play backwards */ if (0 > FrameCountNow) { /* Frame-Over */ /* Set Turn-Back */ Status &= ~BitStatus.PLAYING_REVERSE; /* ReCalculate Frame */ TimeAnimation += TimeAnimationFull; TimeAnimation = TimeAnimationFull - TimeAnimation; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); flagTurnBackPingPong = true; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; /* Plural Loop Count Check */ FlagReLoop = ((TimeAnimationFull > TimeAnimation) && (0.0f <= TimeAnimation)) ? false : true; } } else { /* Play foward */ if (FrameCountEnd < FrameCountNow) { /* Frame-Over */ FlagLoop = true; /* Loop-Count Check */ if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; FlagLoop = (0 > CountLoopRemain) ? false : FlagLoop; } if (true == FlagLoop) { /* Loop */ countLoopThisTime++; /* Set Turn-Back */ Status |= BitStatus.PLAYING_REVERSE; /* ReCalculate Frame */ TimeAnimation -= TimeAnimationFull; TimeAnimation = TimeAnimationFull - TimeAnimation; FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); flagTurnBackPingPong = true; /* Set Instance Parts Restart Request */ Status |= BitStatus.REDECODE_INSTANCE; /* Force-Decode UserData */ Status |= BitStatus.DECODE_USERDATA; /* Plural Loop Count Check */ FlagReLoop = ((TimeAnimationFull > TimeAnimation) && (0.0f <= TimeAnimation)) ? false : true; } else { /* End */ TimeAnimation = ((float)FrameCountEnd) * TimeFramePerSecond; FrameCountNow = FrameCountEnd; // Status &= ~BitStatus.PLAYING; Status |= BitStatus.REQUEST_PLAYEND; FlagReLoop = false; } } } } } } /* Member-Valiables Update */ int FrameNoNew = frameNoStart + FrameCountNow; if (FrameNoNew != frameNoNow) { Status |= BitStatus.DECODE_USERDATA; } frameNoPrevious = frameNoNow; frameNoNow = FrameNoNew; /* Update User-CallBack */ SpriteStudioData.UpdateUserData(frameNoNow, gameObject, this); /* Update GameObject */ SpriteStudioData.UpdateGameObject(gameObject, frameNoNow, false); }
/* ******************************************************** */ //! Force Boot-Up /*! * @param * (None) * @retval Return-Value * (None) * * Don't use this function. <br> * (This function is for the Importer in Editor) */ public void BootUpForce() { SpriteStudioData = new Library_SpriteStudio.AnimationData(); RateTimeAnimation = 1.0f; Status = BitStatus.CLEAR; }
/* ******************************************************** */ //! Stop playing the animation /*! * @param * (None) * @retval Return-Value * (None) * * The playing of animation stops. */ public void AnimationStop() { Status &= ~BitStatus.PLAYING; }
/* ******************************************************** */ //! Stop playing the animation /*! @param (None) @retval Return-Value (None) The playing of animation stops. */ public void AnimationStop() { Status &= ~BitStatus.PLAYING; }
/* ******************************************************** */ //! Start playing the animation /*! @param No Animation's Index<br> -1 == Now-Setting Index is not changed @param PlayTimes 0 == Infinite-looping <br> 1 == Not looping <br> 2 <= Number of Plays @param StartFrameNo Offset frame-number of starting Play in animation (0 origins). <br> -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> "No" is the Animation's Index (Get the Index in the "AnimationGetIndexNo" function.). <br> Give "0" to "No" when the animation included in (imported "ssae") data is one. <br> When the Animation's Index not existing is given, this function returns false. <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 No, int PlayTimes, int StartFrameNo=-1, float RateTime=0.0f) { /* Error-Check */ if(-1 != No) { animationNo = No; /* Don't Use "AnimationNo" (occur "Stack-Overflow") */ } if((0 > animationNo) || (ListInformationPlay.Length <= animationNo)) { return(false); } /* Set Playing-Datas */ Status &= ~(BitStatus.PAUSING | BitStatus.REQUEST_PLAYEND); Status |= BitStatus.PLAYING; Status |= BitStatus.DECODE_USERDATA; /* Set Animation Information */ frameNoStart = ListInformationPlay[animationNo].FrameStart; frameNoEnd = ListInformationPlay[animationNo].FrameEnd; framePerSecond = ListInformationPlay[animationNo].FramePerSecond; int CountFrame = (frameNoEnd - frameNoStart) + 1; if(-1 == StartFrameNo) { /* Use "FrameNoInitial" */ StartFrameNo = ((0 <= FrameNoInitial) && (CountFrame > FrameNoInitial)) ? FrameNoInitial : 0; } else { /* Direct-Frame */ StartFrameNo = ((0 <= StartFrameNo) && (CountFrame > StartFrameNo)) ? StartFrameNo : 0; } frameNoNow = frameNoStart + StartFrameNo; /* Set Status */ frameNoPrevious = -1; RateTimeAnimation = (0.0f == RateTime) ? RateTimeAnimation : RateTime; TimeAnimation = StartFrameNo * TimeFramePerSecond; int CountLoop = PlayTimes - 1; if((-1 == CountLoop) || (0 < CountLoop)) { /* Value-Valid (-1 == Infinite-Loop) */ CountLoopRemain = CountLoop; } else { /* Play-once or Value-Invalid */ CountLoopRemain = 0; } /* UserData-CallBack Buffer Create */ if(null == ListCallBackUserData) { ListCallBackUserData = new ArrayList(); } ListCallBackUserData.Clear(); 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(true == FlagSwitch) { Status |= BitStatus.PAUSING; } else { Status &= ~BitStatus.PAUSING; } return(true); }
protected void AppendExecLateUpdate() { /* Execute Simplified-SpriteDrawManager */ int Count = 0; MeshFilter InstanceMeshFilter = GetComponent <MeshFilter>(); MeshRenderer InstanceMeshRenderer = GetComponent <MeshRenderer>(); if (null != TableListMesh) { ListMeshDraw ListMesh = null; Count = TableListMesh.Count; int CountMesh = 0; Material[] MaterialTable = new Material[Count]; int ValueRenderQueue = ValueKindDrawQueue[(int)KindRenderQueueBase]; int MaterialRenderQueue = 0; if (null == InstanceCameraDraw) { /* Camera is lost ? */ CameraGetRendering(); } int ZOffset = 0; if (null != InstanceCameraDraw) { Vector3 PositionViewPort = (null != InstanceCameraDraw) ? InstanceCameraDraw.WorldToViewportPoint(transform.position) : Vector3.zero; float RateLinerZ = 1.0f - ((PositionViewPort.z - InstanceCameraDraw.nearClipPlane) / (InstanceCameraDraw.farClipPlane - InstanceCameraDraw.nearClipPlane)); ZOffset = ((0.0f > RateLinerZ) || (1.0f < RateLinerZ)) ? -1 : (int)(RateLinerZ * RateDrawQueueEffectZ); } if (-1 == ZOffset) { /* out of sight (Clipping) */ InstanceMeshRenderer.enabled = false; } else { /* in sight */ InstanceMeshRenderer.enabled = true; for (int i = 0; i < Count; i++) { ListMesh = TableListMesh[i] as ListMeshDraw; CountMesh += ListMesh.Count; MaterialTable[i] = new Material(TableMaterial[ListMesh.MaterialNo]); MaterialRenderQueue = (-1 == ValueRenderQueue) ? MaterialTable[i].shader.renderQueue : ValueRenderQueue; MaterialRenderQueue += (OffsetDrawQueue + ZOffset + i); MaterialTable[i].renderQueue = MaterialRenderQueue; } Material[] TableMaterialOld = InstanceMeshRenderer.sharedMaterials; InstanceMeshRenderer.sharedMaterials = MaterialTable; for (int i = 0; i < TableMaterialOld.Length; i++) { Object.DestroyImmediate(TableMaterialOld[i]); } int IndexVertexNow = 0; int IndexTriangleNow = 0; int[] IndexVertex = new int[Count]; int[] IndexTriangle = new int[Count + 1]; CombineInstance[] CombineMesh = new CombineInstance[CountMesh]; InformationMeshData DataMeshInformation = null; CountMesh = 0; for (int i = 0; i < Count; i++) { ListMesh = TableListMesh[i] as ListMeshDraw; IndexVertex[i] = IndexVertexNow; IndexTriangle[i] = IndexTriangleNow; DataMeshInformation = ListMesh.MeshDataTop; Matrix4x4 MatrixCorrect = transform.localToWorldMatrix.inverse; while (null != DataMeshInformation) { CombineMesh[CountMesh].mesh = DataMeshInformation.DataMesh; CombineMesh[CountMesh].transform = MatrixCorrect * DataMeshInformation.DataTransform.localToWorldMatrix; CountMesh++; IndexVertexNow += DataMeshInformation.DataMesh.vertexCount; IndexTriangleNow += DataMeshInformation.DataMesh.triangles.Length / 3; DataMeshInformation = DataMeshInformation.ChainNext; } } IndexTriangle[Count] = IndexTriangleNow; Mesh MeshNew = new Mesh(); MeshNew.CombineMeshes(CombineMesh); int[] TriangleBuffer = MeshNew.triangles; int[] VertexNoTriangle = null; MeshNew.triangles = null; MeshNew.subMeshCount = Count; for (int i = 0; i < Count; i++) { CountMesh = IndexTriangle[i + 1] - IndexTriangle[i]; VertexNoTriangle = new int[CountMesh * 3]; for (int j = 0; j < CountMesh; j++) { IndexTriangleNow = (j + IndexTriangle[i]) * 3; IndexVertexNow = j * 3; VertexNoTriangle[IndexVertexNow] = TriangleBuffer[IndexTriangleNow]; VertexNoTriangle[IndexVertexNow + 1] = TriangleBuffer[IndexTriangleNow + 1]; VertexNoTriangle[IndexVertexNow + 2] = TriangleBuffer[IndexTriangleNow + 2]; } MeshNew.SetTriangles(VertexNoTriangle, i); } if (null != InstanceMeshFilter.sharedMesh) { InstanceMeshFilter.sharedMesh.Clear(); Object.DestroyImmediate(InstanceMeshFilter.sharedMesh); } InstanceMeshFilter.sharedMesh = MeshNew; } TableListMesh.Clear(); } /* Excute "UserData CallBack" */ if ((null != ListCallBackUserData) && (null != functionUserData)) { Count = ListCallBackUserData.Count; ParameterCallBackUserData Parameter = null; for (int i = 0; i < Count; i++) { Parameter = ListCallBackUserData[i] as ParameterCallBackUserData; functionUserData(transform.parent.gameObject, Parameter.PartsName, Parameter.AnimationDataParts, AnimationNo, frameNoNow, Parameter.FrameNo, Parameter.Data ); } ListCallBackUserData.Clear(); } /* Excute "Play-End CallBack" */ if (0 != (Status & BitStatus.REQUEST_PLAYEND)) { Status = BitStatus.CLEAR; if (null != functionPlayEnd) { if (false == (functionPlayEnd(transform.parent.gameObject))) { InstanceMeshFilter.sharedMesh.Clear(); Object.DestroyImmediate(InstanceMeshFilter.sharedMesh); InstanceMeshFilter.sharedMesh = null; Destroy(transform.parent.gameObject); } } } }
protected void AppendExecUpdate() { if (null != SpriteStudioData) { if (null != ListInformationPlay) { if (0 != (Status & BitStatus.PLAYING)) { if (0 == (Status & BitStatus.PAUSING)) { /* Get Frame Count */ if (-1 != frameNoPrevious) { /* Not Update, Just Starting */ TimeAnimation += (Time.deltaTime * RateTimeAnimation); Status &= ~BitStatus.DECODE_USERDATA; } int FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); int FrameCountEnd = frameNoEnd - frameNoStart; if (0.0f <= RateTimeAnimation) { /* Play normaly */ if (FrameCountEnd < FrameCountNow) { /* Frame-Over */ /* Loop-Count Check */ bool FlagLoop = true; if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; if (0 > CountLoopRemain) { FlagLoop = false; } } /* ReCalculate Frame */ if (true == FlagLoop) { /* Loop */ int FrameCountFull = FrameCountEnd + 1; TimeAnimation -= ((float)FrameCountFull * TimeFramePerSecond); FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); } else { /* End */ TimeAnimation = ((float)FrameCountEnd) * TimeFramePerSecond; FrameCountNow = FrameCountEnd; Status |= BitStatus.REQUEST_PLAYEND; } } /* Frame-No Set */ int FrameNoNew = frameNoStart + FrameCountNow; if (FrameNoNew != frameNoNow) { Status |= BitStatus.DECODE_USERDATA; } frameNoPrevious = frameNoNow; frameNoNow = FrameNoNew; } else { /* Play backwards */ if (0 > FrameCountNow) { /* Frame-Over */ /* Loop-Count Check */ bool FlagLoop = true; if (0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; if (0 > CountLoopRemain) { FlagLoop = false; } } /* ReCalculate Frame */ if (true == FlagLoop) { /* Loop */ int FrameCountFull = FrameCountEnd + 1; TimeAnimation += ((float)FrameCountFull * TimeFramePerSecond); FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); } else { /* End */ TimeAnimation = 0.0f; FrameCountNow = 0; Status |= BitStatus.REQUEST_PLAYEND; } } /* Frame-No Set */ int FrameNoNew = frameNoStart + FrameCountNow; if (FrameNoNew != frameNoNow) { Status |= BitStatus.DECODE_USERDATA; } frameNoPrevious = frameNoNow; frameNoNow = FrameNoNew; } /* Update User-CallBack */ SpriteStudioData.UpdateUserData(frameNoNow, gameObject, this); /* Update GameObject */ SpriteStudioData.UpdateGameObject(gameObject, frameNoNow); } } } } }
/* ******************************************************** */ //! Start playing the animation /*! * @param No * Animation's Index<br> * -1 == Now-Setting Index is not changed<br> * default: -1 * @param PlayTimes * -1 == Now-Setting "CountLoopRemain" is not changed * 0 == Infinite-looping <br> * 1 == Not looping <br> * 2 <= Number of Plays<br> * default: -1 * @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 * @param LabelStart * Label-name of starting Play in animation. * "_start" == Top-frame of Animation (reserved label-name)<br> * "" == use "NameLabelStart"<br> * default: "" * @param FrameOffsetStart * Offset frame-number from LabelStart * Animation's Top-frame is "LabelStart + FrameOffsetStart".<br> * int.MinValue == use "OffsetFrameStart" * default: int.MinValue * @param LabelEnd * Label-name of the terminal in animation. * "_end" == Last-frame of Animation (reserved label-name)<br> * "" == use "NameLabelEnd"<br> * default: "" * @param FrameOffsetEnd * Offset frame-number from LabelEnd * Animation's Last-frame is "LabelEnd + FrameOffsetEnd".<br> * int.MaxValue == use "OffsetFrameEnd" * default: int.MaxValue * @retval Return-Value * true == Success <br> * false == Failure (Error) * * The playing of animation begins. <br> * <br> * "No" is the Animation's Index (Get the Index in the "AnimationGetIndexNo" function.). <br> * Give "0" to "No" when the animation included in (imported "ssae") data is one. <br> * When the Animation's Index not existing is given, this function returns false. <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 No = -1, int TimesPlay = -1, int FrameInitial = -1, float RateTime = 0.0f, PlayStyle KindStylePlay = PlayStyle.NO_CHANGE, string LabelStart = "", int FrameOffsetStart = int.MinValue, string LabelEnd = "", int FrameOffsetEnd = int.MaxValue ) { /* Error-Check */ animationNo = (-1 != No) ? No : animationNo; /* Don't Use "AnimationNo" (occur "Stack-Overflow") */ if ((0 > animationNo) || (ListInformationPlay.Length <= animationNo)) { return(false); } /* Set Playing-Datas */ Status &= ~BitStatus.MASK_INITIAL; Status |= BitStatus.PLAYING; Status |= BitStatus.DECODE_USERDATA; switch (KindStylePlay) { case PlayStyle.NO_CHANGE: break; case PlayStyle.NORMAL: FlagStylePingpong = false; break; case PlayStyle.PINGPONG: FlagStylePingpong = true; break; default: goto case PlayStyle.NO_CHANGE; } /* Set Animation Information */ int FrameNo; Library_SpriteStudio.AnimationInformationPlay InformationAnimation = ListInformationPlay[animationNo]; string Label = ""; Label = string.Copy((true == string.IsNullOrEmpty(LabelStart)) ? NameLabelStart : LabelStart); if (true == string.IsNullOrEmpty(Label)) { Label = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultStart); } FrameNo = InformationAnimation.FrameNoGetLabel(Label); if (-1 == FrameNo) { /* Label Not Found */ FrameNo = InformationAnimation.FrameStart; } FrameNo += (int.MinValue == FrameOffsetStart) ? OffsetFrameStart : FrameOffsetStart; if ((InformationAnimation.FrameStart > FrameNo) || (InformationAnimation.FrameEnd < FrameNo)) { FrameNo = InformationAnimation.FrameStart; } frameNoStart = FrameNo; Label = string.Copy((true == string.IsNullOrEmpty(LabelEnd)) ? NameLabelEnd : LabelEnd); if (true == string.IsNullOrEmpty(Label)) { Label = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultEnd); } FrameNo = InformationAnimation.FrameNoGetLabel(Label); if (-1 == FrameNo) { /* Label Not Found */ FrameNo = InformationAnimation.FrameEnd; } FrameNo += (int.MaxValue == FrameOffsetEnd) ? OffsetFrameEnd : FrameOffsetEnd; if ((InformationAnimation.FrameStart > FrameNo) || (InformationAnimation.FrameEnd < FrameNo)) { FrameNo = InformationAnimation.FrameEnd; } frameNoEnd = FrameNo; framePerSecond = (null == partsRootOrigin) ? InformationAnimation.FramePerSecond : partsRootOrigin.FramePerSecond; int CountFrame = (frameNoEnd - frameNoStart) + 1; if (-1 == FrameInitial) { /* Use "FrameNoInitial" */ FrameInitial = ((0 <= FrameNoInitial) && (CountFrame > FrameNoInitial)) ? FrameNoInitial : 0; } else { /* Direct-Frame */ FrameInitial = ((0 <= FrameInitial) && (CountFrame > FrameInitial)) ? FrameInitial : 0; } // frameNoNow = FrameInitial; frameNoNow = FrameInitial + frameNoStart; frameNoPrevious = -1; RateTime = (0.0f == RateTime) ? RateTimeAnimation : RateTime; if (0.0f > RateTime) { Status = (0 == (Status & BitStatus.STYLE_REVERSE)) ? (Status | BitStatus.STYLE_REVERSE) : (Status & ~BitStatus.STYLE_REVERSE); RateTime *= -1.0f; } rateTimePlay = RateTime; Status |= (0 != (Status & BitStatus.STYLE_REVERSE)) ? BitStatus.PLAYING_REVERSE : 0; if (0 != (Status & BitStatus.PLAYING_REVERSE)) { /* Play-Reverse & Start Top-Frame */ frameNoNow = (frameNoNow <= frameNoStart) ? frameNoEnd : frameNoNow; } else { /* Play-Normal & Start End-Frame */ frameNoNow = (frameNoNow >= frameNoEnd) ? frameNoStart : frameNoNow; } // TimeAnimation = frameNoNow * TimeFramePerSecond; TimeAnimation = (frameNoNow - frameNoStart) * TimeFramePerSecond; if (-1 != TimesPlay) { /* MEMO: TimesPlay is Invalid, Force Play-Once */ CountLoopRemain = (0 > TimesPlay) ? 0 : (TimesPlay - 1); } /* UserData-CallBack Buffer Create */ if (null == ListCallBackUserData) { ListCallBackUserData = new ArrayList(); } ListCallBackUserData.Clear(); return(true); }
protected void AppendExecLateUpdate() { /* Execute Simplified-SpriteDrawManager */ int Count = 0; MeshFilter InstanceMeshFilter = GetComponent<MeshFilter>(); MeshRenderer InstanceMeshRenderer = GetComponent<MeshRenderer>(); if(null != TableListMesh) { ListMeshDraw ListMesh = null; Count = TableListMesh.Count; int CountMesh = 0; Material[] MaterialTable = new Material[Count]; int ValueRenderQueue = ValueKindDrawQueue[(int)KindRenderQueueBase]; int MaterialRenderQueue = 0; if(null == InstanceCameraDraw) { /* Camera is lost ? */ CameraGetRendering(); } int ZOffset = 0; if(null != InstanceCameraDraw) { Vector3 PositionViewPort = (null != InstanceCameraDraw) ? InstanceCameraDraw.WorldToViewportPoint(transform.position) : Vector3.zero; float RateLinerZ = 1.0f - ((PositionViewPort.z - InstanceCameraDraw.nearClipPlane) / (InstanceCameraDraw.farClipPlane - InstanceCameraDraw.nearClipPlane)); ZOffset = ((0.0f > RateLinerZ) || (1.0f < RateLinerZ)) ? -1 : (int)(RateLinerZ * RateDrawQueueEffectZ); } if(-1 == ZOffset) { /* out of sight (Clipping) */ InstanceMeshRenderer.enabled = false; } else { /* in sight */ InstanceMeshRenderer.enabled = true; for(int i=0; i<Count; i++) { ListMesh = TableListMesh[i] as ListMeshDraw; CountMesh += ListMesh.Count; MaterialTable[i] = new Material(TableMaterial[ListMesh.MaterialNo]); MaterialRenderQueue = (-1 == ValueRenderQueue) ? MaterialTable[i].shader.renderQueue : ValueRenderQueue; MaterialRenderQueue += (OffsetDrawQueue + ZOffset + i); MaterialTable[i].renderQueue = MaterialRenderQueue; } Material[] TableMaterialOld = InstanceMeshRenderer.sharedMaterials; InstanceMeshRenderer.sharedMaterials = MaterialTable; for(int i=0; i<TableMaterialOld.Length; i++) { Object.DestroyImmediate(TableMaterialOld[i]); } int IndexVertexNow = 0; int IndexTriangleNow = 0; int[] IndexVertex = new int[Count]; int[] IndexTriangle = new int[Count+1]; CombineInstance[] CombineMesh = new CombineInstance[CountMesh]; InformationMeshData DataMeshInformation = null; CountMesh = 0; for(int i=0; i<Count; i++) { ListMesh = TableListMesh[i] as ListMeshDraw; IndexVertex[i] = IndexVertexNow; IndexTriangle[i] = IndexTriangleNow; DataMeshInformation = ListMesh.MeshDataTop; Matrix4x4 MatrixCorrect = transform.localToWorldMatrix.inverse; while(null != DataMeshInformation) { CombineMesh[CountMesh].mesh = DataMeshInformation.DataMesh; CombineMesh[CountMesh].transform = MatrixCorrect * DataMeshInformation.DataTransform.localToWorldMatrix; CountMesh++; IndexVertexNow += DataMeshInformation.DataMesh.vertexCount; IndexTriangleNow += DataMeshInformation.DataMesh.triangles.Length / 3; DataMeshInformation = DataMeshInformation.ChainNext; } } IndexTriangle[Count] = IndexTriangleNow; Mesh MeshNew = new Mesh(); MeshNew.CombineMeshes(CombineMesh); int[] TriangleBuffer = MeshNew.triangles; int[] VertexNoTriangle = null; MeshNew.triangles = null; MeshNew.subMeshCount = Count; for(int i=0; i<Count; i++) { CountMesh = IndexTriangle[i + 1] - IndexTriangle[i]; VertexNoTriangle = new int[CountMesh * 3]; for(int j=0; j<CountMesh; j++) { IndexTriangleNow = (j + IndexTriangle[i]) * 3; IndexVertexNow = j * 3; VertexNoTriangle[IndexVertexNow] = TriangleBuffer[IndexTriangleNow]; VertexNoTriangle[IndexVertexNow + 1] = TriangleBuffer[IndexTriangleNow + 1]; VertexNoTriangle[IndexVertexNow + 2] = TriangleBuffer[IndexTriangleNow + 2]; } MeshNew.SetTriangles(VertexNoTriangle, i); } if(null != InstanceMeshFilter.sharedMesh) { InstanceMeshFilter.sharedMesh.Clear(); Object.DestroyImmediate(InstanceMeshFilter.sharedMesh); } InstanceMeshFilter.sharedMesh = MeshNew; } TableListMesh.Clear(); } /* Excute "UserData CallBack" */ if((null != ListCallBackUserData) && (null != functionUserData)) { Count = ListCallBackUserData.Count; ParameterCallBackUserData Parameter = null; for(int i=0; i<Count; i++) { Parameter = ListCallBackUserData[i] as ParameterCallBackUserData; functionUserData( transform.parent.gameObject, Parameter.PartsName, Parameter.AnimationDataParts, AnimationNo, frameNoNow, Parameter.FrameNo, Parameter.Data ); } ListCallBackUserData.Clear(); } /* Excute "Play-End CallBack" */ if(0 != (Status & BitStatus.REQUEST_PLAYEND)) { Status = BitStatus.CLEAR; if(null != functionPlayEnd) { if(false == (functionPlayEnd(transform.parent.gameObject))) { InstanceMeshFilter.sharedMesh.Clear(); Object.DestroyImmediate(InstanceMeshFilter.sharedMesh); InstanceMeshFilter.sharedMesh = null; Destroy(transform.parent.gameObject); } } } }
/* ******************************************************** */ //! 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) { Status = (true == FlagSwitch) ? (Status | BitStatus.PAUSING) : (Status & ~BitStatus.PAUSING); return(true); }
protected void AppendExecUpdate() { if(null != SpriteStudioData) { if(null != ListInformationPlay) { if(0 != (Status & BitStatus.PLAYING)) { if(0 == (Status & BitStatus.PAUSING)) { /* Get Frame Count */ if(-1 != frameNoPrevious) { /* Not Update, Just Starting */ TimeAnimation += (Time.deltaTime * RateTimeAnimation); Status &= ~BitStatus.DECODE_USERDATA; } int FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); int FrameCountEnd = frameNoEnd - frameNoStart; if(0.0f <= RateTimeAnimation) { /* Play normaly */ if(FrameCountEnd < FrameCountNow) { /* Frame-Over */ /* Loop-Count Check */ bool FlagLoop = true; if(0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; if(0 > CountLoopRemain) { FlagLoop = false; } } /* ReCalculate Frame */ if(true == FlagLoop) { /* Loop */ int FrameCountFull = FrameCountEnd + 1; TimeAnimation -= ((float)FrameCountFull * TimeFramePerSecond); FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); } else { /* End */ TimeAnimation = ((float)FrameCountEnd) * TimeFramePerSecond; FrameCountNow = FrameCountEnd; Status |= BitStatus.REQUEST_PLAYEND; } } /* Frame-No Set */ int FrameNoNew = frameNoStart + FrameCountNow; if(FrameNoNew != frameNoNow) { Status |= BitStatus.DECODE_USERDATA; } frameNoPrevious = frameNoNow; frameNoNow = FrameNoNew; } else { /* Play backwards */ if(0 > FrameCountNow) { /* Frame-Over */ /* Loop-Count Check */ bool FlagLoop = true; if(0 <= CountLoopRemain) { /* Limited-Count Loop */ CountLoopRemain--; if(0 > CountLoopRemain) { FlagLoop = false; } } /* ReCalculate Frame */ if(true == FlagLoop) { /* Loop */ int FrameCountFull = FrameCountEnd + 1; TimeAnimation += ((float)FrameCountFull * TimeFramePerSecond); FrameCountNow = (int)(TimeAnimation / TimeFramePerSecond); } else { /* End */ TimeAnimation = 0.0f; FrameCountNow = 0; Status |= BitStatus.REQUEST_PLAYEND; } } /* Frame-No Set */ int FrameNoNew = frameNoStart + FrameCountNow; if(FrameNoNew != frameNoNow) { Status |= BitStatus.DECODE_USERDATA; } frameNoPrevious = frameNoNow; frameNoNow = FrameNoNew; } /* Update User-CallBack */ SpriteStudioData.UpdateUserData(frameNoNow, gameObject, this); /* Update GameObject */ SpriteStudioData.UpdateGameObject(gameObject, frameNoNow); } } } } }