[游戏开发参考书-用DirectX编写RPG游戏]这是一个系列的丛书如果你都看并且懂的话你就可以你工作啦!

源代码在线查看: script.h

软件大小: 33896 K
上传用户: zxixi2007
关键词: DirectX RPG 编写
下载地址: 免注册下载 普通下载 VIP

相关代码

				#ifndef _SCRIPT_H_
				#define _SCRIPT_H_
				
				// Script structures ///////////////////////////////
				enum Types { _NONE = 0, _TEXT, _BOOL, _INT, _FLOAT, _CHOICE };
				
				typedef struct sScriptEntry
				{
				  long   Type;         // Type of entry
				
				  union {
				    long   IOValue;    // Used for saving/loading
				    long   Length;     // Length of text (w/0 terminator)
				    long   Selection;  // Selection in choice
				    BOOL   bValue;     // BOOL value
				    long   lValue;     // long value
				    float  fValue;     // float value
				  };
				  char    *Text;       // Text buffer
				
				  sScriptEntry()
				  {
				    Type = _NONE;
				    IOValue = 0;
				    Text = NULL;
				  }
				
				  ~sScriptEntry()
				  {
				    delete [] Text;
				  }
				} sScriptEntry;
				
				typedef struct sScript
				{
				  long          Type;        // 0-(#actions)-1
				  long          NumEntries;  // # entries
				  sScriptEntry *Entries;     // Array of entries
				
				  sScript      *Prev;        // Prev in list
				  sScript      *Next;        // Next in a list
				
				  sScript()
				  { 
				    Type = 0;
				    NumEntries = 0;
				    Entries = NULL;
				    Prev = Next = NULL;
				  }
				
				  ~sScript()
				  {
				    delete [] Entries;
				    delete Next;
				  }
				} sScript;
				
				class cScript 
				{
				  private:
				    long     m_NumActions;
				    sScript *m_ScriptParent;
				
				    virtual BOOL Prepare() { return TRUE; }
				    virtual BOOL Release() { return TRUE; }
				
				    virtual sScript *Process(sScript *Script) 
				            { return Script->Next; }
				
				  public:
				    cScript();
				    ~cScript();
				
				    BOOL Load(char *Filename);
				    BOOL Free();
				    BOOL Execute(char *Filename);
				
				    sScript *GetParentScript();
				};
				
				#endif
							

相关资源