44 lines
1.1 KiB
C#
Executable File
44 lines
1.1 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UpgradeEffect : MonoBehaviour
|
|
{
|
|
public static UpgradeEffect instance;
|
|
public static UpgradeEffect top_instance;
|
|
|
|
RectTransform rect;
|
|
public int steps;
|
|
public float maxScale;
|
|
public bool onTop;
|
|
void Awake(){
|
|
if(onTop){
|
|
top_instance = this;
|
|
}else{
|
|
instance= this;
|
|
}
|
|
rect = GetComponent<RectTransform>();
|
|
}
|
|
void Start()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Show(Vector3 position){
|
|
gameObject.SetActive(true);
|
|
rect.position = position;
|
|
StartCoroutine(Effect());
|
|
}
|
|
|
|
IEnumerator Effect(){
|
|
gameObject.SetActive(true);
|
|
for(int i=0; i < steps; i++){
|
|
float level = 1-Mathf.Abs((i - ((float)steps/2f)) / ((float)steps/2f));
|
|
Debug.Log(level);
|
|
rect.localScale = new Vector3(level * maxScale, level * maxScale);
|
|
yield return new WaitForFixedUpdate();
|
|
}
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|