Ejemplo n.º 1
0
        public void Draw()
        {
            string displayBuffer = "";

            for (int y = 0; y < gridHeight; y++)
            {
                displayBuffer = "";
                for (int x = 0; x < gridWidth; x++)
                {
                    Gameobjekt current = displayAr[x, y];
                    if (current == null)
                    {
                        current = new Gameobjekt();
                    }
                    if (current.isDrawn)
                    {
                        displayBuffer += current.symbole;
                    }
                    else
                    {
                        displayBuffer += "  ";
                    }
                }
                Console.WriteLine(displayBuffer);
            }
        }
Ejemplo n.º 2
0
 public static bool CheckForObjInWorld(Pos2D position, out Gameobjekt gameobjekt)
 {
     if (GoThroughAllObj(Game.gameObjList, position, out gameobjekt))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        bool CheckIfInside(Gameobjekt gameobjekt)
        {
            int x = gameobjekt.position.x;
            int y = gameobjekt.position.y;

            if (x >= 0 && x < gridWidth)
            {
                if (y >= 0 && y < gridHeight)
                {
                    return(true);
                }
                return(false);
            }
            return(false);
        }
Ejemplo n.º 4
0
 public void AddObj(Gameobjekt gameobjekt)
 {
     //Dev.Dis(changedPoints);
     //Dev.Dis(changedPoints.Count);
     if (!gameobjekt.isDrawn)
     {
         return;
     }
     if (!CheckIfInside(gameobjekt))
     {
         return;
     }
     if (changedPoints.Count == 0)
     {
         displayAr[gameobjekt.position.x, gameobjekt.position.y] = gameobjekt;
         changedPoints.Add(gameobjekt.position);
         //Dev.Dis(gameobjekt.position);
         return;
     }
     else
     {
         foreach (Pos2D item in changedPoints)
         {
             if (gameobjekt.position.x == item.x && gameobjekt.position.y == item.y)
             {
                 if (gameobjekt.zIndex > displayAr[item.x, item.y].zIndex)
                 {
                     displayAr[item.x, item.y] = gameobjekt;
                     return;
                 }
                 else
                 {
                     return;
                 }
             }
         }
         displayAr[gameobjekt.position.x, gameobjekt.position.y] = gameobjekt;
         changedPoints.Add(gameobjekt.position);
         return;
     }
 }
Ejemplo n.º 5
0
 private static bool GoThroughAllObj(List <Gameobjekt> gameobjekts, Pos2D position, out Gameobjekt gameobjektHit)
 {
     //gameobjektHit = new Gameobjekt();
     Dev.Dis(gameobjekts.Count());
     foreach (Gameobjekt item in gameobjekts)
     {
         if (item.position.Equals(position))
         {
             gameobjektHit = item;
             return(true);
         }
     }
     gameobjektHit = null;
     return(false);
 }