Example #1
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            lastActiveTile = activeTile;

            lblInfo1.Content = "";
            lblInfo2.Content = "";
            lblInfo3.Content = "";
            lblInfo4.Content = "";
            lblInfo5.Content = "";


            Button btn = (Button)e.OriginalSource;
            string apu = btn.Content.ToString();
            int apux = 0;
            int apuy = 0;
            int.TryParse(apu.Substring(apu.IndexOf("£x") + 2, 2), out apux);
            int.TryParse(apu.Substring((apu.IndexOf("£y") + 2), 2), out apuy);

            foreach (Tile t in map)
            {
                if (t.TileX == apux && t.TileY == apuy) activeTile = t;
            }
            refreshInfo();
        }
Example #2
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            lastActiveTile = activeTile;

            lblInfo1.Content = "";
            lblInfo2.Content = "";
            lblInfo3.Content = "";
            lblInfo4.Content = "";
            lblInfo5.Content = "";
            txtBoxArmy.Text = "";

            Button btn = (Button)e.OriginalSource;
            string apu = btn.Content.ToString();
            int apux = 0;
            int apuy = 0;
            int.TryParse(apu.Substring(apu.IndexOf("£x")+2, 2), out apux);
            int.TryParse(apu.Substring((apu.IndexOf("£y") + 2),2 ), out apuy);

            foreach (Tile t in map)
            {
                if (t.TileX == apux && t.TileY == apuy) activeTile = t;
            }

            

            /*
            if (movingArmy)
            {
                if (activeTile.Terrain.TerrainType > 0 && activeTile != lastActiveTile && lastActiveTile.TileX +1 >= activeTile.TileX && activeTile.TileX >= lastActiveTile.TileX - 1 && lastActiveTile.TileY + 1 >= activeTile.TileY && activeTile.TileY >= lastActiveTile.TileY - 1)
                {
                    if (activeTile.Army != null && activeTile.Army.PlayerID == activePlayer) //armeijoiden yhdistämienn
                    {
                        foreach (Unit u in lastActiveTile.Army.Unit)
                        {
                            activeTile.Army.AddUnit(u);
                        }
                        lastActiveTile.Army = null;
                        activeTile.Army.ArmyMovement--;
                    }
                    else if (activeTile.Army != null) //armeijalla hyökkääminen
                    {
                        lastActiveTile.Army.Attack(activeTile.Army);
                        lastActiveTile.Army.ArmyMovement--;
                        bool attackerDead = lastActiveTile.Army.CheckHP();
                        if (attackerDead)
                        {
                            lastActiveTile.Army = null;
                        }
                        if (activeTile.Army.CheckHP())
                        {
                            activeTile.Army = null;
                            if (!attackerDead)
                            {
                                activeTile.Army = lastActiveTile.Army;
                                lastActiveTile.Army = null;
                            }
                        }
                    }
                    else //armeijalla liikkuminen
                    {
                        activeTile.Army = lastActiveTile.Army;
                        lastActiveTile.Army = null;
                        activeTile.PlayerID = activePlayer;
                        activeTile.Army.ArmyMovement--;
                        if (activeTile.Construction != null) activeTile.PlayerID = activePlayer;
                        if (activeTile.City != null) activeTile.PlayerID = activePlayer;
                    }
                    
                    drawMap();
                }
                else MessageBox.Show("Illegal movement!");
             
                movingArmy = false;
            }*/



            refreshInfo();
        }