private void createZones()
 {
     testZone = new TestZone(50, 50);
     testCave = new TestCave(30, 20);
     testZone.getTransitionZones().Add(testCave);
     testZone.getTransitionPoints().Add(new Point(450, 350));
     testCave.getTransitionZones().Add(testZone);
     testCave.getTransitionPoints().Add(new Point(1300, 50));
 }
Exemple #2
0
        public NPC(Zone startingZone, Point startingLocation, int startingLevel)
        {
            this.startingZone = startingZone;
            this.startingLocation = startingLocation;
            this.startingLevel = startingLevel;
            currentLocation = startingLocation;
            currentZone = startingZone;
            currentLevel = startingLevel;

            yOffset = 0;
            width = 30;
            height = 30;
        }
 private int isTransition(Point start, Player player, Zone currentZone)
 {
     for (int i = 0; i < 30; i++)
     {
         for (int j = 0; j < 30; j++)
         {
             int transNum = currentZone.getTransitionMap()[player.getCurrentZoneLevel()].getTransitionMap()[start.Y + i, start.X + j];
             if (transNum != 0)
             {
                 return transNum;
             }
         }
     }
     return 0;
 }
 private int checkLeftCollision(Player player, Zone currentZone)
 {
     int i = 0;
     Point startingCollision = new Point(player.getGlobalLocation().X - player.getMoveSpeed(), player.getGlobalLocation().Y);
     for (int j = 0; j < player.getWalkingOffset(); j++)
     {
         if (currentZone.getCollisionMap()[player.getCurrentZoneLevel()].getCollisionMap()[startingCollision.Y + j, startingCollision.X] == false || currentZone.getTrafficMap()[player.getCurrentZoneLevel()].getTrafficMap()[startingCollision.Y + j, startingCollision.X] == true)
         {
             if (i < player.getMoveSpeed())
             {
                 startingCollision.X++;
                 i++;
                 j = 0;
             }
             else
             {
                 return 0;
             }
         }
     }
     return player.getMoveSpeed() - i;
 }
Exemple #5
0
 public void setCurrentZone(Zone zone)
 {
     currentZone = zone;
 }
        public void drawZone(Graphics g, Player player, Zone currentZone)
        {
            int playerDrawLocationX;
            int playerDrawLocationY;
            int zoneDrawLocationX;
            int zoneDrawLocationY;

            if (player.getGlobalLocation().X + player.getXOffset() >= 450 && player.getGlobalLocation().X + player.getXOffset() < currentZone.getWidth() - 450)
            {
                playerDrawLocationX = 450 - player.getXOffset();
                zoneDrawLocationX = -(player.getGlobalLocation().X + player.getXOffset()) + 450;
            }
            else
            {
                if (player.getGlobalLocation().X + player.getXOffset() < 450)
                {
                    playerDrawLocationX = player.getGlobalLocation().X;
                    zoneDrawLocationX = 0;
                }
                else
                {
                    playerDrawLocationX = 900 - (currentZone.getWidth() - player.getGlobalLocation().X);
                    zoneDrawLocationX = -currentZone.getWidth() + 900;
                }
            }
            if (player.getGlobalLocation().Y + player.getYOffset() >= 300 && player.getGlobalLocation().Y + player.getYOffset() < currentZone.getHeight() - 300) // add in the image height stuff
            {
                playerDrawLocationY = 300 - player.getYOffset() - player.getDrawOffsetY();
                zoneDrawLocationY = -(player.getGlobalLocation().Y + player.getYOffset()) + 300;
            }
            else
            {
                if (player.getGlobalLocation().Y + player.getYOffset() < 300)
                {
                    playerDrawLocationY = player.getGlobalLocation().Y - player.getDrawOffsetY();
                    zoneDrawLocationY = 0;
                }
                else
                {
                    playerDrawLocationY = 600 - (currentZone.getHeight() - player.getGlobalLocation().Y + player.getDrawOffsetY());
                    zoneDrawLocationY = -currentZone.getHeight() + 600;
                }
            }

            int drawWindowTopX = player.getGlobalLocation().X - playerDrawLocationX;
            int drawWindowTopY = player.getGlobalLocation().Y - playerDrawLocationY - player.getDrawOffsetY();

            for (int i = 0; i < currentZone.getLevels().Count; i++) //drawing of npcs doesn't work properly
            {
                if (player.getCurrentZoneLevel() == i)
                {
                    g.DrawImage(currentZone.getLevels()[i], new Point(zoneDrawLocationX, zoneDrawLocationY));

                    List<NPC> inFrontNPCs = new List<NPC>();
                    List<NPC> behindNPCs = new List<NPC>();

                    for (int j = 0; j < currentZone.getNPCs().Count; j++)
                    {
                        if (currentZone.getNPCs()[j].getCurrentLocation().Y > player.getGlobalLocation().Y)
                        {
                            inFrontNPCs.Add(currentZone.getNPCs()[j]);
                        }
                        else
                        {
                            behindNPCs.Add(currentZone.getNPCs()[j]);
                        }
                    }
                    drawNPCs(g, behindNPCs, drawWindowTopX, drawWindowTopY, i);
                    drawPlayer(g, player, new Point(playerDrawLocationX, playerDrawLocationY));
                    drawNPCs(g, inFrontNPCs, drawWindowTopX, drawWindowTopY, i);

                }
                else
                {
                    g.DrawImage(currentZone.getLevels()[i], new Point(zoneDrawLocationX, zoneDrawLocationY));
                    drawNPCs(g, currentZone.getNPCs(), drawWindowTopX, drawWindowTopY, i);
                }
            }

            //g.DrawLine(new Pen(Color.Black), new Point(0, 300), new Point(900, 300));
            //g.DrawLine(new Pen(Color.Black), new Point(450, 0), new Point(450, 600));
            //g.DrawLine(new Pen(Color.Blue), new Point(0, playerDrawLocationY + player.getDrawOffsetY()), new Point(900, playerDrawLocationY + player.getDrawOffsetY()));
        }