Upgrade Sistem. (Please help me D:)

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Basically this:

    Im trying to make an upgrade sistem for my tower defence.

    The first one has a problem, i want that when i select that tower if the player dont buy the upgrade in 2 seconds, the tower will stop getting selected animation. (but instead, if i buy the upgrade the tower will change to the upgrade texture, but than 2 seconds later it will get back to default :C)

    The second one, I want to make that only when one single tower is selected, the upgrade will be done.

    because, right now if you are fast enough you can make that multiple towers selected at the same time get upgraded at the cost of 1.

  • I am not too sure if I understand correctly, but you can fix all of them using variables.

    But the first thing you will need to fix is the second part of your question. To make sure only that one tower is upgraded, use a variable to record that tower's UID. In case you don't know, UID is like a number tag given to every single sprite in the game. Also, add a simple sprite into your layout, just a small one and you can set it to invisible as well, I will explain why we want it later, but for now, let's call it SpriteInvisible. So what you can do is this:

    On left button clicked on DialShooter --> Set Variable1 to DialShooter.UID. And also Set SpriteInvisible position to DialShooter's x and y coordinates.

    Than when the player clicks on the upgrade button, create a sub event and select the DialShooter by UID, using Variable1 as a reference. That will take care of your second issue.

    For the first one, you need to remember that the sub events will all run as the conditions have been met, so it will always return to default after 2 seconds. What you want to do is do a check to see if it has been upgraded or not. If not, than only return the animation to default.

    Again you can do this using variables. And for this case, I won't use the Wait action, I would rather create my own custom timer cause I think it will work better. What I would do is this, create 2 global variables, one called CheckTime, another called CountDown. And another local variable for the DialShooter, called ReturnDefault. Now on for your first event, just add the three actions and remove the rest. Set CountDown to 120, CheckTime to 1, and ReturnDefault to 1.

    Create a new event and set three conditions, check if CheckTime = 1, CountDown > 0, and add the every tick condition together. In the subevent, use the deduct variable to deduct Countdown by 1 (because in the every tick condition, 60 ticks equal 1 second, so 120 ticks equal 2 seconds. So once your Countdown reaches 0, that means the 2 seconds are up. Create an event below with two conditions, if CheckTime = 1 and CountDown =< 0, add the action set CheckTime = 0 and select the DialShooter with the UID variable, and return it's animation to default. And as you can see, if the player clicks on another DialShooter, the CountDown is reset to 120 again from the event above.

    Lastly, you still have your local variable ReturnDefault which is at 1. The reason we want this is because, if you select another DialShooter halfway while it is counting down, the events only work on the new DialShooter, and the first one you selected will never return to default animation. Remember the SpriteInvisible we used earlier, this is where it will come in handy. Create a new event below, with two conditions. If ReturnDefault = 1, and if DialShooter is NOT overlapping with SpriteInvisible, set it's animation to default and also set the ReturnDefault back to 0. Remember to set ReturnDefault back to 0 for the event when you upgrade as well.

    I'm sure there must be a more effective way, but this should work for you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I am not too sure if I understand correctly, but you can fix all of them using variables.

    But the first thing you will need to fix is the second part of your question. To make sure only that one tower is upgraded, use a variable to record that tower's UID. In case you don't know, UID is like a number tag given to every single sprite in the game. Also, add a simple sprite into your layout, just a small one and you can set it to invisible as well, I will explain why we want it later, but for now, let's call it SpriteInvisible. So what you can do is this:

    On left button clicked on DialShooter --> Set Variable1 to DialShooter.UID. And also Set SpriteInvisible position to DialShooter's x and y coordinates.

    Than when the player clicks on the upgrade button, create a sub event and select the DialShooter by UID, using Variable1 as a reference. That will take care of your second issue.

    For the first one, you need to remember that the sub events will all run as the conditions have been met, so it will always return to default after 2 seconds. What you want to do is do a check to see if it has been upgraded or not. If not, than only return the animation to default.

    Again you can do this using variables. And for this case, I won't use the Wait action, I would rather create my own custom timer cause I think it will work better. What I would do is this, create 2 global variables, one called CheckTime, another called CountDown. And another local variable for the DialShooter, called ReturnDefault. Now on for your first event, just add the three actions and remove the rest. Set CountDown to 120, CheckTime to 1, and ReturnDefault to 1.

    Create a new event and set three conditions, check if CheckTime = 1, CountDown > 0, and add the every tick condition together. In the subevent, use the deduct variable to deduct Countdown by 1 (because in the every tick condition, 60 ticks equal 1 second, so 120 ticks equal 2 seconds. So once your Countdown reaches 0, that means the 2 seconds are up. Create an event below with two conditions, if CheckTime = 1 and CountDown =< 0, add the action set CheckTime = 0 and select the DialShooter with the UID variable, and return it's animation to default. And as you can see, if the player clicks on another DialShooter, the CountDown is reset to 120 again from the event above.

    Lastly, you still have your local variable ReturnDefault which is at 1. The reason we want this is because, if you select another DialShooter halfway while it is counting down, the events only work on the new DialShooter, and the first one you selected will never return to default animation. Remember the SpriteInvisible we used earlier, this is where it will come in handy. Create a new event below, with two conditions. If ReturnDefault = 1, and if DialShooter is NOT overlapping with SpriteInvisible, set it's animation to default and also set the ReturnDefault back to 0. Remember to set ReturnDefault back to 0 for the event when you upgrade as well.

    I'm sure there must be a more effective way, but this should work for you.

    Sorry i couldnt understand some stuff. like, what do you mean with the "UID variable", and its becase im new to construct. and i cant find any event/action called "Deduct" or with "deduct" on it.

    ¿Could you please send me a screen shot or an example of this? i would areciatte. Same with the spritinvisible, i couldnt pretty much understand the sistem. ill send you a gif:

  • Ok give me a few minutes, I will set up a simple capx for you to learn and understand.

    https://www.dropbox.com/s/5dt1bsu8m35pcud/SelectingExample.capx?dl=0

    Ok the link is above. It is a simple capx and commented so you can study it to understand how it works than you will be able to easily apply it to your own game. In the capx, you can also copy and drag more Sprite around, it will still work the same no matter how many you have because we are using UIDs to select each individual sprites. Have fun!

  • Ok give me a few minutes, I will set up a simple capx for you to learn and understand.

    Aw men thank you.

    i really apreciatte the fact that you took the time to do this

    ¿Do you have any sort of contact? like email, or facebook or skype. (i can read pm's but i cant send one because of the reputation limit)

    its because i dont have contacts that are actually really good at construct 2 (well basically i dont have any contact that uses construct)

  • I seldom use facebook and skype. If you need help, just post here or make a new thread, there are many people here who are able to help you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)