Ejemplo n.º 1
0
        private void UpdateLabitinthView(RichTextBox rtb_Labirinth)
        {
            string         line      = "";
            PointLabirinth userPoint = m_user.Location;

            for (int i = userPoint.x - 1; i <= userPoint.x + 1; i++)
            {
                for (int j = userPoint.y - 1; j <= userPoint.y + 1; j++)
                {
                    if (userPoint.x != i || userPoint.y != j)
                    {
                        IInteractable item = m_labirinth[i, j];
                        if (item != null)
                        {
                            line += m_labirinth[i, j].Symbol;
                        }
                        else
                        {
                            line += "   ";
                        }
                    }
                    else
                    {
                        line += "P";
                    }
                }

                line += "\n";
            }
            rtb_Labirinth.Text = line;
        }
Ejemplo n.º 2
0
        public override void Interact(Player user)
        {
            PointLabirinth point = user.Location;

            while (FindPoint(ref point))
            {
            }
            user.Location = point;
            m_labirinth[m_myLocation.x, m_myLocation.y] = null;
        }
Ejemplo n.º 3
0
        private IInteractable GetOrNotRandomItem(PointLabirinth point)
        {
            int i = m_rnd.Next(0, 101);

            if (i <= 30)
            {
                return(GetRandomInteractableClass(point));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 private void GenerateItemsInLabirinth()
 {
     for (int i = 0; i <= m_labirinth.GetUpperBound(0); i++)
     {
         for (int j = 0; j <= m_labirinth.GetUpperBound(1); j++)
         {
             if (m_labirinth[i, j] == null)
             {
                 PointLabirinth point = new PointLabirinth(i, j);
                 m_labirinth[i, j] = GetOrNotRandomItem(point);
             }
         }
     }
 }
Ejemplo n.º 5
0
        private bool FindPoint(ref PointLabirinth point)
        {
            Random         r           = new Random();
            int            x           = m_labirinth.GetLowerBound(0);
            int            y           = m_labirinth.GetUpperBound(1);
            PointLabirinth local_point = new PointLabirinth(r.Next(x, y), r.Next(x, y));

            if (m_labirinth[local_point.x, local_point.y] as Wall == null)
            {
                point = local_point;
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 6
0
        private static void AddWalls(StreamReader strLabirinth, ref IInteractable[,] labirinth)
        {
            string line  = "";
            int    count = 0;

            while ((line = strLabirinth.ReadLine()) != null)
            {
                for (int i = 0; i < line.Length; i++)
                {
                    char simbol = line[i];
                    if (simbol == 'w')
                    {
                        PointLabirinth point = new PointLabirinth(count, i);
                        Wall           wall  = new Wall(point, labirinth);
                        labirinth[count, i] = wall;
                    }
                }
                count++;
            }
        }
Ejemplo n.º 7
0
        protected void MoveAndInteractWithPlayer(int x, int y, Player user)
        {
            PointLabirinth newPoint = user.Location;

            newPoint.x += x;
            newPoint.y += y;
            if (newPoint.x > m_labirinth.GetUpperBound(0) || newPoint.x < m_labirinth.GetLowerBound(0) ||
                newPoint.y > m_labirinth.GetUpperBound(1) || newPoint.y < m_labirinth.GetLowerBound(1))
            {
                return;
            }

            IInteractable l = m_labirinth[newPoint.x, newPoint.y];

            if (l != null)
            {
                l.Interact(user);
            }
            if (l == null)
            {
                user.Location = newPoint;
            }
        }
Ejemplo n.º 8
0
        private IInteractable GetRandomInteractableClass(PointLabirinth point)
        {
            int           i   = m_rnd.Next(0, 8);
            IInteractable obj = null;

            if (i == 1)
            {
                obj = new Teleport(point, m_labirinth);
            }
            if (i == 2)
            {
                obj = new Undead(point, m_labirinth);
            }
            if (i == 3)
            {
                obj = new Bandit(point, m_labirinth);
            }
            if (i == 4)
            {
                obj = new Hill(point, m_labirinth);
            }
            if (i == 5)
            {
                obj = new Grave(point, m_labirinth);
            }
            if (i == 6)
            {
                obj = new God(point, m_labirinth);
            }
            if (i == 7)
            {
                obj = new Friend(point, m_labirinth);
            }

            return(obj);
        }
Ejemplo n.º 9
0
 protected Item(PointLabirinth newLocation)
 {
     m_myLocation = newLocation;
 }
Ejemplo n.º 10
0
 public Friend(PointLabirinth newLocation, IInteractable[,] labirinth) : base(newLocation)
 {
     m_labirinth = labirinth;
 }
Ejemplo n.º 11
0
 public Teleport(PointLabirinth newLocation, IInteractable[,] labirinth) : base(newLocation)
 {
     m_labirinth = labirinth;
 }