Example #1
0
 public void attack(Champion a_champion)
 {
     faceTile(a_champion.getTile());
     //TODO Play attack animation
     p_actionTaken = true;
     a_champion.damage(MathManager.attack(this, a_champion));
 }
Example #2
0
 public override void invokeEffect(Champion a_champion)
 {
     a_champion.damage(MathManager.randomInt(m_minDamage, m_maxDamage));
     if (m_turnsLeft-- <= 0)
     {
     }
 }
Example #3
0
        public LinkedList <Tile> getSurroundingTiles(Tile a_tile)
        {
            int[] Xcheck = MathManager.isEven(a_tile.X) ? new[] { -1, 0, 1, 1, 0, -1 } : new[] { 1, 0, 1, -1, 0, -1 };
            int[] Ycheck = MathManager.isEven(a_tile.X) ? new[] { 1, -1, 0, 1, 1, 0 } : new[] { -1, -1, 0, -1, 1, 0 };

            LinkedList <Tile> l_list = new LinkedList <Tile>();

            Tile l_tile;

            for (int i = 0; i < Xcheck.Length; i++)
            {
                for (int j = 0; j < Xcheck.Length; j++)
                {
                    if ((l_tile = getTile(a_tile, new Vector2(Xcheck[i], Ycheck[i]))) != null)
                    {
                        if (!l_list.Contains(l_tile))
                        {
                            l_list.AddLast(l_tile);
                        }
                    }
                }
            }

            return(l_list);
        }
Example #4
0
 public void faceTile(Tile a_tile)
 {
     if (a_tile.getMapPosition().X < m_currentPosition.getMapPosition().X)
     {
         if (MathManager.isEven((int)m_currentPosition.getMapPosition().X))
         {
             m_facingState = a_tile.getMapPosition().Y == m_currentPosition.getMapPosition().Y
                                         ? m_facingState = FacingState.TopLeft
                                         : m_facingState = FacingState.BottomLeft;
         }
         else
         {
             m_facingState = a_tile.getMapPosition().Y == m_currentPosition.getMapPosition().Y
                                         ? m_facingState = FacingState.BottomLeft
                                         : m_facingState = FacingState.TopLeft;
         }
     }
     else if (a_tile.getMapPosition().X > m_currentPosition.getMapPosition().X)
     {
         if (MathManager.isEven((int)m_currentPosition.getMapPosition().X))
         {
             m_facingState = a_tile.getMapPosition().Y == m_currentPosition.getMapPosition().Y
                                         ? m_facingState = FacingState.TopRight
                                         : m_facingState = FacingState.BottomRight;
         }
         else
         {
             m_facingState = a_tile.getMapPosition().Y == m_currentPosition.getMapPosition().Y
                                         ? m_facingState = FacingState.BottomRight
                                         : m_facingState = FacingState.TopRight;
         }
     }
     else
     {
         m_facingState = a_tile.getMapPosition().Y < m_currentPosition.getMapPosition().Y
                                 ? m_facingState = FacingState.Up
                                 : m_facingState = FacingState.Down;
     }
 }
Example #5
0
        public void faceObject(GameObject a_gameObject)
        {
            double l_angle = MathManager.angle(
                m_position + m_hitbox.p_dimensions / 2,
                a_gameObject.p_position + new Vector2(a_gameObject.getHitBox().X, a_gameObject.getHitBox().Y) / 2
                );

            if (l_angle > 0)
            {
                if (l_angle <= 70)
                {
                    m_facingState = FacingState.TopRight;
                }
                else if (l_angle <= 130 && l_angle > 70)
                {
                    m_facingState = FacingState.Up;
                }
                else if (l_angle <= 180 && l_angle > 130)
                {
                    m_facingState = FacingState.TopLeft;
                }
            }
            else
            {
                if (l_angle >= -70)
                {
                    m_facingState = FacingState.BottomRight;
                }
                else if (l_angle >= -130 && l_angle < -70)
                {
                    m_facingState = FacingState.Down;
                }
                else if (l_angle >= -180 && l_angle < -130)
                {
                    m_facingState = FacingState.BottomLeft;
                }
            }
        }
Example #6
0
        public Tile(Vector2 a_position, int a_height, TileMap a_tileMap) : base(a_position * new Vector2(TILE_WIDTH - 32, TILE_HEIGHT) - new Vector2(0, a_height * 40))
        {
            X         = (int)a_position.X;
            Y         = (int)a_position.Y;
            m_layer   = 0.500f - a_position.Y / 1000f;
            m_tileMap = a_tileMap;

            if (MathManager.isEven((int)a_position.X))
            {
                m_layer -= 0.0001f;
            }

            m_tileState     = TileState.Normal;
            m_color         = Color.White;
            m_heightSprites = new Sprite[a_height];
            m_height        = a_height;
            m_tileMap       = ((GameState)Game.getInstance().getCurrentState()).getTileMap();

            for (int i = 0; i < a_height; i++)
            {
                m_heightSprites[i] = new Sprite("Tiles//" + m_tileMap.getTileSet() + "mellangrej.png", 1);
            }
        }
Example #7
0
        public void load()
        {
            foreach (Sprite l_sprite in m_spriteDict.Values)
            {
                l_sprite.load();
            }

            int l_heightIndex = MathManager.randomInt(3, 7);

            for (int i = 0; i < m_width; i++)
            {
                for (int j = 0; j < m_height; j++)
                {
                    //m_tileMap[i, j] = new Tile(new Vector2(i, j), MathManager.randomInt(l_heightIndex - 3, l_heightIndex + 3));
                    m_tileMap[i, j] = new Tile(new Vector2(i, j), 1, this);
                    m_tileMap[i, j].load();
                    if (MathManager.isEven(i))
                    {
                        m_tileMap[i, j].move(new Vector2(0, 111));
                    }
                }
            }
        }
Example #8
0
 public DoTEffect(string a_name, Element a_element, int a_maxTurns, int a_minDamage, int a_maxDamage) : base(a_name, a_element)
 {
     m_turnsLeft = MathManager.randomInt(1, a_maxTurns);
     m_minDamage = a_minDamage;
     m_maxDamage = a_maxDamage;
 }
Example #9
0
        private static Stack <Tile> findPath(Tile a_startTile, Tile a_endTile)
        {
            TileMap l_tileMap = ((GameState)Game.getInstance().getCurrentState()).getTileMap();
            Dictionary <Tile, double> l_closedSet = new Dictionary <Tile, double>();
            Dictionary <Tile, double> l_openSet   = new Dictionary <Tile, double>();
            Dictionary <Tile, Tile>   l_cameFrom  = new Dictionary <Tile, Tile>();

            Tile l_neighbor;

            int[] Xcheck = new int[] { 0 };
            int[] Ycheck = new int[] { 0 };

            l_openSet.Add(a_startTile, getPathValue(a_startTile, a_endTile));
            l_cameFrom.Add(a_startTile, a_startTile);

            while (l_openSet.Count > 0)
            {
                KeyValuePair <Tile, double> l_current = l_openSet.First();

                foreach (KeyValuePair <Tile, double> l_kvPair in l_openSet)
                {
                    if (l_kvPair.Value < l_current.Value)
                    {
                        l_current = l_kvPair;
                    }
                }

                if (l_current.Key.getMapPosition() == a_endTile.getMapPosition())
                {
                    Stack <Tile> l_reconstructedPath = new Stack <Tile>();
                    l_reconstructedPath.Push(l_current.Key);
                    return(reconstructPath(l_cameFrom, l_current.Key, l_reconstructedPath));
                }

                l_openSet.Remove(l_current.Key);
                l_closedSet.Add(l_current.Key, l_current.Value);

                if (MathManager.isEven(l_current.Key.X))
                {
                    Xcheck = new[] { -1, 0, 1, 1, 0, -1 };
                    Ycheck = new[] { 1, -1, 0, 1, 1, 0 };
                }
                else
                {
                    Xcheck = new[] { 1, 0, 1, -1, 0, -1 };
                    Ycheck = new[] { -1, -1, 0, -1, 1, 0 };
                }

                for (int i = 0; i < Xcheck.Length && i < Ycheck.Length; i++)
                {
                    int l_newX = (int)l_current.Key.getMapPosition().X + Xcheck[i];
                    int l_newY = (int)l_current.Key.getMapPosition().Y + Ycheck[i];

                    l_neighbor = l_tileMap.getTile(l_newX, l_newY);

                    if (l_neighbor != null)
                    {
                        //int l_heightDifference = l_current.Key.p_height + l_neighbor.p_height;
                        if (l_closedSet.ContainsKey(l_neighbor) || l_neighbor.isObstructed())
                        {
                            continue;
                        }

                        double l_tentativeGScore = l_current.Value + getPathValue(l_neighbor, a_endTile) /* + l_heightDifference*/;

                        if (!l_openSet.ContainsKey(l_neighbor) || l_tentativeGScore < l_openSet[l_neighbor])
                        {
                            l_openSet[l_neighbor]  = l_tentativeGScore;
                            l_cameFrom[l_neighbor] = l_current.Key;
                        }
                    }
                }
            }
            return(new Stack <Tile>());
        }