Example #1
0
 private void doActionAction()
 {
     if (MemUnit != null && (MemUnit.getUnit().getPlayer() == game.turn.currentPlayer))
     {
         UnitAPI currunit = memUnit.getUnit();
         if (SelectedTile.getEnemy() != null)
         {
             if (currunit.canAttack(SelectedTile.getEnemy()))
             {
                 UnitAPI loser = currunit.attack(SelectedTile.getEnemy());
                 MessageBox.Show(loser.getPlayer().name + " loses the battle!");
                 if (loser.lifePoints <= 0)
                 {
                     MessageBox.Show(loser.getPlayer().name + " is dead!");
                 }
             }
             else
             {
                 MessageBox.Show("Attack action not possible");
             }
         }
         else
         {
             if (currunit.canMove(SelectedTile.X, SelectedTile.Y))
             {
                 currunit.move(SelectedTile.X, SelectedTile.Y);
             }
             else
             {
                 MessageBox.Show("Move action not possible");
             }
         }
         //Global Refresh
         memUnit.Refresh();
         updateTiles();
         this.Refresh();
     }
     else
     {
         MessageBox.Show("No unit selected");
     }
     this.isFinished();
 }
        /// <summary>
        /// Helper function to return 32 bit file size indicator in
        /// human readable form (for output as string x bytes, x Kb, x Mb, x Gb)
        /// </summary>
        /// <param name="sizeInBytes"></param>
        /// <param name="sizeString"></param>
        /// <returns></returns>
        public static double GetHumanReadableSize(ulong sizeInBytes, out MemUnit sizeString)
        {
            double dSz = 0;

            sizeString = MemUnit.bytes;

            if (sizeInBytes < 1024)
            {
                sizeString = MemUnit.bytes;
                dSz        = sizeInBytes;
            }
            else if (sizeInBytes < (1024 * 512))
            {
                sizeString = MemUnit.Kb;
                dSz        = sizeInBytes / 1024;
            }
            else // More than 1 Mb and less than 0,5 Gb ?
            if (sizeInBytes < ((1024.0 * 1024) * 512))
            {
                sizeString = MemUnit.Mb;
                dSz        = sizeInBytes / (1024.0 * 1024);
            }
            else if (sizeInBytes < ((1024.0 * 1024 * 1024) * 512))
            {
                sizeString = MemUnit.Gb;
                dSz        = sizeInBytes / (1024.0 * 1024 * 1024);
            }
            else if (sizeInBytes < ((1024.0 * 1024 * 1024 * 1024) * 512))
            {
                sizeString = MemUnit.Tb;
                dSz        = sizeInBytes / (1024.0 * 1024 * 1024 * 1024);
            }
            else
            {
                sizeString = MemUnit.Pb;
                dSz        = sizeInBytes / (1024.0 * 1024 * 1024 * 1024 * 1024);
            }

            return(dSz);
        }
Example #3
0
 public bool isOneOfMyUnitsSelected(List <UnitAPI> tileUnits)
 {
     return(tileUnits.Any(t => (hasMemUnit && (t == MemUnit.getUnit()))));
 }