예제 #1
0
        public bool NPCMove(INPC npc, int direction)
        {
            //TODO: Hier noch die einfügen, ob sich der NPC dort hinbewegen kann

            //NPC bewegen (genaue Distanz)
            int distance = 0;

            int[] targetCoords = npc.getPositon();

            //TODO: hier ist noch ein Bug: die Distanz ist zu hoch
            if (direction == 0)
            {
                targetCoords[1]++;
                distance = (
                    gameStatics.GameGraphicObject.getPosition(
                    tileIDs[targetCoords[0],targetCoords[1]])[1] - npc.getPixelPosition()[1]);
            }
            if (direction == 3)
            {
                targetCoords[1]--;
                distance = gameStatics.GameGraphicObject.getPosition(
                    tileIDs[targetCoords[0],targetCoords[1]])[0] + npc.getPixelPosition()[0];
            }
            if (direction == 1)
            {
                targetCoords[1]++;
                distance = gameStatics.GameGraphicObject.getPosition(
                    tileIDs[targetCoords[0],targetCoords[1]])[1] + npc.getPixelPosition()[1];
            }
            if (direction == 2)
            {
                targetCoords[1]++;
                distance = gameStatics.GameGraphicObject.getPosition(
                  tileIDs[targetCoords[0], targetCoords[1]])[0] + npc.getPixelPosition()[0];
            }

            //NPC bewegen:
            npc.move(distance, direction, moveSpeed);

            //Zurückgeben, dass der NPC bewegt wurde:
            return true;
        }