XNA Creators Club Online
Page 1 of 1 (11 items)
Sort Posts: Previous Next

Please Help Me With The book "RPG Programming Using XNA".

Last post 11/20/2009 9:54 PM by Aflakjuju. 10 replies.
  • 11/20/2009 3:40 PM

    Please Help Me With The book "RPG Programming Using XNA".

    Hello, I'm trevor and im looking for some help with Jim Perry's book, RPG Programming Using XNA Game Studio 3.0.
    I have no idea why its doing this, so im looking for some help.

    EDIT: Here is my new source code:

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Text;  
     
    namespace RPG  
    {  
        public class Stat  
        {  
            private StartType _type;  
            private string _name;  
            private string _abbreviation;  
            private string _description;  
            private string _statCalculation;  
     
            private static readonly char[] _operators = { '+', '-', '*', '/' };  
     
            public const short MaxStatValue = (short)DieType.d99;  
            public const short HealMaxStatValue = (short)DieType.d999;  
     
            public const int PoundsPerStatPoint = 3;  
        }  
     
        public enum StatType  
        {  
            Regular,  
            Calculated  
        }  
     
        public Stat()  
        {  
        }  
     
        public Stat(string name)  
        {  
            _name = name;  
        }  
     
        public StatType Type  
        {  
            get { return _type; }  
            set { _type = value; }  
        }  
     
        public string Name  
        {  
            get { return _name; }  
            set { if (!string.IsNullOrEmpty(value)) _name = value; }  
        }  
     
        public string Abbreviation  
        {  
            get { return _abbriviation; }  
            set { if (!string.IsNullOrEmpty(value)) _abbriviation = value; }  
        }  
     
        public string Description  
        {  
            get { return _description; }  
            set { if (!string.IsNullOrEmpty(value)) _description = value; }  
        }                      
     
        public string StatCalculation  
        {  
            get { return ConstructStatCalulation(); }  
            set 
            {  
                if (_type == StatType.Calculation)  
                {  
                    if (!string.IsNullOrEmpty(value))  
                    {  
                        _statCalculation = value;  
                    }  
                }  
                else 
                    _statCalculation = value;  
            }  
        }  
     
        public enum DieType  
        {  
          
        d4 = 4,  
        d6 = 6,  
        d8 = 8,  
        d10 = 10,  
        d12 = 12,  
        d20 = 20,  
        d99 = 99,  
        d999 = 999,  
        MaxDie = 99,  
        HealMaxDie = 999  
          
        }  
    }  
     


    The error is as follows:(*)

    The name "DieType" does not exist in the current context.
    ---
    Expected class, delegate, enum, interface, or struct

    public *Stat*()
    public *Stat*(string name)
    public *StatType* Type
    public *string* Name
    public *string* Abbreviation
    public *string* Description
    public string StatCalculation

    Please help me out.
    Thanks,
    Trevor,

     

     

     

    Jameson III,
  • 11/20/2009 4:03 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    Search your code for "DieType".  You declared this somewhere, and the compiler doesn't know what it is.
  • 11/20/2009 5:08 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    So the DieType works fine now that I added the enum, But I still need help with the string problem.
    I'm working on it so I'll keep you posted.

    EDIT: So I placed all of the public strings in between the "public class Stat" to see what would happen.
    And it fixed the string errors. but it added several other errors. So, I am still working on it.
    Jameson III,
  • 11/20/2009 5:39 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    Aflakjuju:
    but it added several other errors.

    What errors? It would also help if you posted the code you now have. Please make sure you format it using the Format Code Block button (4th from the right on the toolbar when you're typing your post.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 11/20/2009 6:13 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    I undid it so its not there anymore. The current code is the one I first posted. Ok, Thanks. I was wondering if the posting system had this. Though I couldn't find it. Do you have any suggestions for the string errors? And so far your book is great.
    Jameson III,
  • 11/20/2009 6:57 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    It seems you need some more familiarity with C# and the .Net framework.  Without knowing what the string errors are, I can't help, but if you post them we can try to help.

    I'll also mention that you'll find help faster and keep these forums less clogged if you just try to Google the more simple error messages not related to XNA.  No doubt other people have run into them and can explain the problem and solution.
  • 11/20/2009 7:05 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    Oops. I should have googled it.
    EDIT: I googled it, and found nothing helpful.

    Wait, are all of the public strings supposed to be in the "namespace RPG" section, or the "public class Stat" section?
    The public class Stat is inside of the namespace RPG.

    Example:
    namespace RPG  
    {  
        public class Stat  
        {  
        }  

    Right now I have all of the public strings in the namespace section. Do i need to have it in the public class section?
    Am I making sense?
    Jameson III,
  • 11/20/2009 8:21 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    Answer
    Reply Quote
    Yes the strings have to be inside a class. Members have to be inside a class or struct.
  • 11/20/2009 8:40 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    ok, so sorry for being stupid.  X( . I realize that you are right, csharp1024. it worked.
    Jameson III,
  • 11/20/2009 9:33 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    Have you downloaded the source code that's available or are you just trying to go through the book?
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 11/20/2009 9:54 PM In reply to

    Re: Please Help Me With The book "RPG Programming Using XNA".

    No, I prefer to copy it from the book. It helps me learn a little bit more. So I don't have the ability to copy and paste it.
    So yes, I'm trying to get through the book.
    Jameson III,
Page 1 of 1 (11 items) Previous Next