Esempio n. 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();
 }
Esempio n. 2
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);

        }