示例#1
0
 public static void drawInCircleFOV(int centerx, int centery, int radius)
 { // will draw in "fair" circle with vision ray tracing
     Console.SetCursorPosition(0, 0);
     for (int j = 0; j < Program.mapHeight; j++)
     {
         for (int i = 0; i < Program.mapWidth; i++)
         {
             //Console.SetCursorPosition(i, j);
             int xdiff = centerx - i;
             int ydiff = centery - j;
             if (xdiff * xdiff + ydiff * ydiff <= radius * radius && WorldLOS.VisibleLineExist(centerx, centery, i, j))
             {
                 Console.ForegroundColor = World.map[i, j].Color;
                 Console.Write(World.map[i, j].Appearance);
                 World.map[i, j].WasSeen = true;
                 continue;
             }
             else
             {
                 if (World.map[i, j].WasSeen)
                 {
                     Console.ForegroundColor = ConsoleColor.DarkGray;
                     Console.Write(World.map[i, j].Appearance);
                     continue;
                 }
                 if (!World.map[i, j].WasSeen)
                 {
                     Console.Write(' ');
                     continue;
                 }
             }
         }
     }
 }
示例#2
0
        static void placeActors()
        {
            int plx, ply;

            plx = player.CoordX;
            ply = player.CoordY;
            int x, y;

            for (int i = 0; i < 7; i++)
            {
                do
                {
                    x = MyRandom.getRandomInt(mapWidth);
                    y = MyRandom.getRandomInt(mapHeight);
                    if (map[x, y].IsPassable && !WorldLOS.VisibleLineExist(x, y, plx, ply))
                    {
                        AllActors.Add(UnitCreator.createActor("Guard", x, y));
                    }
                } while (!map[x, y].IsPassable);
            }
            for (int i = 0; i < 3; i++)
            {
                do
                {
                    x = MyRandom.getRandomInt(mapWidth);
                    y = MyRandom.getRandomInt(mapHeight);
                    if (map[x, y].IsPassable && !WorldLOS.VisibleLineExist(x, y, plx, ply))
                    {
                        AllActors.Add(UnitCreator.createActor("Officer", x, y));
                    }
                } while (!map[x, y].IsPassable);
            }
        }
示例#3
0
        public static void drawItemsInCircle(int x, int y, int radius)
        {
            int dx, dy;

            foreach (Item currItem in World.AllItemsOnFloor)
            {
                dx = currItem.CoordX - x;
                dy = currItem.CoordY - y;
                if (dx * dx + dy * dy > radius * radius)
                {
                    continue;
                }
                if (WorldLOS.VisibleLineExist(x, y, currItem.CoordX, currItem.CoordY))
                {
                    currItem.Draw();
                }
            }
        }
示例#4
0
        public static void drawUnitsInCircle(int x, int y, int radius)
        {
            int dx, dy;

            foreach (Actor currActor in World.AllActors)
            {
                dx = currActor.CoordX - x;
                dy = currActor.CoordY - y;
                if (dx * dx + dy * dy > radius * radius)
                {
                    continue;
                }
                if (WorldLOS.VisibleLineExist(x, y, currActor.CoordX, currActor.CoordY))
                {
                    currActor.Draw();
                }
            }
        }
示例#5
0
        void shootDialogue()
        {
            if (Inv.Wielded.Range == 1)
            {
                Log.AddLine("You can't shoot with the " + Inv.Wielded.DisplayName + "!");
                return;
            }
            Log.AddLine("Which target? (tab - next, f - fire, esc - cancel)");
            bool nextTargetPlease = true;

            while (nextTargetPlease)
            {
                nextTargetPlease = false;
                foreach (Actor currTarget in World.AllActors)
                {
                    if (WorldLOS.VisibleLineExist(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY))
                    {
                        WorldRendering.drawInCircleFOV(CoordX, CoordY, visibilityRadius);
                        WorldRendering.drawUnitsInCircle(CoordX, CoordY, visibilityRadius);
                        this.Draw();
                        currTarget.DrawHighlighted();
                        Console.ForegroundColor = ConsoleColor.Red;
                        WorldRendering.DrawLineNotInclusive(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY, '*');
                        ConsoleKeyInfo keyPressed = Console.ReadKey(true);
                        if (keyPressed.Key == ConsoleKey.Tab)
                        {
                            nextTargetPlease = true;
                            continue;
                        }
                        if (keyPressed.Key == ConsoleKey.Escape)
                        {
                            Log.AddOneFromList(StringFactory.CancelStrings());
                            return;
                        }
                        if (keyPressed.Key == ConsoleKey.F)
                        {
                            Attack.RangedAttack(this, currTarget);
                            return;
                        }
                    }
                }
            }
            Log.ReplaceLastLine("No targets in range!");
        }
示例#6
0
        bool ActorSeesTheTarget()  //do we see the player?
        {
            Target = World.player;
            int targetX, targetY;

            targetX = Target.CoordX;
            targetY = Target.CoordY;
            int    vectorX  = Target.CoordX - CoordX;
            int    vectorY  = Target.CoordY - CoordY;
            double distance = Math.Sqrt(vectorX * vectorX + vectorY * vectorY);

            if (distance <= visibilityRadius)
            {
                if (ViewSector.PointIsInSector(CoordX, CoordY, targetX, targetY, lookX, lookY, ViewAngle))
                {
                    if (WorldLOS.VisibleLineExist(CoordX, CoordY, targetX, targetY))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }