39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ArrowController : MonoBehaviour
|
|
{
|
|
// Left, down, up, right arrow sprites.
|
|
[SerializeField] public Sprite[] arrowSprites;
|
|
[SerializeField] public GameObject successObject;
|
|
[SerializeField] public GameObject failObject;
|
|
[SerializeField] public Image image;
|
|
[SerializeField] public Image bgImage;
|
|
public int key = 0;
|
|
|
|
public void Init()
|
|
{
|
|
image.sprite = arrowSprites[key];
|
|
}
|
|
|
|
public void Succeed()
|
|
{
|
|
GameObject o = Instantiate(successObject);
|
|
o.transform.position = transform.position;
|
|
o.transform.SetParent(this.transform);
|
|
image.color = Color.clear;
|
|
bgImage.color = Color.clear;
|
|
}
|
|
|
|
public void Fail()
|
|
{
|
|
GameObject o = Instantiate(failObject);
|
|
o.transform.position = transform.position;
|
|
o.transform.SetParent(this.transform);
|
|
image.color = Color.clear;
|
|
bgImage.color = Color.clear;
|
|
}
|
|
}
|