Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Storm8 AutoHealer Pin
Dave Kreskowiak12-Jan-15 4:23
mveDave Kreskowiak12-Jan-15 4:23 
AnswerRe: Storm8 AutoHealer Pin
Pete O'Hanlon11-Jan-15 21:31
mvePete O'Hanlon11-Jan-15 21:31 
QuestionMoving objects around 2D array in threads Pin
Member 1136734811-Jan-15 10:17
Member 1136734811-Jan-15 10:17 
AnswerRe: Moving objects around 2D array in threads Pin
Richard Andrew x6411-Jan-15 12:23
professionalRichard Andrew x6411-Jan-15 12:23 
GeneralRe: Moving objects around 2D array in threads Pin
Member 1136734811-Jan-15 14:57
Member 1136734811-Jan-15 14:57 
GeneralRe: Moving objects around 2D array in threads Pin
SledgeHammer0111-Jan-15 15:04
SledgeHammer0111-Jan-15 15:04 
GeneralRe: Moving objects around 2D array in threads Pin
Member 1136734811-Jan-15 17:50
Member 1136734811-Jan-15 17:50 
AnswerRe: Moving objects around 2D array in threads Pin
Member 1136734813-Jan-15 11:02
Member 1136734813-Jan-15 11:02 
It turns out this whole thing was just a bug in my code when placing new animal on the field. I have it working now. If an animal reproduces it passes the new object back to the field and starts a new thread successfully. The two Field methods now look like this...

C#
public void run()
{
    //the threads have been restarted to accoutn for newborns
    this.RestartThreads = false;
    //iterate through actors on field and start their threads

    //add the newborns from a temp list
    //to the ActoreOnField List and execute the run method

    foreach (IActor actor in actorsOnField)
    {
        Thread t = new Thread(delegate() { move(actor); });
        t.Start();
        RunningThreads.Add(t);
    }
}

public void move(IActor actor)
{
    while (RestartThreads == false)
    {
        int rand = RandomNumber.GetRandomNumber(1000, 2000);
        Thread.Sleep(rand);

        if (!isPaused)
        {
            lock (_grid)
            {
                IActor player = actor.move(this);

                if (player != null)
                {
                    Thread t = new Thread(delegate() { move(player); });
                    t.Start();
                }
            }
        }
    }
}


Thanks.
Questionhow about this book? Pin
kidult10-Jan-15 22:52
kidult10-Jan-15 22:52 
AnswerRe: how about this book? Pin
OriginalGriff10-Jan-15 22:59
mveOriginalGriff10-Jan-15 22:59 
GeneralRe: how about this book? Pin
kidult11-Jan-15 0:42
kidult11-Jan-15 0:42 
GeneralRe: how about this book? Pin
OriginalGriff11-Jan-15 0:46
mveOriginalGriff11-Jan-15 0:46 
GeneralRe: how about this book? Pin
kidult11-Jan-15 1:58
kidult11-Jan-15 1:58 
GeneralRe: how about this book? Pin
OriginalGriff11-Jan-15 2:33
mveOriginalGriff11-Jan-15 2:33 
GeneralRe: how about this book? Pin
Santosh K. Tripathi12-Jan-15 17:24
professionalSantosh K. Tripathi12-Jan-15 17:24 
GeneralRe: how about this book? Pin
kidult15-Jan-15 14:28
kidult15-Jan-15 14:28 
GeneralRe: how about this book? Pin
blachsmith16-Jan-15 15:48
blachsmith16-Jan-15 15:48 
GeneralRe: how about this book? Pin
OriginalGriff16-Jan-15 22:06
mveOriginalGriff16-Jan-15 22:06 
AnswerRe: how about this book? Pin
Kornfeld Eliyahu Peter10-Jan-15 23:00
professionalKornfeld Eliyahu Peter10-Jan-15 23:00 
GeneralRe: how about this book? Pin
kidult11-Jan-15 0:43
kidult11-Jan-15 0:43 
AnswerRe: how about this book? Pin
OriginalGriff10-Jan-15 23:00
mveOriginalGriff10-Jan-15 23:00 
GeneralRe: how about this book? Pin
kidult11-Jan-15 0:43
kidult11-Jan-15 0:43 
AnswerRe: how about this book? Pin
BillWoodruff11-Jan-15 5:13
professionalBillWoodruff11-Jan-15 5:13 
GeneralRe: how about this book? Pin
kidult15-Jan-15 14:35
kidult15-Jan-15 14:35 
GeneralShockwave flash object Pin
Member 1136607910-Jan-15 21:01
Member 1136607910-Jan-15 21:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.