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 shanereichenfeld · Jan 03, 2014 at 06:12 AM · timergameplayliveslevel-editor

Lives = play

So i have a "Main Menu" when you click "play" it takes you to a Level selector Screen with all the levels, and you can click on any level and play it. When u play a Level you have 5 heart's that you go threw and if u have zero heart's it restarts the level.

HOW DO I MAKE IT SO WHEN YOU ARE AT 0 HEART'S IT takes 1 out of 3 golden hearts away, and when u have 0 golden hearts you can't play until the golden hearts regenerate. 1 golden heart takes 20 min to generate. BUT I ONLY WANT THE GOLDEN HEARTS TO APPEAR ON THE LEVEL SELECT SCREEN.

heres my code in #c for the level 5 hearts:

 using UnityEngine;
 using System.Collections;
 
 public class EnemyDamage : MonoBehaviour {
 
     public GameManager gameMananger;
 
     int damageValue = 1;
 
     void OnTriggerEnter(Collider col){
         if(col.gameObject.tag == "Player"){
             gameMananger.SendMessage("PlayerDamaged", damageValue, SendMessageOptions.DontRequireReceiver);
         }
     }
 }

Also here my Level select Screen in #c

/// /// Level Select. /// Attached to Main Camera /// using UnityEngine; using System.Collections;

public class LevelSelect : MonoBehaviour {

 public Texture backgroundTexture;
 
 void OnGUI(){
     
     //Display our Background Texture
     GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
     
     //Displays our Buttons
     
     if (GUI.Button (new Rect (Screen.width * .1f, Screen.height * .15f, Screen.width * .1f, Screen.height * .1f), "1")) {
         print ("Clicked 1");
         UnityEngine.Application.LoadLevel("Level1");
     }
     
     if (GUI.Button (new Rect (Screen.width * .2f, Screen.height * .15f, Screen.width * .1f, Screen.height * .1f), "2")) {
         print ("Clicked 2");
     }
 }

}

What do i add to make these changes or how do i make a new script for those new changes?

Comment
Add comment · Show 1
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
avatar image ShadoX · Jan 03, 2014 at 07:58 AM 0
Share

Would be great if you could re-format that code and get rid of that caps stuff. Anyway, if you know how to check if your 5 hearts are at 0 you should be able to decrease the amount of golden hearts. Something like.. (pseudo code)

 int regularHeart = 5;
 int goldHeart = 3;
 
 if(regularHeart < 1 && goldHeart > 0){
  goldHeart -= 1; //is the same as goldHeart = goldHeart - 1;
 }
 regularHeart = 5;

Generating goldHearts would be a matter of checking the time that has passed and if 20 $$anonymous$$ have gone by you'd add 1 gold heart as long as you don't already have 3.

Depending on what type of game your making you would also have to make sure that the player can't cheat by simply setting the clock on his device to get the gold ones back quickly, but that's obviously up to you.

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

19 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

Related Questions

Energy or lives regen by time 1 Answer

Count down timer. 2 Answers

Timer not subtracting... 1 Answer

Making a Timer Out out of 3D Text using C#. 1 Answer

using player time as highscore 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