Class Hierarchy - Data Design In A RPG Game Where Classes Overlap?

Aug 19, 2010

This is a followup to the question I asked here:

[URL]

I understand the answer in the post above, which is absolutely amazing, by the way. It's about implementing interfaces with a class. However, what if a class needs to share features with another class?Yes, that class can an Interface. However, let's use this sample definition.

[code]...

Or, in other words:An equippable item can perform acts outside of its typical usage of a shield or weapon. But not all items can act as a sheid or weapon.I mean, I could create a class that implements IWeapon, IShield, IMagic, IUseableItem, etc. But there should be a better way than returning NULL when those interfaces are called.

View 2 Replies


ADVERTISEMENT

Class Hierarchy - Data Design In An RPG Game

Aug 10, 2010

how to organize the classes within my RPG project that I'm making. I've tried to implement a battle system but I am not comfortable with my initial results. This is the basic layout I currently have for my classes. [Code] clsCharacter contains statistics pertaining to one character, including magic available to that character to use. Also includes what weapons that character has equipped. clsTeam contains multiple clsCharacter, as well as a list of items that each clsCharacter in the team can use. clsBattle contains two clsTeams. One team is the player and the other is the computer. Now, this is a wonderful way to organize data. However, I see limitations with this approach. For instance, to pass data from Battle to Character, it has to pass through the team class and vice-versa. Plus, if I use Properties, it transfers data as ByVal instead of ByRef, so I cannot guarantee that I'm editing the original and not a copy of the passed object (IIRC)

In addition, I feel it is just messy code to include methods within the clsCharacter class that invoke this: MyTeam.MyBattle.DoAction(). Plus, the clsCharacter might not even be in the battle at the time - I don't won't to bog down that class featuring code that is exclusive for battling when I also need to be concerned about moving around the map, saving/loading data, etc. So, any suggestions? Right now, I'm burnt out of ideas. One idea I have so far is to include a function for the clsCharacter that exports a list of all possible moves the character could make, and if the character is CPU choose the most optimal one, and if Human than wrap it up in some nifty GUI so they can choose what action to take. But at the same time, how do I use that information within the context of the battle?

View 2 Replies

Design Patterns - Inheritance - Do All Properties In The Derived Classes Have To Be Declared In The Base Class

Aug 8, 2011

Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'

public mustinherit class Document
public property Contents as string
public sub new()...

[code]....

View 3 Replies

Event Won't Come Through Class Hierarchy

Feb 2, 2010

I'm writing a Windows Forms application in VB.Net 2008, .NET Framework 3.5, and I am trying to handle an event created by a class that get's instantiated several times throughout the program. The thing is the events gets fired in the Functions class, but nothing's happening in the main class.I tried to change the called class by instantiating it in the beginning of the main class, by using 'WithEvents testEvent as MTO_Tool.Functions = New Functions' but that also didn't work.

Code:

' The main class:
Public Class MainScreen
WithEvents testEvent As MTO_tool.Functions
Private Sub test() Handles testEvent.SaveChanges

[code]....

View 1 Replies

Inheritance Hierarchy For Class Quadrilateral / Square And Rectangle

Sep 30, 2009

I have to write an inheritance hierarchy for class Quadrilateral, square and rectangle. Use Quadrilateral as base class of the hierarchy.

So for I had this:
Public MustInherit Class Quadrilateral
Public Function getName() As String
Return "Shape"
End Function

View 1 Replies

C# - Class Design For Reports In .NET Application That Use A Conglomeration Of Data?

Jul 20, 2011

I can articulate my question well enough to get some clear and usable feedback here. I have reports (like paper reports) in my .NET application that have data bound to them. Typically the reports are a combination of many data elements across several busniess entites that may not all relate through an Inheritance hierarcy, etc. This makes it difficult to get all the needed data placed together to bind to the report.

So what I have done before are make 'Report' classes with data elements specific to supporting the reports they are bound to, and on the back end might be tied to specially created Stored Procedures that bring this data back (maybe several joins across many tables to get the right data needed). So if I was to make an analogy to the database world, I am essentially 'denormailizing' the data structure to get all of this data into a single class to make it easy to bind to the report.

