Author Topic: [Help]C# Accessibility Domain(I think that's what it's called.)  (Read 4458 times)

0 Members and 1 Guest are viewing this topic.

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
[Help]C# Accessibility Domain(I think that's what it's called.)
« on: February 26, 2013, 04:47:01 pm »
Sorry to bother you again. I know I post here quite a lot for help. I have tried googling it.

Any way I need help changing the Accessibility Domain(?). Normally I declared all the variables at the top but this time I must declare an array in a method.

Thanks in advance and sorry to bother you again.

Offline Scipi

  • Omni Kitten Meow~ =^ω^=
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1547
  • Rating: +192/-3
  • Meow :3
    • View Profile
    • ScipiSoftware
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #1 on: February 26, 2013, 05:06:36 pm »
What are you trying to do, exactly? It looks like Accessibility Domain is more related to Access Modifiers in classes.

For instance, you had a private internal class

Code: [Select]
public class MyClass{

    public static int foo = 0;

    static MyClass(){
        MyInnerClass.bar = 0;
    }

    private class MyInnerClass{
        public static int bar;
    }
}

MyClass.MyInnerClass.foo would be inaccessible since MyInnerClass is private.

So this doesn't seem too related to your problem.

Imma Cat! =^_^= :3 (It's an emoticon now!)
Spoiler For Things I find interesting:
Spoiler For AI Programming:
Spoiler For Shameless advertising:

Spoiler For OldSig:





Spoiler For IMPORTANT NEWS!:
Late last night, Quebec was invaded by a group calling themselves, "Omnimaga". Not much is known about these mysterious people except that they all carried calculators of some kind and they all seemed to converge on one house in particular. Experts estimate that the combined power of their fabled calculators is greater than all the worlds super computers put together. The group seems to be holding out in the home of a certain DJ_O, who the Omnimagians claim to be their founder. Such power has put the world at a standstill with everyone waiting to see what the Omnimagians will do...

Wait... This just in, the Omnimagians have sent the UN a list of demands that must be met or else the world will be "submitted to the wrath of Netham45's Lobster Army". Such demands include >9001 crates of peanuts, sacrificial blue lobsters, and a wide assortment of cherry flavored items. With such computing power stored in the hands of such people, we can only hope these demands are met.

In the wake of these events, we can only ask, Why? Why do these people make these demands, what caused them to gather, and what are their future plans...

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #2 on: February 26, 2013, 05:41:36 pm »
Code: [Select]
public void DetectNPC()
{
    [...](Other code in method)
    Vector2[] PhilCharNPCHitVectors = new Vector2[ArrayLength];
    float[] NPCHitXCoord = new float[ArrayLength];
    float[] NPCHitYCoord = new float[ArrayLength];                   
    [...]
}

private void UpdateInput()
 {
            OldState = KeyState;
            KeyState = Keyboard.GetState();
            if (KeyState.IsKeyDown(Keys.S) && themap.HitMap[Convert.ToInt32(YCoord) + 1].Substring(Convert.ToInt32(XCoord) * 2, 2) == "..")
            {
                YCoord = YCoord + 1;
            }
            if (KeyState.IsKeyDown(Keys.W) && themap.HitMap[Convert.ToInt32(YCoord) - 1].Substring(Convert.ToInt32(XCoord) * 2, 2) == "..")
            {
                YCoord = YCoord - 1;
            }
            if (KeyState.IsKeyDown(Keys.D) && themap.HitMap[Convert.ToInt32(YCoord)].Substring((Convert.ToInt32(XCoord) * 2) + 1, 2) == "..")
            {
                XCoord = XCoord + 1;
            }
            if (KeyState.IsKeyDown(Keys.A) && themap.HitMap[Convert.ToInt32(YCoord)].Substring((Convert.ToInt32(XCoord) * 2) - 1, 2) == "..")
            {
                XCoord = XCoord - 1;
            }
            NextMap();
}

So I need to access the arrays from DetectNPC in UpdateInput. The arrays must be declared in the DetectNPC. Passing is not an option as UpdateInput is not called in DetectNPC.

Offline Scipi

  • Omni Kitten Meow~ =^ω^=
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1547
  • Rating: +192/-3
  • Meow :3
    • View Profile
    • ScipiSoftware
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #3 on: February 26, 2013, 05:51:44 pm »
You should try defining them outside DetectNPC() and make sure both methods are within the same class. That way, they are accessible by both methods.

The problem here is that the arrays are out of scope. That is, they are only defined within DetectNPC(). When you leave DetectNPC() via return, those arrays are cleared off the stack. You should either make them global variables, or members of a class that contains both methods.

Imma Cat! =^_^= :3 (It's an emoticon now!)
Spoiler For Things I find interesting:
Spoiler For AI Programming:
Spoiler For Shameless advertising:

Spoiler For OldSig:





Spoiler For IMPORTANT NEWS!:
Late last night, Quebec was invaded by a group calling themselves, "Omnimaga". Not much is known about these mysterious people except that they all carried calculators of some kind and they all seemed to converge on one house in particular. Experts estimate that the combined power of their fabled calculators is greater than all the worlds super computers put together. The group seems to be holding out in the home of a certain DJ_O, who the Omnimagians claim to be their founder. Such power has put the world at a standstill with everyone waiting to see what the Omnimagians will do...

Wait... This just in, the Omnimagians have sent the UN a list of demands that must be met or else the world will be "submitted to the wrath of Netham45's Lobster Army". Such demands include >9001 crates of peanuts, sacrificial blue lobsters, and a wide assortment of cherry flavored items. With such computing power stored in the hands of such people, we can only hope these demands are met.

In the wake of these events, we can only ask, Why? Why do these people make these demands, what caused them to gather, and what are their future plans...

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #4 on: February 27, 2013, 12:11:44 pm »
I was planning on that but, I have to delete the array every time DetectNPC runs as it is supposed to change size every time.

Edit:
The problem here is that the arrays are out of scope. That is, they are only defined within DetectNPC(). When you leave DetectNPC() via return, those arrays are cleared off the stack. You should either make them global variables, or members of a class that contains both methods.

That's what I am trying to change, I want to have the array in scope while still declaring it in the method. Any way of doing this?

Oops double post edited into one post.
« Last Edit: February 27, 2013, 12:14:30 pm by Augs »

Offline Scipi

  • Omni Kitten Meow~ =^ω^=
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1547
  • Rating: +192/-3
  • Meow :3
    • View Profile
    • ScipiSoftware
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #5 on: February 27, 2013, 02:23:15 pm »
I don't think there would be any way, you would have to delete or overwrite the arrays each time, unless there's a container you would use like a Vector that you can change the size of dynamically.

Imma Cat! =^_^= :3 (It's an emoticon now!)
Spoiler For Things I find interesting:
Spoiler For AI Programming:
Spoiler For Shameless advertising:

Spoiler For OldSig:





Spoiler For IMPORTANT NEWS!:
Late last night, Quebec was invaded by a group calling themselves, "Omnimaga". Not much is known about these mysterious people except that they all carried calculators of some kind and they all seemed to converge on one house in particular. Experts estimate that the combined power of their fabled calculators is greater than all the worlds super computers put together. The group seems to be holding out in the home of a certain DJ_O, who the Omnimagians claim to be their founder. Such power has put the world at a standstill with everyone waiting to see what the Omnimagians will do...

Wait... This just in, the Omnimagians have sent the UN a list of demands that must be met or else the world will be "submitted to the wrath of Netham45's Lobster Army". Such demands include >9001 crates of peanuts, sacrificial blue lobsters, and a wide assortment of cherry flavored items. With such computing power stored in the hands of such people, we can only hope these demands are met.

In the wake of these events, we can only ask, Why? Why do these people make these demands, what caused them to gather, and what are their future plans...

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: [Help]C# Accessibility Domain(I think that's what it's called.)
« Reply #6 on: March 07, 2013, 05:00:13 pm »
Problem solved. I used lists.