Jump to content
  • Advertisement
Sign in to follow this  
ChristOwnsMe

Object creation in Scripts or engine

This topic is 2527 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am making a game with XNA and using cs-script(c#) for scripting and I am having some design issues. I am not understanding where my npc objects should exist or be created. Here is an example script.



using System;
using WafflezEngine;

public class ClassName
{
public bool AlreadyOpen=false;

public void DecideOnAction()
{

}

public String GetRenderImage()
{

return "Sprite_Sheet.png";
}

public void OnClick()
{
if(!AlreadyOpen)
{
WSU.Util.CreateWindow(0,0);
AlreadyOpen=true;
}
}

}

This script implements the following interface.


public interface EntityAI
{
void OnClick();//runs when npc has been clicked on
void DecideOnAction();//runs evaluators and decides on best action
String GetRenderImage();//gets the image this npc uses to draw itself
}

My NPC objects have the member variable

public EntityAI Script;

in the class definition.


Currently an npc object is created in the engine and then the script is loaded into that object. However, with this setup, the npc script can't access the npc object it is created for, and therefor can't run any NPC object methods, like Move(), etc. Should i be creating NPC objects INSIDE of the script? Any script design help would be appreciated. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!