Example #1
0
      public void GetMyFOV()
      {
          FOVCalc.player.Y = creature.currentpossition.X;
          FOVCalc.player.X = creature.currentpossition.Y;



          for (int j = 0; j < tab.GetLength(0); j++)
          {
              for (int i = 0; i < tab.GetLength(1); i++)
              {
                  if (!(tab[j, i].transluscent))
                  {
                      //	Console.Write("{0} , {1} is not transluscent", i, j);
                      FOVCalc.Point_Set(i, j, 1);
                  }
                  else
                  {
                      FOVCalc.Point_Set(i, j, 0);
                  }
                  // Console.WriteLine();
              }
          }
          FOVCalc.VisualRange = creature.attributes.visualrange;
          FOVCalc.GetVisibleCells();
      }
        public void DrawFOV(Pole[,] tab, int pX, int pY, byte sightRange)
        {
            var FOVCalc = new FOVRecurse();

            FOVCalc.player.Y    = pX;
            FOVCalc.player.X    = pY;
            FOVCalc.VisualRange = sightRange;


            for (int j = 0; j < tab.GetLength(0); j++)
            {
                for (int i = 0; i < tab.GetLength(1); i++)
                {
                    if (!(tab[j, i].transluscent))
                    {
                        //	Console.Write("{0} , {1} is not transluscent", i, j);
                        FOVCalc.Point_Set(i, j, 1);
                    }
                    else
                    {
                        FOVCalc.Point_Set(i, j, 0);
                    }
                    // Console.WriteLine();
                }
            }

            FOVCalc.GetVisibleCells();

            for (int j = 0; j < tab.GetLength(1); j++)
            {
                for (int i = 0; i < tab.GetLength(0); i++)
                {
                    Point xy = new Point();
                    xy.X = j;
                    xy.Y = i;
                    Console.ForegroundColor = tab[i, j].colour;
                    if (tab[i, j].mapEntities.name != "item_null")
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                    }
                    if (FOVCalc.VisiblePoints.Contains(xy))
                    {
                        tab[i, j].isExplored = true;
                        if (tab[i, j].Creature.Count != 0)
                        {
                            Console.Write("{0}", tab[i, j].Creature[tab[i, j].Creature.Count - 1].type);
                        }
                        else if (tab[i, j].mapEntities.name != "item_null")
                        {
                            Console.Write("{0}", tab[i, j].mapEntities.type);
                        }
                        else if (tab[i, j].Items.Count != 0)
                        {
                            Console.Write("{0}", tab[i, j].Items[tab[i, j].Items.Count - 1].type);
                        }
                        else
                        {
                            Console.Write("{0}", tab[i, j].type);
                        }
                    }
                    else if (tab[i, j].isExplored)
                    {
                        Console.ForegroundColor = ConsoleColor.Black;
                        if (tab[i, j].Creature.Count != 0)
                        {
                            Console.Write("{0}", tab[i, j].Creature[tab[i, j].Creature.Count - 1].type);
                        }
                        else if (tab[i, j].mapEntities.name != "item_null")
                        {
                            Console.Write("{0}", tab[i, j].mapEntities.type);
                        }
                        else if (tab[i, j].Items.Count != 0)
                        {
                            Console.Write("{0}", tab[i, j].Items[tab[i, j].Items.Count - 1].type);
                        }
                        else
                        {
                            Console.Write("{0}", tab[i, j].type);
                        }
                    }
                    else
                    {
                        Console.Write("#");
                    }
                }
                Console.WriteLine();
            }
        }