Thread: XNA using C#
View Single Post
Old 02-29-2008, 10:40 PM   #29 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 229
+8 Internets
Send a message via ICQ to Cloud9_
... and you're putting all that in the battle engine? How are you doing that?

My thought process would be to code the battle engine pretty standard, so you can add items like that all day and take some away.. or add properties to that sword later if you choose. Basically if the health drain was attached to the item, place a method in that items cs file, something like;

Code:
public void OnSwing(int StatToCheckChanceOfHit) { // Sword has 10% chance to do life drain modified by the person's StatToCheckChanceOfHit. If (SuccessfulHit) Deals extra damage, damage over time, and heals the user by said damage }
i dont know what you're tryin to do but thats actually a pretty cool idea.. but in the actual battle engine, i'd put a way to find that information... not that information itself. That way if you ever wanted to change what the sword does, or if you wanted to add that effect to another sword, or add 100 items into the game with different effects, you just have to include that OnSwing() method into the item, because the battle engine is just going to check the players equipped items for an OnSwing method.

I know i didn't explain that well, but thats how i'd try to code it... What are some other options? (trying to get a feel of getting many different solutions to problems, see things from other angles, u know? )

EDIT:

Ok i think i have a better way of explaining what i was trying to say For example, in my battle engine I have a 3 public methods (Initialize, Update and Draw) what i would probably do is

public void Update()
{
UpdateTimers(); // Updates the battle timers (can player attack yet, monster attack yet, any repeating environmental damage, haste / slow effects, etc
UpdatePlayer(); // if player timer is expired, show players options, execute options, set timer, etc etc
UpdateMonster(); // if MOBs timer is expired, let the MOB do their move, set monster timer, etc etc

}//end Update

then later on in UpdatePlayer(), when they swing their weapon do something like
UpdatePlayer()
{
yadda yadda, other code here, do all this jazz...
if (attack)
{ Swing weapon; check weapons OnSwing() method for any additional properties attached to weapon; apply those OnSwing() properties. If haste grant user haste for X rounds... if health leach, drain health while adding to you, etc etc. }
}

Last edited by Cloud9_ : 02-29-2008 at 10:51 PM.
Cloud9_ is offline   Reply With Quote

 
Uberguilds Network