void Awake() { myBodyControl = GetComponent<Sct_LavaBodyControl>(); myState = GetComponent<Sct_LavaState>(); input = GetComponent<Sct_LavaInput>(); sound = GetComponent<Sct_LavaSound>(); mask = GetComponent<Sct_BubbleMask>(); itemControl = GetComponent<Sct_LavaItem>(); }
void Awake() { LavaControl = GetComponent<Sct_LavaBodyControl>(); }
void Start() { rootControl = GameObject.FindWithTag(tag).GetComponentInChildren<Sct_LavaBodyControl>(); rootState = GameObject.FindWithTag(tag).GetComponentInChildren<Sct_LavaState>(); }
/// <summary> /// 設定毛毛蟲相撞(頭撞頭)時該怎麼扣 /// </summary> void LavaStateCollisionDetect(ref Sct_LavaBodyControl Script, ref Sct_LavaBodyControl hitScript) { //自己和對方的身體至少要有一節或更多 if (hitScript.LavaBodys.Count >= 1 && Script.LavaBodys.Count >= 1) { //身體數量相同且都大於1節 if (hitScript.LavaBodys.Count == Script.LavaBodys.Count && hitScript.LavaBodys.Count > 1 && Script.LavaBodys.Count > 1) { //自己減一節身體 Script.RemoveBody(); } //比我多 else if (hitScript.LavaBodys.Count > Script.LavaBodys.Count) { //自己加一節 Script.AddBody(); } //比我少 else if (hitScript.LavaBodys.Count < Script.LavaBodys.Count) { //自己大於1才扣 if (Script.LavaBodys.Count > 1) //扣自己一節 Script.RemoveBody(); } } }
//private Sct_LavaSound sound; void Awake() { bodyControl = GetComponent<Sct_LavaBodyControl>(); col = GetComponent<Sct_CollisionDetect>(); mask = GetComponent<Sct_BubbleMask>(); input = GetComponent<Sct_LavaInput>(); variable = GetComponent<Sct_LavaVariable>(); //sound = GetComponent<Sct_LavaSound>(); }
/// <summary> /// 夾到後要處理的事 /// </summary> /// <param name="_catchedLava">被夾到的蟲</param> public void Catch(Sct_LavaBodyControl _catchedLava) { //是自己放的就沒事 if (_catchedLava == _ownerLava) return; if (_catchedLava && _ownerLava) { Sct_LavaState _targetState = _catchedLava.GetComponent<Sct_LavaState>(); //Sct_BubbleMask _targetMask = _catchedLava.GetComponent<Sct_BubbleMask>(); if (_targetState) { //當撞到的是蝴蝶.. if (_targetState.CurrentState == LavaState.ButterFly) { _targetState.Check2Lava(2); } else { //刪除被夾到蟲的身體 if (_catchedLava.LavaBodys.Count == 3) { _catchedLava.RemoveBody(); _catchedLava.RemoveBody(); } else if (_catchedLava.LavaBodys.Count == 2) _catchedLava.RemoveBody(); } } else { Debug.LogError("檢查是否有放Component!"); } Sct_LavaState _myState = _ownerLava.GetComponent<Sct_LavaState>(); if (_myState) { if (_myState.CurrentState == LavaState.Lava) { if (_ownerLava.LavaBodys.Count == 3) { //增加放陷阱的蟲身體 _ownerLava.AddBody(); _ownerLava.AddBody(); } else if (_ownerLava.LavaBodys.Count == 2) _ownerLava.RemoveBody(); } _myState.Check2Butterfly(); } } else { Debug.LogError("檢查是否有放Component!"); } //做完事後刪除自己 Destroy(gameObject); }