However on the hard line OOP concepts and architecture design, one could say that a report is just another 'thing' to bind data to, and its class should not be designed just to suit the needs of data binding. In this thought process, I would actually need to make my class design be able to create the relationships needed to get all of the data together properly to still be bound, but not create any special 'Report' classes. I find this difficult to do sometimes. It is much easier to create these relationships in the back end stored procedures and then just output the resultset to be almost immediately bound to the report.

So what is the right way to solve this? If I create these specialized report classes with really no behavior, am I introducing an anti-pattern like the Anemic Domain Model?I could use some feedback, and please speak up if my question and scenarios did not make sense.

View 1 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

Possible To Create Interfaces And Classes In Design Mode?

Nov 16, 2009

Sometime ago I used to create all my class structures in vision before I wrote them. That however didn't last. I found it easier to just make little drawings with pencil and piece of paper. And I still do to this day. In code usually those drawings manifest themselves as interfaces which then are implemented by different classes. I do all this in code. And I was just wondering if there is any tools available in Visual Studio for VB.NET that would allow to create interfaces and implement them in classes (which a lot of times means just adding variables to class that will hold data passed with interface attributes) from design mode(kinda like using Visio only after you finish you don't have to write out code).

View 3 Replies

Asp.net - Design A Game Web App?

Jun 21, 2009

i know vb.net, but have had no experience at all with web programming. i need to make a web app that can run in a browser where there is a board game and pieces that you can move around. can someone help me get started? are there any examples in asp.net?

i need something like this:

[code].....

i don't know what language this is built in, but i would much prefer vb.net. i would like the pieces to be pictures instead of text.

View 5 Replies

C# - Why Are Many Designer Classes In System.Design Marked As Internal

Aug 28, 2009

I have been developing some components for our products at work, and one of them is based off the flow layout panel.What i would like to do is provide a custom designer for it, but without loosing the features provided by it's default designer (System.Windows.Forms.Design.FlowLayoutPanelDesigner) which is marked as internal.Using Reflector i thought i would just implement it again myself, seeing as it inherits from 'FlowPanelDesigner and that from PanelDesigner` all of which are internal.

Why would these classes be specifically marked as internal? Is it due to them being specifically for Visual Studio use, and thus not 'framework' code?Also, is there an easier option that re-implementing all the functionality?

View 2 Replies

Partial Classes - Add A Control Or Change A Property At Design-time

Mar 26, 2008

In my never ending search for more knowledge, I have come across Partial Classes. I was wondering if some of the kind people who actually understand the uses could explain some of them to me. Now I know that when we create a form that we actually create a partial class which the generator rewrites when we add a control or change a property at design-time, and this allows us not to have to worry about setting up the controls ourselves.

[Code]...

View 2 Replies

Make And Design A Game In VB 2008

Mar 20, 2009

I have have to make and design a game in visual basic 2008 for college i also started colleage late... i dont kow how to start my game. the way the game is blackjack (21)

View 1 Replies

Get A Value Inside Parent Class From Child Class (in Nested Classes)?

Jan 1, 2012

I have Class1 and class2 which is inside class1, VB.NET code:

Public Class class1
Public varisbleX As Integer = 1
Public Class class2

[code]....

View 1 Replies

Make Design Box For The Concentration Game In VB 2010?

May 13, 2011

I am trying to make my design box for the Concentration game in VB 2010. And do not know what kind of box to use, to show the cards that flip over.

View 4 Replies

Flattening An Object Hierarchy Using A Shim Class - Initializing Derived Object Properties From The Base Object?

Jul 10, 2010

I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:

newProperty1 - a new string property of the derived class

flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class

Code example:

Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......

Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.

Code example:

' property names are in the string array fieldNames

'baseObjQuery is an ienumerable of baseObj

'derivedObjList is a list of derivedObj[code].....

Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?

View 7 Replies

Video Poker Game Using Visual Studio - Create Classes?

Jun 25, 2009

I am very new to this whole programming thing and I have read several books and many websites but I can't get a good start on creating a video poker game. I understand that I need to create classes, but have no idea how to start. Most of the things I have been reading have been for Visual Basic 6.0 and it appears hard to understand. I am looking for some type of tutorial of how to create the classes I need and how to get the actual information from the classes into my form. Can anyone out there provide me with a good starting point? Is there any good (and easy) code out there to get me started. I feel that if I can get a good starting base, I can learn from there.

View 3 Replies

Class - .net Interface And A Classes?

Mar 25, 2012

I have a class which has a variety of details, as follows:

Vehicle Name
Vehicle Address
VEHICLE Percentage: 10

I need to somehow use an Interface for another version, SpecialVehicle.

Special Vehicle has a different Percentage, for example 15.

How can I integrate that in an interface? I just don't understand them?

View 1 Replies

Best Pratice In Inheritance - Three Classes Employee, Manager And Salesman. Manager And Salesman Classes Inherits Employee Class

Jul 27, 2010

I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.

Employee :

Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single

[CODE]...

Manager :

Public Class Manager
Inherits Employee

[CODE]...

Salesman :

Public Class Salesman
Inherits Employee

[CODE]...

Now I have created a object of salesman and manager using the following code:

Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")

Is this a good programming pratice or should I use:

Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")

View 6 Replies

.net - Inner Classes Building XML - Have Outer Class Put It Together?

Feb 25, 2011

I am trying to create a class whose end result is do create an XML document. Currently the class consists of nested classes that each build a section of the XML document. What I am hung up on is how I should tie the results of the inner classes for the final output.Should the outer class pass an instance of XmlTextWriter to each of the inner classes that build up specific sections or should each innerclass just output a string representation of the XML and the outer class can piece them together?

[code]...

The code is not complete but I hope it gives an idea of what I am trying to accomplish. I need to find a way to gather XML sections together to output as a single document.

View 3 Replies

.net - Monitoring All Events In A Class And Sub-classes

Apr 25, 2010

I'd like to be able to log to the console every time an event is fired either in the object I've instantiated or in anything it's instantiated [ad infinitum]. I wouldn't see some of these events normally due to them being consumed further down the chain). Ideally I would be able to log all public and private events but if only public are possible, I can live with that.

I've Googled and all I can find is how to monitor a directory - So I'm not sure if this is not possible or simply has a name that I don't know.

The sort of information I'm after is similar to what's found in an exception - Target Site, Source, Stack Trace, etc...

Could I perhaps do this through reflection somehow?

To Give you an idea of the console App:

Sub Main()
Container = ContainerGenerate.GenerateContainer()
Dim TemplateID As New Guid("5959b961-b347-46bc-b1b6-cba311304f43")

[Code]....

View 2 Replies

Class Project Developing Classes?

Apr 15, 2012

I'm working on a class project where I have to create an item class with private attributes, public get and set methods for the attributes, and two non-access methods. I have two textbooks I work with. The first book is Clearly Visual Basic(Zak) and the second is Programming, Logic, and Design(Farrel). I've set my private attributes but I am having difficulty writing what I want to accomplish in the VB.net language.

Class CD1
Declarations
private string cdName
private string aristName

[code]....

View 14 Replies

Class SELF That Is Hosted By A Couple Different Classes?

Jan 16, 2010

I have a class SELF that is hosted by a couple different classes. Basically, the hosting class HOST calls a method in SELF. SELF is passed HOST as an argument in the constructor, so SELF can call methods in HOST. In normal situations, a call to HOST will do something minor, then return so that SELF can continue. However, for one particular type of HOST, one of the calls from SELF to HOST will cause HOST to call SELF, and so on ad infinitum. A classic, though convoluted, case of recursion. Once again, this is only going to happen for one type of HOST. For other types of HOST, that particular call will not cause HOST to call SELF, so there will be no recursion. Nonetheless, there is no getting around it in one case.

I can see two means to decouple the recursion, and I am wondering which one (or a third) would work best:

1) Add a timer into that particular HOST so that the call from SELF that would trigger the recursion would actually just start the timer in HOST, then return. When the timer ticks, HOST can call SELF. The recursion is broken because the call to SELF is done on the timer event, and not when SELF called HOST.

2) As it happens, HOST makes the first call to SELF in a background thread, which means I don't really need to worry whether this thread blocks or not. Therefore, I could have this background thread spawn a second background thread to make the call to SELF, then have the initial HOST thread JOIN on the second thread. This means that the initial thread will block until the second thread finishes. Meanwhile, the second thread will call HOST, and the HOST won't call back to SELF, it will just return like all the other HOST objects would do. This will allow the second thread to run to completion. When the second thread completes, the first thread will take over and call SELF again on a new second thread. Therefore, the recursion is broken because the secondary thread will always run to completion, and the primary thread will wait for the secondary thread to complete, then call it again.

I tend to prefer the second option, because the first option involves a pause of some length (the minimum for a timer, which is pretty small), while the second doesn't, but the first option is actually a little easier to implement.

View 6 Replies

Creating A Class That Contains Other Classes/Objects?

Aug 27, 2010

I'm wondering on how you would go abouts instantiating a class that contains other complex objects. for example an Payment Class which has Date,Time, etc.. and it also holds a reference to a paymethod object which has id,Type,Description etc.. How do you instantiate the payment class with all the other objects without one or the other failing, how do you create the payment class which doesn

View 4 Replies

[OOD] Class Design For With Database Back End

Feb 6, 2010

I was hoping that I could get some guidance from some of you guys on Object Design with Database back ends. I am trying to build what could be considered to be my first full scale application, which is a student tracker (simplification). While I have a reasonable idea of how I would go about designing the classes for the system, the bit that I don't know how to do is, how I would go about getting the data to and from the database.

For example with my other applications, I have done a couple of things;

1) Gathered all the data when the application started up, creating the objects then. Then when the application closed sending the data back to the database.

2) Have the code which deals with getting the data in the specific class, so the student class for example would take only one constructor argument which would be the studentID, then the class code would connect to the database and populate the object fields as appropriate.

3) Variations of the above. I have also looked into LINQ, which seems like it would be very useful if you don't expect your classes to deal with any business logic and just data, but I suppose it would be possible to create a wrapper class that would include the business logic.

[Code]....

View 1 Replies

[OOD] Class Design For With Database Back End?

Mar 11, 2010

I was hoping that I could get some guidance from some of you guys on Object Design with Database back ends.I am trying to build what could be considered to be my first full scale application, which is a student tracker (simplification). While I have a reasonable idea of how I would go about designing the classes for the system, the bit that I don't know how to do is, how I would go about getting the data to and from the database

View 3 Replies

.net :: Convert C# Classes (class Library) To SQL DDL (tables)?

Aug 4, 2010

I have to convert a set of C# classes (class library) to SQL tables to be used by SQL Server, so that the data can be stored in a database and manipulated through the database.The problem is that the number of these classes is big (more than 1000 classes),and it would take a long time to setup manually such a database schema (tables,ndexes, stored procedures, etc.) - not to mention the class hierarchies that I need to maintain.

View 6 Replies

Call & Use A Classes Type From Methods Within The Class?

Mar 3, 2011

I will preface this by saying Im previously an asp developer and am learning oop programming/Vb.Net

Im working on a 3 tier architecture and trying to abstract my code as much as possible since I have a very large intranet to convert. In my business layer I am defining my classes with management methods. Below is an example of one of my classes.

My question: Is there a way for me to genericaly refer to the class type and object type so that I dont have to continualy refer to the class name/type "ServiceRequest" throughout the class. For example something like:

[Code]...

View 1 Replies

Create Multiple Classes Of Different Names That Use That Class?

Mar 6, 2009

Okay, say I have a class named "ChannelList", and it raises an event named "FoundChannel"

But what I'M wanting to do is create multiple classes of different names that use that class, but I want to have all of the "FoundChannel" events be handled under one single sub routine?

View 15 Replies

Instance A Class, Based On Other Classes, Add New Properties?

May 26, 2009

You know how everyone says "C++ is like C with classes"?How similar is it to .NET classes? instance a class, based on other classes, add new properties, override existing properties, etc?Are the variables strongly-typed and declared before they are used? Or is it a Duck-Typing language like Python?

Also, does it have its own Garbage Collector that disposes of objects when the pointer exits their scope,or do you have to manually clear and get rid of them when you finish with them? What's the difference between native C++, and the "managed C++" in Visual Studio? Because I'd prefer to use native code if its not too much harder. for the sake of all that is good and holy, don't use ACCESS, EXCEL, or a TEXT FILE as a database. If you want your program to use a "local database", without any of the hassle of setting up a MS SQL or MySQL server, just click this link: >>> SQLite <<< Seriously. This is for your own good.

View 3 Replies

Losing Class Variables - Use Classes More In My Programs

Sep 24, 2010

I'm trying to use classes more in my programs. I'm using classes. This is the section of the main form that is causing the problem:

If conType = Nothing Then
TaOrIbt()
End If
objGetECaptureType.CaptureType(conType)

[CODE]...

View 12 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved