游戏逻辑循环
This commit is contained in:
parent
76925714d9
commit
061937275d
|
|
@ -46,7 +46,7 @@ ParticleSystem:
|
|||
cullingMode: 0
|
||||
ringBufferMode: 0
|
||||
ringBufferLoopRange: {x: 0, y: 1}
|
||||
looping: 0
|
||||
looping: 1
|
||||
prewarm: 0
|
||||
playOnAwake: 1
|
||||
useUnscaledTime: 0
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1107 &-4659606680046192436
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 5
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
|
|
@ -11,7 +11,7 @@ AnimatorStateMachine:
|
|||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 3947085986465062884}
|
||||
m_Position: {x: 200, y: 0, z: 0}
|
||||
m_Position: {x: 160, y: 260, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
|
|
@ -46,12 +46,12 @@ AnimatorController:
|
|||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1102 &3947085986465062884
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: clap-stick
|
||||
m_Name: Action
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -165,12 +165,6 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mCtnStage: {fileID: 2101175959}
|
||||
--- !u!224 &464670185 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 6904755265700125195, guid: 6ebd5f76171ee4e0b8d96b2eae97c251,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 3844714965480532569}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &493959135
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -311,8 +305,8 @@ RectTransform:
|
|||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 6858361774777129065}
|
||||
- {fileID: 464670185}
|
||||
- {fileID: 4946020809530057780}
|
||||
- {fileID: 7676866811056894034}
|
||||
- {fileID: 987875187}
|
||||
- {fileID: 1714038173902949465}
|
||||
- {fileID: 923398010}
|
||||
|
|
@ -538,9 +532,6 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 1bdd22e611e6942489e40ead15305a34, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mAudioListener: {fileID: 0}
|
||||
mMusicPlayer: {fileID: 0}
|
||||
mSoundPlayer: {fileID: 0}
|
||||
soundPacks: []
|
||||
--- !u!4 &1345696984
|
||||
Transform:
|
||||
|
|
@ -1030,7 +1021,7 @@ RectTransform:
|
|||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1203140506473995672}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &3844714965480532569
|
||||
--- !u!1001 &1969282075732289138
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
|
|
@ -1154,7 +1145,13 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 6ebd5f76171ee4e0b8d96b2eae97c251, type: 3}
|
||||
--- !u!1001 &4321345554119791874
|
||||
--- !u!224 &4946020809530057780 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 6887168216434345711, guid: 841ca4be8d96342da81473d244f04f57,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 5298792260618257231}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &5298792260618257231
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
|
|
@ -1353,11 +1350,48 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 841ca4be8d96342da81473d244f04f57, type: 3}
|
||||
--- !u!224 &6858361774777129065 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 6887168216434345711, guid: 841ca4be8d96342da81473d244f04f57,
|
||||
--- !u!1 &7676866810232408422 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6904755265547789119, guid: 6ebd5f76171ee4e0b8d96b2eae97c251,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 4321345554119791874}
|
||||
m_PrefabInstance: {fileID: 1969282075732289138}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &7676866810232408423
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7676866810232408422}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 791356b2c7d5c444980c1472ffa8f1ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!95 &7676866810232408424
|
||||
Animator:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7676866810232408422}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000, guid: 7c5794036b4624dd7a0d12e3ceb6bb4a, type: 2}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorControllerStateOnDisable: 0
|
||||
--- !u!224 &7676866811056894034 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 6904755265700125195, guid: 6ebd5f76171ee4e0b8d96b2eae97c251,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1969282075732289138}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &9049642900195122466
|
||||
PrefabInstance:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,22 @@ public class LevelData
|
|||
public string LevelColorCode;
|
||||
public int SlotCount;
|
||||
public List<EndingData> Endings;
|
||||
|
||||
public EndingData GetMatchingEnding(string pEndingStr)
|
||||
{
|
||||
EndingData tData = null;
|
||||
|
||||
for (int i = 0; i < Endings.Count; i++)
|
||||
{
|
||||
if (Endings[i].IsMatching(pEndingStr))
|
||||
{
|
||||
tData = Endings[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tData;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
@ -30,4 +46,37 @@ public class EndingData
|
|||
public string EndingName;//only for editor display
|
||||
public bool IsGoodEnding;
|
||||
public string EndingCode;//eg: 12X;132;
|
||||
|
||||
public bool IsMatching(string pEndingStr)
|
||||
{
|
||||
bool tMatching = false;
|
||||
|
||||
string[] tTemplateEndingStrs = EndingCode.Split(';');
|
||||
for (int i = 0; i < tTemplateEndingStrs.Length; i++)
|
||||
{
|
||||
if (CompareEndingStr(pEndingStr, tTemplateEndingStrs[i]))
|
||||
{
|
||||
tMatching = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tMatching;
|
||||
}
|
||||
|
||||
private bool CompareEndingStr(string pRefStr, string pTemplateStr)
|
||||
{
|
||||
bool tMatching = true;
|
||||
|
||||
for (int i = 0; i < pRefStr.Length; i++)
|
||||
{
|
||||
if (pTemplateStr[i] != 'X' && pRefStr[i] != pTemplateStr[i])
|
||||
{
|
||||
tMatching = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tMatching;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ public class GameLogic : MonoBehaviour
|
|||
|
||||
private Film mFilm;
|
||||
private int[] mSoundOrder;
|
||||
private string mEndingStr;
|
||||
private int mCurIndex;
|
||||
|
||||
private void Start()
|
||||
|
|
@ -27,26 +28,59 @@ public class GameLogic : MonoBehaviour
|
|||
{
|
||||
mSoundOrder = pSoundOrder;
|
||||
|
||||
string tOrderStr = "";
|
||||
mEndingStr = "";
|
||||
for (int i = 0; i < mSoundOrder.Length; i++)
|
||||
{
|
||||
tOrderStr += (mSoundOrder[i] + 1).ToString();
|
||||
mEndingStr += (mSoundOrder[i] + 1).ToString();
|
||||
if (i < mSoundOrder.Length - 1)
|
||||
{
|
||||
tOrderStr += "_";
|
||||
mEndingStr += "_";
|
||||
}
|
||||
}
|
||||
|
||||
mFilm.PlayScene(tOrderStr);
|
||||
mFilm.PlayScene(mEndingStr);
|
||||
|
||||
mCurIndex = 0;
|
||||
AudioManager.Instance.PlaySound(ResourceManager.Instance.LoadRes<AudioClip>(Const.Path.GetSound(PlayerData.Instance.CurrentLevelID, mSoundOrder[mCurIndex])));
|
||||
TimerManager.Instance.Schedule(PlaySound, 1.5f, mSoundOrder.Length - 1);
|
||||
TimerManager.Instance.Schedule(PlaySound, 1.5f, mSoundOrder.Length);
|
||||
}
|
||||
|
||||
private void PlaySound()
|
||||
{
|
||||
mCurIndex++;
|
||||
AudioManager.Instance.PlaySound(ResourceManager.Instance.LoadRes<AudioClip>(Const.Path.GetSound(PlayerData.Instance.CurrentLevelID, mSoundOrder[mCurIndex])));
|
||||
if (mCurIndex < mSoundOrder.Length)
|
||||
{
|
||||
AudioManager.Instance.PlaySound(ResourceManager.Instance.LoadRes<AudioClip>(Const.Path.GetSound(PlayerData.Instance.CurrentLevelID, mSoundOrder[mCurIndex])));
|
||||
}
|
||||
else
|
||||
{
|
||||
//end
|
||||
LevelData tLvData = GameConfig.Instance.GetLevelData(PlayerData.Instance.CurrentLevelID);
|
||||
EndingData tEdData = tLvData.GetMatchingEnding(mEndingStr.Replace("_",""));
|
||||
|
||||
UIManager.Instance.CloseUI<PanelGame>();
|
||||
|
||||
PanelResult tUIResult = UIManager.Instance.OpenUI<PanelResult>();
|
||||
if (tEdData != null)
|
||||
{
|
||||
tUIResult.Init(tEdData.EndingName, tEdData.IsGoodEnding, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
tUIResult.Init("", false, false);
|
||||
}
|
||||
|
||||
tUIResult.DelAgain = PlayAgain;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayAgain()
|
||||
{
|
||||
UIManager.Instance.CloseUI<PanelResult>();
|
||||
|
||||
PanelGame tUIGame = UIManager.Instance.OpenUI<PanelGame>();
|
||||
tUIGame.Init();
|
||||
|
||||
mFilm.PlayScene("0");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameManager : D_MonoSingleton<GameManager>
|
||||
{
|
||||
public void LoadMain()
|
||||
{
|
||||
SceneManager.LoadScene("Main");
|
||||
}
|
||||
|
||||
public void LoadGame()
|
||||
{
|
||||
SceneManager.LoadScene("Game");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a55aee0d94e4641559e3f3a8af3d09c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
public class PanelGame : BasePanel
|
||||
{
|
||||
|
|
@ -23,10 +24,15 @@ public class PanelGame : BasePanel
|
|||
[SerializeField] GameObject mGobPlayProgress;
|
||||
[SerializeField] Image mImgPlayProgress;
|
||||
|
||||
[SerializeField] Animator mAtrAction;
|
||||
[SerializeField] GameObject mGobOpMask;
|
||||
|
||||
private int mTotalSlot;
|
||||
private int mCurSlotIndex;
|
||||
private int[] mSoundOrder;
|
||||
|
||||
private PanelGameAni mAni;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
UIUtils.BindBtn(mBtnLevel, OnClickLevel);
|
||||
|
|
@ -34,6 +40,8 @@ public class PanelGame : BasePanel
|
|||
UIUtils.BindBtn(mBtnPlay, OnClickPlay);
|
||||
|
||||
mBtnEndings.DelClick = OnClickEndings;
|
||||
|
||||
mAni = GetComponent<PanelGameAni>();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
|
|
@ -70,6 +78,13 @@ public class PanelGame : BasePanel
|
|||
mBtnSounds[i].SetSoundPic(ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetSoundPic(PlayerData.Instance.CurrentLevelID, i)));
|
||||
mBtnSounds[i].DelClick = OnClickSound;
|
||||
}
|
||||
|
||||
mGobPlay.SetActive(false);
|
||||
mGobPlayProgress.SetActive(false);
|
||||
mAtrAction.gameObject.SetActive(false);
|
||||
mGobOpMask.SetActive(false);
|
||||
|
||||
mAni.Init();
|
||||
}
|
||||
|
||||
private void OnClickLevel()
|
||||
|
|
@ -88,10 +103,29 @@ public class PanelGame : BasePanel
|
|||
}
|
||||
|
||||
private void OnClickPlay()
|
||||
{
|
||||
mGobPlay.SetActive(false);
|
||||
mGobOpMask.SetActive(true);
|
||||
|
||||
mAni.ReadyPlay(0.5f);
|
||||
TimerManager.Instance.Schedule(Action, 0.5f);
|
||||
}
|
||||
|
||||
private void Action()
|
||||
{
|
||||
mAtrAction.gameObject.SetActive(true);
|
||||
mAtrAction.Play("Action");
|
||||
|
||||
TimerManager.Instance.Schedule(StartPlay, 1.5f);
|
||||
}
|
||||
|
||||
private void StartPlay()
|
||||
{
|
||||
DelPlay?.Invoke(mSoundOrder);
|
||||
|
||||
mGobPlay.SetActive(false);
|
||||
mGobPlayProgress.SetActive(true);
|
||||
mImgPlayProgress.fillAmount = 0;
|
||||
mImgPlayProgress.DOFillAmount(1, mSoundOrder.Length * 1.5f).SetEase(Ease.Linear);
|
||||
}
|
||||
|
||||
private void OnClickSlot(int pIndex)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
|
||||
public class PanelGameAni : MonoBehaviour
|
||||
{
|
||||
[SerializeField] RectTransform mRctTop;
|
||||
[SerializeField] RectTransform mRctCenter;
|
||||
|
||||
[SerializeField] RectTransform mRctEndingsBtn;
|
||||
|
||||
[SerializeField] RectTransform mRctSlotBG;
|
||||
[SerializeField] RectTransform mRctSlotBtns;
|
||||
|
||||
[SerializeField] RectTransform mRctSoundBtns;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
mRctTop.anchoredPosition = new Vector2(0, 180);
|
||||
mRctCenter.anchoredPosition = new Vector2(0, -560);
|
||||
|
||||
mRctEndingsBtn.anchoredPosition = new Vector2(100, -235);
|
||||
|
||||
mRctSlotBG.anchoredPosition = new Vector2(0, -125);
|
||||
mRctSlotBG.sizeDelta = new Vector2(mRctSlotBG.sizeDelta.x, 249);
|
||||
|
||||
mRctSlotBtns.anchoredPosition = new Vector2(0, -305);
|
||||
mRctSoundBtns.anchoredPosition = new Vector2(0, -470);
|
||||
|
||||
mRctTop.DOAnchorPosY(0, 0.5f);
|
||||
mRctCenter.DOAnchorPosY(0, 0.5f);
|
||||
|
||||
mRctEndingsBtn.DOAnchorPosX(-10, 0.3f).SetDelay(0.5f);
|
||||
}
|
||||
|
||||
public void ReadyPlay(float pDuration)
|
||||
{
|
||||
mRctSlotBG.DOAnchorPosY(-180, pDuration);
|
||||
mRctSlotBG.DOSizeDelta(new Vector2(mRctSlotBG.sizeDelta.x, 395), pDuration);
|
||||
|
||||
mRctSlotBtns.DOAnchorPosY(-390, pDuration);
|
||||
mRctSoundBtns.DOAnchorPosY(-680, pDuration);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f1c72c744cfff48f783923faf3d2cd90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PanelResult : BasePanel
|
||||
{
|
||||
public Action DelAgain;
|
||||
|
||||
[SerializeField] Text mTxtEndingName;
|
||||
|
||||
[SerializeField] GameObject mGobWinTitle;
|
||||
[SerializeField] GameObject mGobLoseTitle;
|
||||
|
||||
[SerializeField] GameObject mGobWinFace;
|
||||
[SerializeField] GameObject mGobLoseFace;
|
||||
|
||||
[SerializeField] GameObject mGobWinBtns;
|
||||
[SerializeField] GameObject mGobOtherBtns;
|
||||
|
||||
[SerializeField] Button mBtnAgain1;
|
||||
[SerializeField] Button mBtnAgain2;
|
||||
[SerializeField] Button mBtnNext;
|
||||
[SerializeField] Button mBtnChoose;
|
||||
|
||||
[SerializeField] ButtonEndings mBtnEndings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
UIUtils.BindBtn(mBtnAgain1, OnClickAgain);
|
||||
UIUtils.BindBtn(mBtnAgain2, OnClickAgain);
|
||||
UIUtils.BindBtn(mBtnNext, OnClickNext);
|
||||
UIUtils.BindBtn(mBtnChoose, OnClickChoose);
|
||||
|
||||
mBtnEndings.DelClick = OnClickEndings;
|
||||
}
|
||||
|
||||
public void Init(string pEndingName,bool pIsWin, bool pAllLevelClear)
|
||||
{
|
||||
mTxtEndingName.text = pEndingName;
|
||||
|
||||
mGobWinTitle.SetActive(pIsWin);
|
||||
mGobLoseTitle.SetActive(!pIsWin);
|
||||
|
||||
mGobWinFace.SetActive(pIsWin);
|
||||
mGobLoseFace.SetActive(!pIsWin);
|
||||
|
||||
mGobWinBtns.SetActive(!pAllLevelClear && pIsWin);
|
||||
mGobOtherBtns.SetActive(pAllLevelClear || !pIsWin);
|
||||
}
|
||||
|
||||
private void OnClickAgain()
|
||||
{
|
||||
DelAgain?.Invoke();
|
||||
}
|
||||
|
||||
private void OnClickNext()
|
||||
{
|
||||
GameManager.Instance.LoadGame();
|
||||
}
|
||||
|
||||
private void OnClickChoose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnClickEndings()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 311ee5e8045614c3d8a3995000a8d907
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(Image))]
|
||||
public class ImageFrameAni : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Sprite[] mSprFrames;
|
||||
[SerializeField] int mFrameRate = 30;
|
||||
[SerializeField] bool mIsPlaying = true;
|
||||
|
||||
private Image mImg;
|
||||
|
||||
private int mCurIndex;
|
||||
|
||||
private float mDelta;
|
||||
private float mTimer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mImg = GetComponent<Image>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
mDelta = 1.0f / mFrameRate;
|
||||
mTimer = mDelta;
|
||||
|
||||
mCurIndex = 0;
|
||||
mImg.sprite = mSprFrames[mCurIndex];
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (mSprFrames.Length > 0 && mIsPlaying)
|
||||
{
|
||||
mTimer -= Time.deltaTime;
|
||||
|
||||
if (mTimer <= 0)
|
||||
{
|
||||
mCurIndex = (mCurIndex + 1) % mSprFrames.Length;
|
||||
mImg.sprite = mSprFrames[mCurIndex];
|
||||
|
||||
mTimer = mDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 539362ffcf9bc4a8cb2be32a27fb8d79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue