/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="maze">Name of the maze</param>
		/// <param name="coordinate">Location</param>
		/// <param name="direction">Direction</param>
		/// <param name="position">Square position</param>
		public DungeonLocation(string maze, Point coordinate, CardinalPoint direction, SquarePosition position)
		{
			Maze = maze;
			Coordinate = coordinate;
			Direction = direction;
			Position = position;
		}
Example #2
0
        public SquarePosition FindMove(SuperField superField, Bot bot, int iterations)
        {
            var            bestScore    = -100000000;
            SquarePosition bestPosition = new SquarePosition(0, 0, 0, 0);

            for (int fieldY = 0; fieldY < 3; fieldY++)
            {
                for (int fieldX = 0; fieldX < 3; fieldX++)
                {
                    for (int squareY = 0; squareY < 3; squareY++)
                    {
                        for (int squareX = 0; squareX < 3; squareX++)
                        {
                            if (superFieldService.IsMovePossible(superField, fieldY, fieldX, squareY, squareX))
                            {
                                var tempSuperField = new SuperField(superField);
                                superFieldService.DoMove(tempSuperField, fieldY, fieldX, squareY, squareX);
                                var score = findScoreForBestMove(tempSuperField, bot, iterations, 1);
                                if (score >= bestScore)
                                {
                                    bestScore    = score;
                                    bestPosition = new SquarePosition(fieldY, fieldX, squareY, squareX);
                                }
                            }
                        }
                    }
                }
            }
            return(bestPosition);
        }
Example #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="maze">Name of the maze</param>
 /// <param name="coordinate">Location</param>
 /// <param name="direction">Direction</param>
 /// <param name="position">Square position</param>
 public DungeonLocation(string maze, Point coordinate, CardinalPoint direction, SquarePosition position)
 {
     Maze       = maze;
     Coordinate = coordinate;
     Direction  = direction;
     Position   = position;
 }
Example #4
0
    /// <summary>
    /// Functions creates square at given position.
    /// </summary>
    /// <param name="position"></param>
    /// <param name="squarePosition"></param>
    /// <param name="blockType"></param>
    void AddSquare(Vector3 position, SquarePosition squarePosition, BlockType blockType)
    {
        switch (squarePosition)
        {
        case SquarePosition.top:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z - .5f)));
            break;

        case SquarePosition.bottom:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z + .5f)));
            break;

        case SquarePosition.left:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z - .5f)));
            break;

        case SquarePosition.right:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z + .5f)));
            break;

        case SquarePosition.front:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z + .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z + .5f)));
            break;

        case SquarePosition.back:
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y - .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x - .5f, position.y + .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y + .5f, position.z - .5f)));
            meshVertices.Add(transform.InverseTransformPoint(new Vector3(position.x + .5f, position.y - .5f, position.z - .5f)));
            break;

        default:
            return;
        }

        Vector2 texturePositionInAtlas = new Vector2((int)blockType % (1 / textureSizeInAtlas), (int)((int)blockType * textureSizeInAtlas));        // get texture position in atlas from block type (very smart)

        TextureFace(texturePositionInAtlas);
    }
Example #5
0
        public int findScoreForBestMove(SuperField superField, Bot bot, int iterations, int step)
        {
            if (step >= iterations)
            {
                return(superFieldEvalutionService.EvaluateSuperField(superField, bot).Totaal());
            }
            else
            {
                var            isScorePositive = step % 2 == 0;
                var            bestScore       = isScorePositive ? -100000000 : 100000000;
                SquarePosition bestPosition    = new SquarePosition(0, 0, 0, 0);

                for (int fieldY = 0; fieldY < 3; fieldY++)
                {
                    for (int fieldX = 0; fieldX < 3; fieldX++)
                    {
                        for (int squareY = 0; squareY < 3; squareY++)
                        {
                            for (int squareX = 0; squareX < 3; squareX++)
                            {
                                if (superFieldService.IsMovePossible(superField, fieldY, fieldX, squareY, squareX))
                                {
                                    var tempSuperField = new SuperField(superField);
                                    superFieldService.DoMove(tempSuperField, fieldY, fieldX, squareY, squareX);
                                    var newIterations = iterations;
                                    if (!tempSuperField.TurnRestrictedToField)
                                    {
                                        newIterations--;
                                    }
                                    var score = findScoreForBestMove(tempSuperField, bot, newIterations, step + 1);
                                    if (isScorePositive && score >= bestScore || !isScorePositive && score <= bestScore)
                                    {
                                        bestScore = score;
                                    }
                                }
                            }
                        }
                    }
                }
                if (bestScore == (isScorePositive ? -100000000 : 100000000))
                {
                    return(superFieldEvalutionService.EvaluateSuperField(superField, bot).Totaal());
                }
                else
                {
                    return(bestScore);
                }
            }
        }
