Tag Info

New answers tagged

4

Generally, you want to avoid excessive hierarchy. What if a player wants to attack an object (such as a trap, or door?) How would a trap attack a player? What about environmental hazards? I would suggest an entity-component system over inheritance here. Give everything that has health a Health component, and give everything that can attack a Weapon ...


0

What do you want to prevent? Editing or reading? Preventing reading is impossible. Your client has to be able to read and display the images and text files to allow playing the game, so everything someone would need to crack any protection you add would always have to be included in your client software. If you want to make it less tempting for a user to ...


0

As the game executable has to be able to decode the data to use it, there is no protection from an user determining the decryption key and doing the same to read the data. You can get limited protection from modifying files by encrypting them with a private key server-side, as the user will not be able to encrypt new data in a manner that is decryptable by ...


0

You might have misunderstood me a little bit. Not all objects HAVE to use factories. Perhaps only your tower and enemy objects. Maybe your Attack object as well as a Projectile. You'll need to tinker to see what fits the pattern. Some people would create a generic Entity/GameObject class though. You could do some research on Entity Component Systems to ...


1

I would avoid the general idea of a tower type. Let tower contain a set of properties that matter. An Attack object (that has its own range, RoF, damage, sound effects, onHit() effect for DoTs, etc.), a model, health, location... Then build factory classes that are asked to build a "type" of tower by figuring out how to initialize a tower to be a "cannon" ...


2

Instead of having a TowerType enum and a lot of if/else/case constructs in your code which handle differences between types, you could make your types of towers separate classes which inherit from an abstract Tower base class. These classes would set their properties in their constructors. Using sub-classes would also allow you to have a different ...


1

Here is how i think it could be done class Class1 { public enum TowerType { A, B, C }; static private Dictionary<TowerType, Tower> towerTypesInfo; static void init() { towerTypesInfo= new Dictionary<TowerType, Tower>(100);//100 tower types towerTypesInfo.Add(TowerType.A, new Tower(20, 40, 50)); ...



Top 50 recent answers are included