void Update() { switch (lavaState) { case LavaState.Stagnate: if (timer < 0) { lavaState = LavaState.WarmUp; timer = warmUpTime; // Start Warmup particles var main = warmUpParticle.main; main.duration = warmUpTime; warmUpParticle.Play(); } else { timer -= Time.deltaTime; } break; case LavaState.WarmUp: if (timer < 0) { lavaState = LavaState.Active; timer = activeTime; // Start Active particles var main = activeParticle.main; main.duration = activeTime; activeParticle.Play(); // Activate the collider collider.enabled = true; } else { timer -= Time.deltaTime; } break; case LavaState.Active: if (timer < 0) { lavaState = LavaState.Stagnate; timer = stagnateTime; // Deactivate the collider collider.enabled = false; } else { timer -= Time.deltaTime; } break; default: break; } }
void Start() { lavaState = LavaState.Stagnate; collider.isTrigger = true; collider.enabled = false; timer = stagnateTime; warmUpParticle.time = warmUpTime; activeParticle.time = activeTime; }
/// <summary> /// 設定保護膜按鈕開關 /// </summary> /// <param name='lavaNum'> 蟲蟲編號 </param> /// <param name='state'> 按鈕狀態 </param> /// <param name='lavaState'> 蟲蟲狀態(true:蝴蝶 false:蟲) </param> public void setBounsBtn(int lavaNum, bool btnState,LavaState lavaState) { //取得蟲蟲的技能按鈕位置 int lavaPos = -1; for(int posNum = 0; posNum < Sct_DEFCONST.LAVA_AMOUNT_MAX; posNum++) { if(lavaPosData[posNum] == lavaNum) { lavaPos = posNum; break; } } //設定保護膜按鈕 if(lavaPos >= 0) { if(lavaState == LavaState.ButterFly)// 蝴蝶 { if(btnState) { btn_Bouns[lavaPos].transform.Find("Background").GetComponent<UISprite>().spriteName = "Png_Ingame_Controller_ProtectionN0" + lavaNum; btn_Bouns[lavaPos].GetComponent<Collider>().enabled = true; } else { btn_Bouns[lavaPos].transform.Find("Background").GetComponent<UISprite>().spriteName = "Png_Ingame_Controller_ProtectionC0" + lavaNum; btn_Bouns[lavaPos].GetComponent<Collider>().enabled = false; } } else if (lavaState == LavaState.Lava)// 蟲 { btn_Bouns[lavaPos].transform.Find("Background").GetComponent<UISprite>().spriteName = "Png_Ingame_Controller_CircleIn"+ "0" + lavaNum; btn_Bouns[lavaPos].GetComponent<Collider>().enabled = false; } } else { Debug.LogWarning("找不到蟲蟲"+ lavaNum +"的控制器"); } }
/// <summary> /// 檢查是否要變蟲 /// </summary> /// <param name="_removeBodys">要移除的節數</param> public void Check2Lava(int _removeBodys) { if (TheLavaState == LavaState.Lava) return; int AddBodys = 5 - _removeBodys; bodyControl.enabled = true; TheLavaState = LavaState.Lava; for (int i = 0; i < AddBodys; ++i) { bodyControl.AddBody(); } mask.MState = MaskState.CoolDown; if (IsInvoking("CheckLerpTurn")) CancelInvoke("CheckLerpTurn"); ChangeSprite(variable.LavaType, TheLavaState); }
/*private void onRiskCollision() { //被雨撞到而且又是蝴蝶時 if (TheLavaState == LavaState.ButterFly) { bodyControl.enabled = true; TheLavaState = LavaState.Lava; for (int i = 0; i < 4; ++i) { bodyControl.AddBody(); } HasRainCollied = false; gameUI.setBounsBtn((int)theOrder, false); mask.MState = MaskState.CoolDown; ChangeSprite(theOrder, TheLavaState); } //被怪物撞到而且又是蝴蝶時 else if (HasMonsterCollied && TheLavaState == LavaState.ButterFly) { bodyControl.enabled = true; TheLavaState = LavaState.Lava; bodyControl.AddBody(); HasMonsterCollied = false; gameUI.setBounsBtn((int)theOrder, false); mask.MState = MaskState.CoolDown; ChangeSprite(theOrder, TheLavaState); } }*/ /// <summary> /// 檢查要不要變蝴蝶 /// </summary> public void Check2Butterfly() { //當長度大於五而且還是"蟲"時 if (TheLavaState == LavaState.ButterFly) return; if (bodyControl.LavaBodys.Count < 5) return; //移除所有身體 bodyControl.RemoveAllBodys(); //改變狀態為蝴蝶 TheLavaState = LavaState.ButterFly; //關掉身體控制Component bodyControl.enabled = false; ChangeSprite(variable.LavaType, TheLavaState); InvokeRepeating("CheckLerpTurn", 0f, 0.25f); }
public void ChangeSprite(PlayerType type, LavaState state) { switch (type) { case PlayerType.Blue: if (state == LavaState.Lava) { headSprite.spriteName = Sct_DEFCONST.LAVA_SPRITE_NAME.BLUE_LAVA; headSprite.MakePixelPerfect(); transform.localScale = orginalScale; } else { headSprite.spriteName = Sct_DEFCONST.BUTTERFLY_SPRITE_NAME.BLUE_BUTTERFLY; headSprite.MakePixelPerfect(); headSprite.transform.localScale *= 0.6f; } break; case PlayerType.Green: if (state == LavaState.Lava) { headSprite.spriteName = Sct_DEFCONST.LAVA_SPRITE_NAME.GREEN_LAVA; headSprite.MakePixelPerfect(); transform.localScale = orginalScale; } else { headSprite.spriteName = Sct_DEFCONST.BUTTERFLY_SPRITE_NAME.GREEN_BUTTERFLY; headSprite.MakePixelPerfect(); headSprite.transform.localScale *= 0.6f; } break; case PlayerType.Purple: if (state == LavaState.Lava) { headSprite.spriteName = Sct_DEFCONST.LAVA_SPRITE_NAME.PURPLE_LAVA; headSprite.MakePixelPerfect(); transform.localScale = orginalScale; } else { headSprite.spriteName = Sct_DEFCONST.BUTTERFLY_SPRITE_NAME.PURPLE_BUTTERFLY; headSprite.MakePixelPerfect(); headSprite.transform.localScale *= 0.6f; } break; case PlayerType.Red: if (state == LavaState.Lava) { headSprite.spriteName = Sct_DEFCONST.LAVA_SPRITE_NAME.RED_LAVA; headSprite.MakePixelPerfect(); transform.localScale = orginalScale; } else { headSprite.spriteName = Sct_DEFCONST.BUTTERFLY_SPRITE_NAME.RED_BUTTERFLY; headSprite.MakePixelPerfect(); headSprite.transform.localScale *= 0.6f; } break; } }