Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Card generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Team-on committed Jan 30, 2021
1 parent ac9a475 commit 38a4ab7
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 2,035 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ private void OnValidate() {
#endif

private void Awake() {
if (startWithRandom) {
currSprite = (byte)Random.Range(0, sprites.Length);
img.sprite = sprites[currSprite];
time = Random.Range(0, secondsForOneSprite - Time.deltaTime);
}
else {
img.sprite = sprites[currSprite];
}
Reinit();
}

void Update() {
Expand All @@ -49,7 +42,37 @@ void Update() {
}
}

public void SetSprites(Sprite[] _sprites) {
sprites = _sprites;

Reinit();
}

public void SetSpritesDublicateInner(Sprite[] _sprites) {
List<Sprite> list = new List<Sprite>(_sprites.Length * 2 - 2);
list.AddRange(_sprites);
for (int i = _sprites.Length - 1; i >= 1; --i)
list.Add(_sprites[i]);

sprites = list.ToArray();

Reinit();
}

public float GetDuration() {
return secondsForOneSprite * sprites.Length + secondsForOneSprite / 2;
}

void Reinit() {
if (startWithRandom) {
currSprite = (byte)Random.Range(0, sprites.Length);
time = Random.Range(0, secondsForOneSprite - Time.deltaTime);
}
else {
currSprite = 0;
time = 0;
}

img.sprite = sprites[currSprite];
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using UnityEngine;
using System.Collections.Generic;

static class RandomEx {
public static class RandomEx {
public static bool GetEventWithChance(int percent) {
int number = UnityEngine.Random.Range(1, 101);
return number <= percent;
Expand Down
Loading

0 comments on commit 38a4ab7

Please sign in to comment.