Example #6
0
        public Square GetContainingSquare(Cell cell, SquarePosition position)
        {
            int col = cell.Column, row = cell.Row;

            switch (position)
            {
            case SquarePosition.UpperLeft:
                break;

            case SquarePosition.LowerLeft:
                row--;
                break;

            case SquarePosition.UpperRight:
                col--;
                break;

            case SquarePosition.LowerRight:
                row--;
                col--;
                break;

            default:
                break;
            }

            if (col >= NumSquareColumns)
            {
                return(null);
            }
            else if (col < 0)
            {
                return(null);
            }
            else if (row >= NumSquareRows)
            {
                return(null);
            }
            else if (row < 0)
            {
                return(null);
            }

            return(Squares[col][row]);
        }
Example #7
0
        /// <summary>
        /// Returns indexes of a position
        /// </summary>
        /// <param name="square">Square on the board</param>
        /// <param name="position">Position inside squar</param>
        /// <param name="index1">Index</param>
        /// <param name="index2">Index</param>
        public static void GetIndexes(BoardSquare square, SquarePosition position, ref int index1, ref int index2)
        {
            index1 = -1;
            index2 = -1;

            for (int i = 0; i <= 6; i++)
            {
                for (int j = 0; j <= 6; j++)
                {
                    if (GetSquare(i, j) == square && GetPosition(i, j) == position)
                    {
                        index1 = i;
                        index2 = j;

                        return;
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Gets the entity in front the team at a given sqaure position
        /// </summary>
        /// <param name="position">Square position</param>
        /// <returns>Entity handle or null</returns>
        public Entity GetFrontEntity(SquarePosition position)
        {
            // Center position
            if (position == SquarePosition.Center)
            {
                return(null);
            }

            int[][] id = new int[][]
            {
                new int[] { 2, 2, 1, 1 },                       // From NW
                new int[] { 3, 3, 0, 0 },                       // From NE
                new int[] { 0, 0, 3, 3 },                       // From SW
                new int[] { 1, 1, 2, 2 },                       // From SE
            };

            SquarePosition pos = (SquarePosition)id[(int)position][(int)Direction];

            return(FrontSquare.GetMonster(pos));
        }
Example #9
0
        /// <summary>
        /// Help function for PossibleMoves
        /// </summary>
        /// <param name="index1">Chosen Playstone</param>
        /// <param name="index2">Chosen playstone</param>
        /// <param name="playstones">Actual board</param>
        /// <param name="pos1">Position next to the corner</param>
        /// <param name="pos2">Position next to the corner</param>
        private static void CheckCornerForMove(int index1, int index2,
            PlaystoneState[,] playstones, SquarePosition pos1, SquarePosition pos2)
        {
            BoardSquare square = ModelHelpFunctions.GetSquare(index1, index2);

            // Check fields next to this one
            CheckPositionForMove(playstones, square, pos1);
            CheckPositionForMove(playstones, square, pos2);
        }
Example #10
0
		/// <summary>
		/// Drops an item on the ground
		/// </summary>
		/// <param name="position">Position in the block</param>
		/// <param name="item">Item to drop</param>
		/// <returns>True if the item can be dropped</returns>
		public bool DropItem(SquarePosition position, Item item)
		{
			// No item in the middle of a block
			if (position == SquarePosition.Center)
				throw new ArgumentOutOfRangeException("position", "No items in the middle of a maze block !");

			// Can't drop item in wall
			if (IsWall)
				return false;

			// Actor refuses items
			if (Actor != null && !Actor.AcceptItems)
				return false;

			// Add the item to the ground
			Items[(int)position].Add(item);

			// Call the script
			OnDroppedItem(item);

			return true;
		}
Example #11
0
		/// <summary>
		/// Collects an item on the ground
		/// </summary>
		/// <param name="position">Position in the block</param>
		/// <returns>Item</returns>
		public Item CollectItem(SquarePosition position)
		{
			// No item in the middle of a block
			if (position == SquarePosition.Center)
				return null;

			int count = Items[(int)position].Count;
			if (count == 0)
				return null;

			Item item = Items[(int)position][count - 1];
			Items[(int)position].RemoveAt(count - 1);

			// Call the script
			OnCollectedItem(item);

			return item;
		}
Example #12
0
		/// <summary>
		/// Returns items on the ground at a specific corner
		/// </summary>
		/// <param name="from">Facing position</param>
		/// <param name="position">Ground position</param>
		/// <returns>List of items</returns>
		public List<Item> GetItems(CardinalPoint from, SquarePosition position)
		{
			CardinalPoint[,] tab = new CardinalPoint[,]
			{
				{CardinalPoint.North, CardinalPoint.South, CardinalPoint.West, CardinalPoint.East},
				{CardinalPoint.South, CardinalPoint.North, CardinalPoint.East, CardinalPoint.West},
				{CardinalPoint.West, CardinalPoint.East, CardinalPoint.South, CardinalPoint.North},
				{CardinalPoint.East, CardinalPoint.West, CardinalPoint.North, CardinalPoint.South},
			};

			return GetItems((SquarePosition)tab[(int)from, (int)position]);
		}
Example #13
0
		/// <summary>
		/// Returns items on the ground at a specific corner
		/// </summary>
		/// <param name="position">Ground position</param>
		/// <returns>List of items</returns>
		public List<Item> GetItems(SquarePosition position)
		{
			return Items[(int)position];
		}
Example #14
0
		/// <summary>
		/// Removes a monster
		/// </summary>
		/// <param name="position">Square position</param>
		public void RemoveMonster(SquarePosition position)
		{
			if (position == SquarePosition.Center)
				return;

			Monsters[(int)position] = null;
		}
Example #15
0
		/// <summary>
		/// Get the monster at a given location
		/// </summary>
		/// <param name="position">Location</param>
		/// <returns>Monster handle or null</returns>
		public Monster GetMonster(SquarePosition position)
		{
			// No monster here
			if (MonsterCount == 0)
				return null;

			// Only one monster, so returns this one
			else if (MonsterCount == 1)
			{
				for (int i = 0; i < 4; i++)
					if (Monsters[i] != null)
						return Monsters[i];
			}

			if (position == SquarePosition.Center)
				return null;

			return Monsters[(int)position];
		}
Example #16
0
		/// <summary>
		/// Adds a monster to the square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <param name="position">Square position</param>
		/// <returns>True on success</returns>
		public bool AddMonster(Monster monster, SquarePosition position)
		{
			return false;

			if (position == SquarePosition.Center || GetMonster(position) != null || monster == null)
				return false;

			Monsters[(int)position] = monster;

			return true;
		}
Example #17
0
        /// <summary>
        /// Help function for PossibleMoves
        /// </summary>
        /// <param name="index1">Chosen Playstone</param>
        /// <param name="index2">Chosen playstone</param>
        /// <param name="playstones">Actual board</param>
        /// <param name="pos1">Position in the corner</param>
        /// <param name="pos2">Position in the corner</param>
        private static void CheckMiddleForMove(int index1, int index2,
            PlaystoneState[,] playstones, SquarePosition pos1, SquarePosition pos2)
        {
            BoardSquare square = ModelHelpFunctions.GetSquare(index1, index2);

            // Check fields next to this one
            CheckPositionForMove(playstones, square, pos1);
            CheckPositionForMove(playstones, square, pos2);

            // Check fields in the middle
            switch (square)
            {
                case BoardSquare.OutterSquare:
                case BoardSquare.InnerSquare:
                    CheckPositionForMove(playstones, BoardSquare.MiddleSquare, ModelHelpFunctions.GetPosition(index1, index2));
                    break;
                case BoardSquare.MiddleSquare:
                    CheckPositionForMove(playstones, BoardSquare.OutterSquare, ModelHelpFunctions.GetPosition(index1, index2));
                    CheckPositionForMove(playstones, BoardSquare.InnerSquare, ModelHelpFunctions.GetPosition(index1, index2));
                    break;
            }
        }
		/// <summary>
		/// Gets a ground item display coordinate
		/// </summary>
		/// <param name="view">Block position in the view field</param>
		/// <param name="position">Ground position</param>
		/// <returns>Screen location of the item</returns>
		static public Point GetGroundPosition(ViewFieldPosition view, SquarePosition position)
		{
			return Ground[(int)view, (int)position];
		}
Example #19
0
		/// <summary>
		/// Teleport the monster to a given location
		/// </summary>
		/// <param name="target">Destination square</param>
		/// <param name="pos">Square position</param>
		public bool Teleport(Square square, SquarePosition pos)
		{
			if (square == null)
				return false;

			// Move to another square
			if (Square != square)
			{
				// Remove from previous location
				if (Square != null)
					Square.Monsters[(int)position] = null;

				Square = square;

				// Add the monster to the new square
				position = pos;
				Square.Monsters[(int)pos] = this;
			}

			// Move to a subsquare
			else
			{
				// Remove from previous position
				if (Square == null || Square.GetMonster(pos) != null)
					return false;

				Square.Monsters[(int)position] = null;

				// Move to the new position
				if (square != null)
					square.Monsters[(int)pos] = this;

				position = pos;
			}

			return true;
		}
Example #20
0
        /// <summary>
        /// Update the flying item
        /// </summary>
        /// <param name="time">Game time</param>
        /// <param name="maze">Maze where the flying item is</param>
        /// <returns>True if the blocked or false if nothing happened</rereturns>
        public bool Update(GameTime time, Maze maze)
        {
            // Item can't move any more
            if (Distance == 0)
            {
                return(true);
            }

            LastUpdate += time.ElapsedGameTime;

            if (LastUpdate > Speed)
            {
                LastUpdate -= Speed;

                // Find the next block according to the direction
                Point dst = Point.Empty;
                switch (Location.Direction)
                {
                case CardinalPoint.North:
                    dst = new Point(Location.Coordinate.X, Location.Coordinate.Y - 1);
                    break;

                case CardinalPoint.East:
                    dst = new Point(Location.Coordinate.X + 1, Location.Coordinate.Y);
                    break;

                case CardinalPoint.South:
                    dst = new Point(Location.Coordinate.X, Location.Coordinate.Y + 1);
                    break;

                case CardinalPoint.West:
                    dst = new Point(Location.Coordinate.X - 1, Location.Coordinate.Y);
                    break;
                }


                // Blocked by a wall, fall before the block
                Square square = maze.GetSquare(dst);


                // Can item pass through a door ?
                if (square.Actor != null && square.Actor is Door)
                {
                    Door door = square.Actor as Door;
                    if (!door.CanItemsPassThrough(Item))
                    {
                        Distance = 0;
                    }
                }


                // Wall is blocking
                else if (square.IsBlocking)
                {
                    Distance = 0;
                }


                // Blocked by an obstacle, but fall on the block
                if ((square.Actor != null && square.Actor.CanPassThrough) || square.MonsterCount > 0)
                {
                    Location.Coordinate = dst;

                    SquarePosition gp = Location.Position;
                    switch (Location.Direction)
                    {
                    case CardinalPoint.North:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.South:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        break;

                    case CardinalPoint.West:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        break;

                    case CardinalPoint.East:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;
                    }


                    // Get monster and hit it
                    if (square.MonsterCount > 0)
                    {
                        Monster[] monsters = maze.GetSquare(Location.Coordinate).Monsters;
                        foreach (Monster monster in monsters)
                        {
                            if (monster != null)
                            {
                                Attack attack = new Attack(Caster, monster, Item);
                                if (attack.IsAHit)
                                {
                                    Distance = 0;
                                }
                            }
                        }
                    }
                    return(true);
                }



                // Drop the item at good ground position
                if (Distance == 0)
                {
                    SquarePosition gp = Location.Position;
                    switch (Location.Direction)
                    {
                    case CardinalPoint.North:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        break;

                    case CardinalPoint.South:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.West:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.East:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        break;
                    }

                    return(true);
                }
                else
                {
                    Distance--;
                    Location.Coordinate = dst;
                }
            }

            return(false);
        }
Example #21
0
        /// <summary>
        /// Returns the ground position of a hero
        /// </summary>
        /// <param name="Hero">Hero handle</param>
        /// <returns>Ground position of the hero</returns>
        public SquarePosition GetHeroGroundPosition(Hero Hero)
        {
            SquarePosition groundpos = SquarePosition.Center;


            // Get the hero position in the team
            HeroPosition pos = GetHeroPosition(Hero);


            switch (Location.Direction)
            {
            case CardinalPoint.North:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else
                {
                    groundpos = SquarePosition.SouthEast;
                }
            }
            break;

            case CardinalPoint.East:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else
                {
                    groundpos = SquarePosition.SouthWest;
                }
            }
            break;

            case CardinalPoint.South:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else
                {
                    groundpos = SquarePosition.NorthWest;
                }
            }
            break;

            case CardinalPoint.West:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else
                {
                    groundpos = SquarePosition.NorthEast;
                }
            }
            break;
            }


            return(groundpos);
        }
Example #22
0
        /// <summary>
        /// Help function for PossibleMoves
        /// </summary>
        /// <param name="playstones">Actual board</param>
        /// <param name="square">Board square</param>
        /// <param name="pos">Position inside the square</param>
        private static void CheckPositionForMove(PlaystoneState[,] playstones, BoardSquare square,
            SquarePosition pos)
        {
            int i = 0, j = 0;

            ModelHelpFunctions.GetIndexes(square, pos, ref i, ref j);
            if (playstones[i, j] == PlaystoneState.Neutral)
                playstones[i, j] = PlaystoneState.Selectable;
        }
		/// <summary>
		/// Get the monster screen location
		/// </summary>
		/// <param name="position">ViewField position</param>
		/// <param name="sub">square position</param>
		/// <returns>Screen location</returns>
		static public Point GetMonsterLocation(ViewFieldPosition position, SquarePosition sub)
		{
			return MonsterLocations[(int)position][(int)sub];
		}
Example #24
0
		/// <summary>
		/// Definies a monster
		/// </summary>
		/// <param name="position">Square position</param>
		/// <param name="monster">Monster handle or null</param>
		void SetMonster(SquarePosition position, Monster monster)
		{
			TextBox[] boxes = new TextBox[]
			{
				NWMonsterBox,
				NEMonsterBox,
				SWMonsterBox,
				SEMonsterBox,
			};

			Button[] buttons = new Button[]
			{
				DeleteNWBox,
				DeleteNEBox,
				DeleteSWBox,
				DeleteSEBox,
			};

			// Oops ! Wrong position.
			if (position == SquarePosition.Center)
				return;

			if (monster == null)
			{
				boxes[(int) position].Text = string.Empty;
				buttons[(int) position].Enabled = false;
				if (Square != null)
					Square.Monsters[(int) position] = null;
			}
			else
			{
				boxes[(int) position].Text = monster.Name;
				buttons[(int) position].Enabled = true;
				monster.Teleport(Square);
				monster.Position = position;
			}
		}
		/// <summary>
		/// Gets a flying item coordinate
		/// </summary>
		/// <param name="view">Block position in the view field</param>
		/// <param name="ground">ground position</param>
		/// <returns>Screen location of the item</returns>
		static public Point GetFlyingItem(ViewFieldPosition view, SquarePosition ground)
		{
			return FlyingItems[(int)view, (int)ground];
		}
Example #26
0
		/// <summary>
		/// Gets the entity in front the team at a given sqaure position
		/// </summary>
		/// <param name="position">Square position</param>
		/// <returns>Entity handle or null</returns>
		public Entity GetFrontEntity(SquarePosition position)
		{
			// Center position
			if (position == SquarePosition.Center)
				return null;

			int[][] id = new int[][]
			{
				new int[]{2, 2, 1, 1},		// From NW
				new int[]{3, 3, 0, 0},		// From NE
				new int[]{0, 0, 3, 3},		// From SW
				new int[]{1, 1, 2, 2},		// From SE
			};

			SquarePosition pos = (SquarePosition)id[(int)position][(int)Direction];

			return FrontSquare.GetMonster(pos);
		}