void Start() { rigid2D.velocity = new Vector2(0, 0f); healthCanvas = playerHealth.GetComponent <Transform>(); if (ChapterName == "1") { activeClimb = GameObject.Find("vine1").GetComponent <ActiveClimb>(); //防錯誤 爬藤蔓 activePickUp = GameObject.Find("stone1").GetComponent <ActivePickUp>(); //防錯誤 拾取物品 ActivePickUp.PickUpInt = 0; } else if (ChapterName == "2") { activeClimb = GameObject.Find("ladder").GetComponent <ActiveClimb>(); //防錯誤 爬藤蔓 activePickUp = GameObject.Find("Card").GetComponent <ActivePickUp>(); //防錯誤 拾取物品 ActivePickUp.PickUpInt = 0; } else if (ChapterName == "3") { activeClimb = GameObject.Find("ladder").GetComponent <ActiveClimb>(); //防錯誤 爬藤蔓 activePickUp = GameObject.Find("pillar1").GetComponent <ActivePickUp>(); //防錯誤 拾取物品 npcTalk = GameObject.Find("Door").GetComponent <NpcTalk>(); ActivePickUp.PickUpInt = 0; } else if (ChapterName == "4") { //activeClimb = GameObject.Find("ladder").GetComponent<ActiveClimb>(); //防錯誤 爬藤蔓 activePickUp = GameObject.Find("handle").GetComponent <ActivePickUp>(); //防錯誤 拾取物品 //npcTalk = GameObject.Find("Door").GetComponent<NpcTalk>(); ActivePickUp.PickUpInt = 0; } }
//---------------------碰撞----------------------- void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.name == "BossEnemy") //觸碰到敵人 { TakeDamage(10); damageBulletsPool.addDamageInt = 10; W1_beaten.SetActive(true); damageBulletsPool.Fire(); StartCoroutine("Bossbeaten"); } if (col.gameObject.name == "AtkParticle") //序章-玩家受到小BOSS攻擊 { //TakeDamage(BossAtk); TakeDamage(10); damageBulletsPool.addDamageInt = 10; damageBulletsPool.Fire(); W1_beaten.SetActive(true); StartCoroutine("Bossbeaten"); } if (col.gameObject.name == "F1(Clone)") //框框球攻擊 { TakeDamage(5); damageBulletsPool.addDamageInt = 5; damageBulletsPool.Fire(); StartCoroutine("Bossbeaten"); } if (col.gameObject.name == "F2") //框框範圍攻擊 { TakeDamage(25); damageBulletsPool.addDamageInt = 25; damageBulletsPool.Fire(); F2_beaten.SetActive(true); StartCoroutine("Bossbeaten"); } if (col.tag == "EndPoint") //序章-結束點 { if (ChapterName == "0") { dg_GameManager.win(); } else if (ChapterName == "1") { if (StaticObject.sBE1 == 1) //BE1迷失森林 { gameManager.lose(); } else //HE1離開森林 { gameManager.win(); } } else if (ChapterName == "2") { if (StaticObject.sBE2 == 1) { gameManager.lose(); } else //BE2被遺忘的事 { gameManager.win(); } } else if (ChapterName == "4") { if (StaticObject.sBE2 == 1) //BE3萬籟俱寂的等待 { gameManager.lose(); } else //HE2真實的世界 +彩蛋 { gameManager.win(); } } } if (HealthSlider.value < 100) { if (col.gameObject.name == "BloodStation") //補血站 { addBlood = true; lineParticle.SetActive(true); } if (col.tag == "heart") //補血愛心 { addBulletsPool.addDamageInt = 10; addBulletsPool.Fire(); curHealth += 10; Destroy(col.gameObject); } } if (col.tag == "vine") //進入藤蔓 { activeClimb = col.gameObject.GetComponent <ActiveClimb>(); } if (col.tag == "NPC") //觸碰到NPC { npcTalk = col.gameObject.GetComponent <NpcTalk>(); } if (col.tag == "pickUpObj") //拾取物件 { activePickUp = col.gameObject.GetComponent <ActivePickUp>(); if (col.gameObject.name == activePickUp.PickUpObjName) //形石 { activePickUp.PickUpObjBool = true; } } if (col.gameObject.name == "redFairy" || col.gameObject.name == "blueFairy") //觸碰到紅藍精靈 { npcTalk = GameObject.Find("NPC_Statue").GetComponent <NpcTalk>(); } if (col.gameObject.name == "redFlower" || col.gameObject.name == "blueFlower") //觸碰到紅藍花 { npcTalk = GameObject.Find("NPC_Bobby").GetComponent <NpcTalk>(); } if (col.gameObject.name == "rightClock" || col.gameObject.name == "falseClock") //觸碰到時鐘 { npcTalk = GameObject.Find("NPC_Dida").GetComponent <NpcTalk>(); } if (col.gameObject.name == "rightKey" || col.gameObject.name == "falseKey") //觸碰到鑰匙 { npcTalk = GameObject.Find("Door").GetComponent <NpcTalk>(); } if (col.gameObject.name == "Teleportation") //傳送陣 { StartCoroutine("Teleportation"); } }