using System.Collections; using System.Collections.Generic; using UnityEngine; public class OilSpread : MonoBehaviour { //private CapsuleCollider capsule; public BoxCollider boxColider; // Use this for initialization void Start() { ranyou = this.gameObject; //capsule = this.GetComponent(); //boxColider = GetComponent(); } public bool oilSpred;//开始蔓延 /// /// 蔓延速度 /// [SerializeField] private float SpreadSpeed = 0.05f; [SerializeField] public float scale = 1.2f; void Update() { //if (oilSpred && capsule) if (oilSpred && boxColider) RanYouControl(); } /// /// 燃油 /// private GameObject ranyou; public float ranyouScale = 0; private void RanYouControl() { if (ranyouScale < scale - 0.1f) { //CapsuleRadius(); BoxColiderController(); ranyouScale += Time.deltaTime * SpreadSpeed * (scale - ranyouScale) * ReplayManager.playSpeed; ranyou.transform.localScale = new Vector3(ranyouScale, ranyou.transform.localScale.y, ranyouScale); } } private void BoxColiderController() { float can = boxColider.size.x; can += Time.deltaTime * SpreadSpeed * (scale - ranyouScale) * 4.5f * ReplayManager.playSpeed; boxColider.size = new Vector3(can, 1.5f, can); } //private void CapsuleRadius() //{ // capsule.radius += Time.deltaTime * SpreadSpeed * (scale - ranyouScale) * 2; //} public void DelaySet() { transform.localScale = new Vector3(1.1f, 0.7f, 1.1f); Destroy(GetComponent()); transform.parent.GetComponent().SetRanYouPos(); } }