Esempio n. 1
0
        public void CollisionCheckInsideCameraViewport(Camera map, GameCharacter character)
        {
            int x = (int)Math.Round(Constant.VIEWPORT_WIDTH / 2.0, 0);
            int y = (int)Math.Round(Constant.VIEWPORT_HEIGHT / 2.0, 0);

            if (map.viewPort[y - 1, x] != ' ')
            {
                character.BlockedVertically = BlockedDirection.Up;
            }

            if (map.viewPort[y + 1, x] != ' ')
            {
                character.BlockedVertically = BlockedDirection.Down;
            }

            if (map.viewPort[y, x - 1] != ' ')
            {
                character.BlockedHorizontally = BlockedDirection.Left;
            }

            if (map.viewPort[y, x + 1] != ' ')
            {
                character.BlockedHorizontally = BlockedDirection.Right;
            }
        }
Esempio n. 2
0
        public bool BattleCheckOnWorldMap(Camera map, GameCharacter character, GameCharacter enemy)
        {
            bool fight = false;
            int  x     = (int)Math.Round(Constant.VIEWPORT_WIDTH / 2.0, 0);
            int  y     = (int)Math.Round(Constant.VIEWPORT_HEIGHT / 2.0, 0);

            if (map.viewPort[y - 1, x] == enemy.MapForm ||
                map.viewPort[y + 1, x] == enemy.MapForm ||
                map.viewPort[y, x - 1] == enemy.MapForm ||
                map.viewPort[y, x + 1] == enemy.MapForm)
            {
                fight = true;
            }

            return(fight);
        }
Esempio n. 3
0
        public bool ObjectCollisionCheckOnWorldMap(Camera map, GameCharacter character, char objectChar)
        {
            bool encounter = false;

            int x = (int)Math.Round(Constant.VIEWPORT_WIDTH / 2.0, 0);
            int y = (int)Math.Round(Constant.VIEWPORT_HEIGHT / 2.0, 0);

            if (map.viewPort[y - 1, x] == objectChar ||
                map.viewPort[y + 1, x] == objectChar ||
                map.viewPort[y, x - 1] == objectChar ||
                map.viewPort[y, x + 1] == objectChar)
            {
                encounter = true;
            }

            return(encounter);
        }
Esempio n. 4
0
        public void CollisionCheckInsideBounds(CharacterObject observingObject, GameCharacter character)
        {
            //Coordinates list
            List <int> allX = new List <int>();
            List <int> allY = new List <int>();

            //Content list
            List <string> charMapList = new List <string>();

            int xB = observingObject.X;
            int yB = observingObject.Y;

            //------------- Break down observing object
            for (int i = 0; i < observingObject.Width * observingObject.Height; i++)
            {
                allX.Add(xB); xB++;
                allY.Add(yB);

                if (xB > observingObject.X + observingObject.Width - 1)
                {
                    xB = observingObject.X;
                    yB++;
                }
            }

            //Step 1: Break down observing array content into characters and put them into defined list
            for (int i = 0; i < observingObject.PhysicalForm.Length; i++)
            {
                foreach (char c in observingObject.PhysicalForm[i])
                {
                    charMapList.Add(Convert.ToString(c));
                }
            }

            //Console.SetCursorPosition(0, 0);
            //Console.Write(allX.Count + " - " + allY.Count + " - " + charMapList.Count);

            for (int i = 0; i < allY.Count; i++)
            {
                if (character.BoundaryTopX.Contains(allX[i]) && character.BoundaryTopY.Contains(allY[i]) && charMapList[i] != " ")
                {
                    //DisplayManager.WriteTextAt(Constant.GAMEPLAY_CANVAS_LIMIT_LEFT, Constant.GAMEPLAY_CANVAS_LIMIT_DOWN, $"{ observer.Name} encountered " + observingObject.Name + " at the top.");
                    character.BlockedVertically = BlockedDirection.Up;
                }
            }

            for (int i = 0; i < allY.Count; i++)
            {
                if (character.BoundaryBotX.Contains(allX[i]) && character.BoundaryBotY.Contains(allY[i]) && charMapList[i] != " ")
                {
                    //DisplayManager.WriteTextAt(Constant.GAMEPLAY_CANVAS_LIMIT_LEFT, Constant.GAMEPLAY_CANVAS_LIMIT_DOWN, $"{ observer.Name} encountered " + observingObject.Name + " below.");
                    character.BlockedVertically = BlockedDirection.Down;
                }
            }

            for (int i = 0; i < allX.Count; i++)
            {
                if (character.BoundaryLeftX.Contains(allX[i]) && character.BoundaryLeftY.Contains(allY[i]) && charMapList[i] != " ")
                {
                    //DisplayManager.WriteTextAt(Constant.GAMEPLAY_CANVAS_LIMIT_LEFT, Constant.GAMEPLAY_CANVAS_LIMIT_DOWN, $"{ observer.Name} encountered " + observingObject.Name + " on the left.");
                    character.BlockedHorizontally = BlockedDirection.Left;
                    //observingObject.AttackPermission = true;
                }
            }

            for (int i = 0; i < allX.Count; i++)
            {
                if (character.BoundaryRightX.Contains(allX[i]) && character.BoundaryRightY.Contains(allY[i]) && charMapList[i] != " ")
                {
                    //DisplayManager.WriteTextAt(Constant.GAMEPLAY_CANVAS_LIMIT_LEFT, Constant.GAMEPLAY_CANVAS_LIMIT_DOWN, $"{ observer.Name} encountered " + observingObject.Name + " on the right.");
                    character.BlockedHorizontally = BlockedDirection.Right;
                    //observingObject.AttackPermission = true;
                }
            }
        }