Hello, I’m trying to make items/ upgrades for my in-game store. My store has two tiers of weapons: boosts and weapons. I’m trying to make a script that can teleport my player to a certain distances in my level (500 units of distance, 750 units of distance, and 1000 units of distance). My other tier (weapons) would all use the same script, but it would have a different value of hit points attached to it. I tried to make these scripts on my own, but nothing I made functioned properly. I already have a script to manage my gui in the store, but I can never get the actual items right. Anyone have any ideas on where to start?
The first thing i would do is read up on inheritance. This way you can actually create a script and just inherit all of it’s information and change what you need on a per weapon basis.
where would I find that?
http://msdn.microsoft.com/en-us/library/ms173149(v=vs.80).aspx
Basically Inheritence is when you make something and then “duplicate” it with a different name and different contents, and the compiler gives the original contents.
Probably a bad explaination
public class Animal {
// This is the orignal class, it holds all the data that all animals have in common
// For example age name, color, amount of legs.. etc
private string name;
private int age;
}
pubic class Dog : Animal {
// Notice the " : Animal" after the class name Dog
// This means we are inheriting from Animal, so we are getting the two variables
// declared in Animal and we do not have to declare them again
// Now in this class we can declare all things specific to Dogs
private bool isAlphaMale;
}
public class Cat : Animal {
// Same thing with Dog, we are inheriting from Animal, so cat
// gets the variables name and age without having to declare them
// Both this class and dog are seperate so if we change the Dogs name
// to rover, and we change the cats name to theodore then the dogs name willl stay
// as rover cause the variables are seperated by the class that is inheriting
private bool kingOfTheHouse = true;
}