コード例 #1
0
ファイル: RunGame.cs プロジェクト: Dibega/Labyrinth
        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;
        }
コード例 #2
0
ファイル: Teleport.cs プロジェクト: Dibega/Labyrinth
        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;
        }
コード例 #3
0
ファイル: RunGame.cs プロジェクト: Dibega/Labyrinth
        private IInteractable GetOrNotRandomItem(PointLabirinth point)
        {
            int i = m_rnd.Next(0, 101);

            if (i <= 30)
            {
                return(GetRandomInteractableClass(point));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: RunGame.cs プロジェクト: Dibega/Labyrinth
 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);
             }
         }
     }
 }
コード例 #5
0
ファイル: Teleport.cs プロジェクト: Dibega/Labyrinth
        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);
            }
        }
コード例 #6
0
ファイル: RunGame.cs プロジェクト: Dibega/Labyrinth
        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++;
            }
        }
コード例 #7
0
ファイル: ControlStyleMove.cs プロジェクト: Dibega/Labyrinth
        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;
            }
        }
コード例 #8
0
ファイル: RunGame.cs プロジェクト: Dibega/Labyrinth
        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);
        }
コード例 #9
0
 protected Item(PointLabirinth newLocation)
 {
     m_myLocation = newLocation;
 }
コード例 #10
0
ファイル: Friend.cs プロジェクト: Dibega/Labyrinth
 public Friend(PointLabirinth newLocation, IInteractable[,] labirinth) : base(newLocation)
 {
     m_labirinth = labirinth;
 }
コード例 #11
0
ファイル: Teleport.cs プロジェクト: Dibega/Labyrinth
 public Teleport(PointLabirinth newLocation, IInteractable[,] labirinth) : base(newLocation)
 {
     m_labirinth = labirinth;
 }