Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_kOF0lKp4ioWdcw · Jun 26, 2020 at 03:00 PM · score systemkillquests

Kill Quest Issue

Hi guys I am trying to make Kill quest system for my game but unfortunately I cant manage to pass this point I am following this tutorial but still doesnt work. https://www.youtube.com/watch?v=LONrh-6xbXQ

Here are the scripts

[System.Serializable] public class Quest { public bool isActive; public List Goals = new List(); public string title; public string description; public int experienceReward; public int goldReward; //public Item ItemReward {get; set;} public bool Completed { get; set; }

 public void CheckGoals()
 {
     Completed = Goals.All(g => g.Completed);
     if (Completed) GiveReward();
 }
 public void Complete()
 {
     isActive = false;
     Debug.Log(title + "was completed");
 }
  
 void GiveReward()
 {
     // give reward
     Debug.Log("Reward given");
 }

}

[System.Serializable] public class Goal { public string Description; public bool Completed; public int CurrentAmount; public int RequiredAmount;

 public virtual void Init()
 {
     //default
     Debug.Log("init works");
 }

 public void Evaluate()
 {
     if(CurrentAmount >= RequiredAmount)
     {
         Complete();
         Debug.Log("quest completed");
     }
 }

 public void Complete()
 {
     Completed = true;
 }

}

public class KillGoal : Goal { public int EnemyID; public int QuestAmount; public KillGoal(int enemyID, string description, bool completed, int currentAmount, int requiredAmount) { this.EnemyID = enemyID; this.Description = description; this.Completed = completed; this.CurrentAmount = currentAmount; this.RequiredAmount = requiredAmount; }

 public override void Init()
 {
     base.Init();
     CombatEvents.OnEnemyDeath += this.EnemyDied;
     Debug.Log("initiliasing");
     
    
 }

 void EnemyDied(IEnemy enemy)
 {
     if(enemy.ID == EnemyID)
     {
         this.CurrentAmount++;
         Evaluate();
         Debug.Log("enemyDied ++");
     }
 }

}

public class CombatEvents : MonoBehaviour { public delegate void EnemyEventHandler(IEnemy enemy); public static event EnemyEventHandler OnEnemyDeath;

 public static void EnemyDied(IEnemy enemy)
 {
     if(OnEnemyDeath != null)
     {
      OnEnemyDeath(enemy);
         
     }
     
 }
 

}

public class EnemyHealth : MonoBehaviour ,IEnemy { public int enemyHealth; public int currentHealth; public int speed; public delegate void onEnemyDeath(); public static event onEnemyDeath enemyDeath;

 public int ID { get; set; }
                               // public int enemyQScore = 1;
 public LayerMask Ground;
 private Animator anim;
 public GameObject bloodEffect;

// public GameObject bloodSplash; public int scoreValue = 1; public GameAssets Player;

 void Start()
 {
    ID = 1;
     
     anim = GetComponent<Animator>();
     currentHealth = enemyHealth;
   
 }

 void Update()
 {
    
     if (enemyHealth <= 0)
     {
         //Instantiate(bloodSplash, transform.position, Quaternion.identity);
         Instantiate(bloodEffect, transform.position, Quaternion.identity);
         UpdateQuestScore();
         Destroy(gameObject);
         SoundManager.PlaySound(SoundManager.Sound.EnemyDie);
        
         
     }
     {
         transform.Translate(Vector2.left * speed * Time.deltaTime);
     }


 }
 public void TakeDamage(int damage)
 {
     
     Instantiate(bloodEffect, transform.position, Quaternion.identity);
     enemyHealth -= damage;
    // Debug.Log("damage TAKEN !");
 }
 public void OnDestroy()
 {
    
     ScoreManager.score += scoreValue;
     
     
 }
 public void UpdateQuestScore()
 {
     if (enemyDeath != null)
     {
         enemyDeath();
         Debug.Log("updateQS");
     }
 }
 
 
 

}

Will appreciate any help or advice. I cant update the score after my enemy dies to the quest so i can reach the required amount and finish the quest.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

129 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Attaching kill volume to a particle effect..posible and how? 3 Answers

I want to know how to script a kill counter 2 Answers

Kill Streak Help 3 Answers

How can I have the player be able to kill an enemy by jumping on top of it? 1 Answer

Scoring help ! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges