Beispiel #1
0
     void Combat(NPC npc1)
     {
     int f=0;
     NPC npc2=new NPC("11", 200, 1, 1, 1, 1);
     if(npc1.getX()!=0)
         if(maze[npc1.getX()-1,npc1.getY()]==2) npc2=SearchXY(npc1.getX()-1,npc1.getY());
     if(npc1.getX()!=MZ-1)
         if(maze[npc1.getX()+1,npc1.getY()]==2) npc2=SearchXY(npc1.getX()+1,npc1.getY());
     if(npc1.getY()!=0)
         if(maze[npc1.getX(),npc1.getY()-1]==2) npc2=SearchXY(npc1.getX(),npc1.getY()-1);
     if(npc1.getY()!=MZ-1)
         if(maze[npc1.getX(),npc1.getY()+1]==2) npc2=SearchXY(npc1.getX(),npc1.getY()+1);
     
     if(npc1.Status()==0 && npc2.Status()==0 && npc2.getHp()!=200)
     {
        
        {
            npc1.wound(npc2.shoot());
            npc2.wound(npc1.shoot());
        }
     }
     if (npc1.getHp()==0) {enemys.Remove(npc1);maze[npc1.getX(),npc1.getY()]=0;}
     if (npc2.getHp() == 0) { enemys.Remove(npc2); maze[npc2.getX(), npc2.getY()] = 0; }
     Paint();
 }
Beispiel #2
0
        void Step(NPC npc, int st)
        {
            int side;
            if (st == -1) side = r.Next(3);
            else side = st;
            int oldx = npc.getX();
            int oldy = npc.getY();
            int x = 0, y = 0;
            if (!((oldx == 0 && side == 0) || (oldx == MZ && side == 2) || (oldy == 0 && side == 1) || (oldy == MZ && side == 3)))
            {
                switch (side)
                {
                    case 0: { x = oldx - 1; y = oldy; } break;
                    case 3: { x = oldx; y = oldy + 1; } break;
                    case 2: { x = oldx + 1; y = oldy; } break;
                    case 1: { x = oldx; y = oldy - 1; } break;
                }
                if (maze[x,y] == 0)
                { npc.setPosition(x, y); maze[oldx,oldy] = 0; maze[x,y] = 2; }
                else
                    if (maze[x,y] == 3 || maze[x,y] == 4)
                    {
                        for (int i = 0; i < subj.Count; i++)
                            if (subj[i].getX() == x && subj[i].getY() == y)
                            {
                                if (subj[i].getAmount() == 12) npc.upAmmo(subj[i].getAmount());
                                else npc.heal(subj[i].getAmount());
                                break;
                            }
                        npc.setPosition(x, y);
                        maze[oldx,oldy] = 0;
                        maze[x,y] = 2;
                    }
                Combat(npc);
            }

        }
Beispiel #3
0
        void Contact(NPC npc)
        {
            int x = npc.getX(), y = npc.getY(), f = 0;

            for (int i = 0; i < npc.Radius() || f == 0; i++)
            {
                if (x - i == 0) break;
                if (maze[x - i,y] == 1) break;
                if (maze[x - i,y] == 3 || maze[x - i,y] == 4) { Step(npc, 0); f = 1; }
                if (maze[x - i,y] == 2)
                {
                    if (npc.getHp() > 10)
                        Combat(npc);
                    else Step(npc, 2);
                    f = 1;
                }
            }
            for (int i = 0; i < npc.Radius() || f == 0; i++)
            {
                if (x + i == MZ - 1) break;
                if (maze[x + i,y] == 1) break;
                if (maze[x + i,y] == 3 || maze[x + i,y] == 4) { Step(npc, 2); f = 1; }
                if (maze[x + i,y] == 2)
                {
                    if (npc.getHp() > 10)
                        Combat(npc);
                    else Step(npc, 0);
                    f = 1;
                }
            }
            for (int i = 0; i < npc.Radius() || f == 0; i++)
            {
                if (y - i == 0) break;
                if (maze[x,y - i] == 1) break;
                if (maze[x,y - i] == 3 || maze[x,y - i] == 4) { Step(npc, 1); f = 1; }
                if (maze[x,y - i] == 2)
                {
                    if (npc.getHp() > 10)
                        Combat(npc);
                    else Step(npc, 3);
                    f = 1;
                }
            }
            for (int i = 0; i < npc.Radius() || f == 0; i++)
            {
                if (y + i == MZ - 1) break;
                if (maze[x,y + i] == 1) break;
                if (maze[x,y + i] == 3 || maze[x,y + i] == 4) { Step(npc, 3); f = 1; }
                if (maze[x,y + i] == 2)
                {
                    if (npc.getHp() > 10)
                        Combat(npc);
                    else Step(npc, 1);
                    f = 1;
                }
            }
            if (f == 0) Step(npc, -1);

        }