You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
using UnityEngine; |
|
using System.Collections; |
|
|
|
public class OilExtend : MonoBehaviour { |
|
|
|
private GameObject ranyou; |
|
void Start () { |
|
ranyou = this.gameObject; |
|
scale_x = transform.localScale.x; |
|
scale_z = transform.localScale.z; |
|
InvokeRepeating("RanyouSpread", 0, Time.deltaTime); |
|
StartCoroutine(isScale(true, lateTime_x)); |
|
StartCoroutine(isScale(false, lateTime_z)); |
|
} |
|
[SerializeField] |
|
private float spreadSpeed_x; |
|
[SerializeField] |
|
private float spreadSpeed_z; |
|
[SerializeField] |
|
private float scaleMax_x; |
|
[SerializeField] |
|
private float scaleMax_z; |
|
//当前缩放 |
|
private float scale_x; |
|
private float scale_z; |
|
[SerializeField] |
|
private float lateTime_x; |
|
[SerializeField] |
|
private float lateTime_z; |
|
private bool isScale_x; |
|
private bool isScale_z; |
|
private void RanyouSpread() |
|
{ |
|
if(isScale_x && scale_x < scaleMax_x) |
|
{ |
|
scale_x += Time.deltaTime * spreadSpeed_x /100; |
|
} |
|
if(isScale_z && scale_z< scaleMax_z) |
|
{ |
|
scale_z += Time.deltaTime * spreadSpeed_z /100; |
|
} |
|
ranyou.transform.localScale = new Vector3(scale_x, ranyou.transform.localScale.y, scale_z); |
|
if (scale_x >= scaleMax_x && scale_z >= scaleMax_z) |
|
CancelInvoke("RanyouSpread"); |
|
} |
|
private IEnumerator isScale(bool isX,float lateTime) |
|
{ |
|
yield return new WaitForSeconds(lateTime); |
|
if (isX) |
|
isScale_x = true; |
|
else |
|
isScale_z = true; |
|
} |
|
}
|
|
|