Skip to content
Snippets Groups Projects
Commit c66b6b87 authored by Leo Cardhio's avatar Leo Cardhio
Browse files

[feat] final stage

parent 8e1607c0
1 merge request!6[feat] final stage
This diff is collapsed.
fileFormatVersion: 2
guid: e21d8266a3f06ac4cbbfe7662feead3e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
using UnityEngine;
using UnityEngine.UI;
public class BossHealth : EnemyHealth
{
public Slider healthSlider;
public override void TakeDamage (int amount, Vector3 hitPoint)
{
//Check jika dead
if(isDead)
return;
//play audio
enemyAudio.Play ();
//kurangi health
currentHealth -= amount;
healthSlider.value = currentHealth;
//Ganti posisi particle
hitParticles.transform.position = hitPoint;
//Play particle system
hitParticles.Play();
//Dead jika health <= 0
if(currentHealth <= 0)
{
Death();
}
}
void UpdateActiveQuestStatus() {
BossQuestManager.questManager.UpdateQuestStatus("Zomhellephant");
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 47fb397d2d047f541a1dc3c4c2d3bfaa
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
......@@ -9,15 +9,15 @@ public class EnemyHealth : MonoBehaviour
public enum EnemyType{Zombunny, Zombear, Hellephant};
public EnemyType enemyType;
Animator anim;
AudioSource enemyAudio;
ParticleSystem hitParticles;
CapsuleCollider capsuleCollider;
bool isDead;
bool isSinking;
protected Animator anim;
protected AudioSource enemyAudio;
protected ParticleSystem hitParticles;
protected CapsuleCollider capsuleCollider;
protected bool isDead;
protected bool isSinking;
void Awake ()
protected void Awake ()
{
//Mendapatkan reference komponen
anim = GetComponent <Animator>();
......@@ -31,7 +31,7 @@ public class EnemyHealth : MonoBehaviour
}
void Update()
protected void Update()
{
//Check jika sinking
if (isSinking)
......@@ -42,7 +42,7 @@ public class EnemyHealth : MonoBehaviour
}
public void TakeDamage (int amount, Vector3 hitPoint)
public virtual void TakeDamage (int amount, Vector3 hitPoint)
{
//Check jika dead
if(isDead)
......@@ -67,7 +67,7 @@ public class EnemyHealth : MonoBehaviour
}
}
void Death ()
protected void Death ()
{
//set isdead
isDead = true;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossQuestManager : QuestManager
{
void Start() {
quests[0] = GenerateQuest();
ShowQuestToUI();
}
Quest GenerateQuest() {
QuestObjective questObjective = new QuestObjective(0,0,0,1);
string questTitle = GenerateQuestTitle(questObjective, new QuestObjective(0,0,0,0));
return new Quest(questTitle, questObjective, 1200);
}
public override void UpdateQuestStatus(string enemyType) {
quests[0].questProgress.Zomhellephant += 1;
quests[0].title = GenerateQuestTitle(quests[0].questObjective, quests[0].questProgress);
ShowQuestToUI();
CompleteQuest(0);
}
string GenerateQuestTitle(QuestObjective questObjective, QuestObjective questProgress) {
string questName = "Kalahkan ";
if (questObjective.Zomhellephant != 0) {
questName += $"{questProgress.Zomhellephant}/{questObjective.Zomhellephant} Zomhellephant ";
}
return questName;
}
}
fileFormatVersion: 2
guid: 51fda42979e127248aeffb507d249f7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -13,14 +13,16 @@ public class QuestManager : MonoBehaviour
public int zombunnyBounty = 5;
public int zombearBounty = 10;
public int hellephantBounty = 15;
public bool isQuestsComplete = false;
private TMP_Text titlePlaceholder;
private TMP_Text coinValuePlaceholder;
private Image completeMark;
protected TMP_Text titlePlaceholder;
protected TMP_Text coinValuePlaceholder;
protected Image completeMark;
public static QuestManager questManager;
private void Awake()
protected void Awake()
{
if (questManager == null)
{
......@@ -59,7 +61,7 @@ public class QuestManager : MonoBehaviour
return new Quest(questName, questObjective, totalReward);
}
void ShowQuestToUI() {
protected void ShowQuestToUI() {
for (int i = 0; i < questPlaceholders.Length; i++) {
titlePlaceholder = questPlaceholders[i].transform.GetChild(0).GetComponent<TMP_Text>();
coinValuePlaceholder = questPlaceholders[i].transform.GetChild(2).GetComponent<TMP_Text>();
......@@ -84,9 +86,25 @@ public class QuestManager : MonoBehaviour
completeMark.color = tempColor;
GameManager.gameManager.coins += quests[questIdx].questReward;
quests[questIdx].isCompleted = true;
isQuestsComplete = isAllQuestComplete();
Debug.Log(isQuestsComplete);
}
public void UpdateQuestStatus(string enemyType) {
protected bool isAllQuestComplete() {
bool isAllComplete = true;
for (int i = 0; i < quests.Length; i++) {
if (!quests[i].isCompleted) {
isAllComplete = false;
break;
}
}
return isAllComplete;
}
public virtual void UpdateQuestStatus(string enemyType) {
bool isZombunnyAlocated = false;
bool isZombearAlocated = false;
bool isHellephantAlocated = false;
......@@ -141,6 +159,7 @@ public class QuestManager : MonoBehaviour
if (questObjective.Hellephant != 0) {
questName += $"{questProgress.Hellephant}/{questObjective.Hellephant} Hellephant ";
}
return questName;
}
......
......@@ -22,9 +22,16 @@ public class QuestObjective
set { hellephant = value; }
}
public QuestObjective(int zombunny, int zombear, int hellephant) {
private int zomhellephant;
public int Zomhellephant {
get { return zomhellephant; }
set { zomhellephant = value; }
}
public QuestObjective(int zombunny, int zombear, int hellephant, int zomhellephant = 0) {
this.zombunny = zombunny;
this.zombear = zombear;
this.hellephant = hellephant;
this.zomhellephant = zomhellephant;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment