private void teleport() { lerpList.Clear(); Vector3 podestPosition = Vector3.zero; PortalIsle portalIsle = lvlManager.bossIsle.IsleObj.GetComponent <PortalIsle>(); switch (Type) { case ItemType.PortalKey1: podestPosition = portalIsle.Podest1.transform.position; break; case ItemType.PortalKey2: podestPosition = portalIsle.Podest2.transform.position; break; case ItemType.PortalKey3: podestPosition = portalIsle.Podest3.transform.position; break; default: print("Error: teleport von Items ohne gütigem Item-Type (nur PortalKey Erlaubt)"); break; } lerpList.Add(new lerpInfo(gameObject.transform.position + new Vector3(0, 5, 0), 3)); lerpList.Add(new lerpInfo(podestPosition + new Vector3(0, 5, 0), 25)); lerpList.Add(new lerpInfo(podestPosition + new Vector3(0, 1, 0), 7)); checkTeleportFinished = StartCoroutine(checkTeleportFinishedHandler()); }
void OnControllerColliderHit(ControllerColliderHit hit) { if (DieOnCollision) { Stats stats = GetComponent <Stats>(); stats.gotHit(100000); } if (isImmportal == false) { if (isImmportal == false) { if (hit.gameObject.tag == "Enemy") { try { float damage = hit.gameObject.GetComponent <Stats>().strength; TakeDamage(damage); } catch (Exception ex) { Debug.Log(ex); } } } } if (hit.gameObject.tag == "DeathPlane") { Stats stats = GetComponent <Stats>(); stats.gotHit(hit.gameObject.GetComponent <Stats>().strength); } if (hit.gameObject.tag == "Portal") { Portal portal = hit.gameObject.GetComponent <Portal>(); if (portal.PortalActivated == true) { portal.Teleport(); } } if (hit.gameObject.tag == "Item") { Item item = hit.gameObject.GetComponent <Item>(); if (item.collected == false) { item.Collect(); } } if (hit.gameObject.tag == "Boss-Portal") { PortalIsle portalIsle = lvlManager.bossIsle.IsleObj.GetComponent <PortalIsle>(); if (portalIsle.open == true) { portalIsle.teleport(); } } }
public void Collect() { if (Type == ItemType.PortalKey1 || Type == ItemType.PortalKey2 || Type == ItemType.PortalKey3) { teleport(); lvlManager.currentIsle.isleObjectType = IsleAbstract.IsleObjectType.normal; mr.getObject(ObjectPool.categorie.essential, (int)ObjectPool.essential.UI).GetComponent <UI_Canvas>().UpdateMiniMap(); collected = true; PortalIsle portalIsle = lvlManager.bossIsle.IsleObj.GetComponent <PortalIsle>(); portalIsle.PortalKeys++; if (portalIsle.PortalKeys < 3) { ui.ShowMessage(portalIsle.PortalKeys + " of 3 Portal-Keys collected."); } else { ui.ShowMessage("All Portal-Keys collected.\nMain-Portal is open now!"); } } else if (Type == ItemType.SmallBox) { if (opened == true) { Player player = mr.getObject(ObjectPool.categorie.essential, (int)ObjectPool.essential.player).GetComponent <Player>(); Stats playerStats = player.GetComponent <Stats>(); switch (ContentSmall) { case ContentTypeSmall.SmallKey: player.NumberSmallKeys++; ui.UpdateKeys(player.NumberSmallKeys); ui.ShowMessage("Small key collected"); break; case ContentTypeSmall.SpeedUpgrade: playerStats.speed += ContentObj.GetComponent <StatUpgrade>().IncreaseSmallValue; ui.ShowMessage("More Speed!"); break; case ContentTypeSmall.DamageUpgrade: playerStats.shotStrength += ContentObj.GetComponent <StatUpgrade>().IncreaseSmallValue; ui.ShowMessage("More Damage!"); break; case ContentTypeSmall.RateUpgrade: playerStats.fireRate *= ContentObj.GetComponent <StatUpgrade>().IncreaseSmallValue; ui.ShowMessage("Fire rate increased!"); break; case ContentTypeSmall.ShotSpeedUpgrade: playerStats.shotSpeed += ContentObj.GetComponent <StatUpgrade>().IncreaseSmallValue; ui.ShowMessage("Shots are faster!"); break; } ExplosionScript itemEffect = mr.getObject(ObjectPool.categorie.explosion, (int)ObjectPool.explosion.itemCollected).GetComponent <ExplosionScript>(); itemEffect.Initialize(ContentObj.transform.position); GameObject heroEffect = mr.getObject(ObjectPool.categorie.explosion, (int)ObjectPool.explosion.itemCollectedHero); heroEffect.GetComponent <ExplosionScript>().Initialize(player.transform.position); heroEffect.GetComponent <Follow>().Initialize(player.gameObject); mr.returnObject(ContentObj); ContentObj = null; collected = true; } } else if (Type == ItemType.BigBox) { Player player = mr.getObject(ObjectPool.categorie.essential, (int)ObjectPool.essential.player).GetComponent <Player>(); if (player.NumberSmallKeys > 0) { player.NumberSmallKeys--; UI_Canvas ui = mr.getObject(ObjectPool.categorie.essential, (int)ObjectPool.essential.UI).GetComponent <UI_Canvas>(); ui.UpdateKeys(player.NumberSmallKeys); OpenBigBox(); } } }