Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
SpriteReplacerAnimation.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class SpriteReplacerAnimation : MonoBehaviour
6{
7 public enum Type
8 {
10 Boat
11 }
12
13 public static Dictionary<string, SpriteData> dict = new Dictionary<string, SpriteData>();
14
15 public Type type;
16
17 public string id;
18
20
21 [NonSerialized]
22 public SpriteRenderer sr;
23
24 private int index;
25
26 private void Awake()
27 {
28 if (!id.IsEmpty())
29 {
30 SetData(id);
31 }
32 }
33
34 public void SetData(string id)
35 {
36 this.id = id;
37 string text = id.IsEmpty(base.name + "_anime");
38 string path = CorePath.packageCore + "Texture/Item/" + text;
39 data = dict.TryGetValue(text);
40 if (data == null)
41 {
42 data = new SpriteData
43 {
44 path = path
45 };
46 data.Init();
47 dict.Add(text, data);
48 }
49 sr = GetComponent<SpriteRenderer>();
50 sr.sprite = data.GetSprite();
51 if (type == Type.Default)
52 {
53 CancelInvoke();
54 InvokeRepeating("Refresh", 0f, data.time);
55 }
56 }
57
58 private void Refresh()
59 {
60 index++;
61 if (index >= data.frame)
62 {
63 index = 0;
64 }
65 sr.sprite = data.GetSprites()[index];
66 }
67}
void Init()
Definition: SpriteData.cs:31
Sprite GetSprite(bool snow=false)
Definition: SpriteData.cs:58
float time
Definition: SpriteData.cs:29
Sprite[] GetSprites()
Definition: SpriteData.cs:52
static Dictionary< string, SpriteData > dict