Esempio n. 1
0
        private void AttackPlayer()
        {
            bool attacking = true;

            //Scan For the Player
            if (gwinfo.IsPlayerWithinAttackRange(col, row))
            {
                GameState.SuspendEnemies(GameState.currentRoom, this);
                GameState.setBattleOn(this);
                GameState.enemyobj = this;  // Register Attacker

                //Launch indicator
                GameBattleIndicator gind = new GameBattleIndicator();
                gind.thisEnemy  = this;
                gind.thisPlayer = gwinfo.The_Player;
                gind.WakeUp();
                GameState.gmind = gind;

                //************************************
                PlayUIRightPanel.UpdateEnemyTitle(InstanceName + " Health Level");
                PlayUIRightPanel.UpdateEnemyHealthLevel(HealthLevel);
                //************************************

                while (attacking && !_pause)
                {
                    Utility.Wait(300);


                    if (gwinfo.The_Player.HealthLevel <= 0)
                    {
                        //Play health is  Zero.
                        attacking = false;
                        GameState.setBatteOff();
                        Sleep();
                    }

                    GameDataFactory.curr_gwinfo.The_Player.getHit(HitPower);  //Attack

                    //#########################
                    PlayUILeftPanel.UpdateArmourPowerLevel(
                        ((IShield)GameState.GetFirstArmourInInventory()).shieldPower);
                    PlayUIRightPanel.UpdateHealthLevel(gwinfo.The_Player.HealthLevel);
                    PlayUITopItem.UpdateHealthLevel(gwinfo.The_Player.GetHealthLevel());
                    //#########################
                }
            }
            //Scan For the Player
        }
Esempio n. 2
0
        // Main Attack Function.
        private static void HandleBattle(int col, int row, int room)
        {
            ConsoleKeyInfo keyInfo;
            bool           toProcessing = true;
            Item           weapon       = null;



            //while (!Console.KeyAvailable && GameState.isBattleOn() && toProcessing)
            while (GameState.isBattleOn() && toProcessing)
            {
                if (Console.KeyAvailable)
                {
                    keyInfo = Console.ReadKey(true);


                    switch (Char.ToUpper(keyInfo.KeyChar))
                    {
                    case 'A':

                        if (GameState.GetFirstSwordInInventory() == null)
                        {
                            PlayUIBottomItem.updateMessageBox(ConfigManager.GetStringResource(51) + "\r\n" +
                                                              ConfigManager.GetStringResource(52));
                            toProcessing = false;
                            break;
                        }


                        weapon = GameState.GetFirstSwordInInventory();
                        if (weapon is IronSword || weapon is WoodenSword)
                        {
                            ((ILivingOrganism)GameState.enemyobj).getHit(((IWeapon)weapon).hitPower);
                            //Reduce SWord Power.
                            ((IWeapon)weapon).doHit();
                            PlayUIRightPanel.UpdateEnemyHealthLevel(((ILivingOrganism)GameState.enemyobj).HealthLevel);

                            if (((ILivingOrganism)GameState.enemyobj).HealthLevel == 0)
                            {
                                //Enmey Health gone.
                                //Stop the Enemy
                                ((ILivingOrganism)GameState.enemyobj).Sleep();

                                ((GameRoom)gwinfo.GetGameRoombyNumber(GameState.currentRoom)).ItemsHashTable.Remove(GameState.enemyobj.InstanceKey);

                                if (GameState.enemyobj is Monster)
                                {
                                    ((GameRoom)gwinfo.GetGameRoombyNumber(GameState.currentRoom)).MonsterList.Remove((Monster)GameState.enemyobj);
                                    gwinfo.NumberOfMonster--;
                                }
                                else if (GameState.enemyobj is Globin)
                                {
                                    ((GameRoom)gwinfo.GetGameRoombyNumber(GameState.currentRoom)).GlobinList.Remove((Globin)GameState.enemyobj);
                                    gwinfo.NumberOfGlobin--;
                                }

                                if (GameState.enemyobj is ITakable)
                                {
                                    ((ITakable)GameState.enemyobj).Take();
                                }


                                GameState.setBatteOff();
                                GameState.LastWin = true;
                                GameState.ReleaseEnemies(GameState.currentRoom);

                                //********************************************
                                PlayUIRightPanel.UpdateEnemyTitle("");
                                PlayUIRightPanel.UpdateEnemyHealthLevel(0);
                                PlayUILeftPanel.UpdateTotalEnemyItem(
                                    ((GameRoom)gwinfo.GetGameRoombyNumber(GameState.currentRoom)).GlobinList.Count +
                                    ((GameRoom)gwinfo.GetGameRoombyNumber(GameState.currentRoom)).MonsterList.Count);
                                PlayUILeftPanel.UpdateTotalGlobinWItem(gwinfo.NumberOfGlobin);
                                PlayUILeftPanel.UpdateTotalMonsterItem(gwinfo.NumberOfMonster);
                                PlayUITopItem.UpdateHealthLevel(gwinfo.The_Player.GetHealthLevel());
                                PlayUIRightPanel.PaintLegendOption(GameState.currentRoom);


                                //*********************************************
                            }

                            if (((IWeapon)weapon).capableHit > 0)
                            {
                                PlayUILeftPanel.UpdateWeaponTypeVal(weapon.descriptions);
                                PlayUILeftPanel.UpdateWeaponrPowerLevel(
                                    Utility.getPercentageVal(((IWeapon)weapon).capableHit, 400));

                                PlayUILeftPanel.UpdateSwordItem(GameState.CountSwordInInventory());
                            }
                            else
                            {
                                GameState.RemoveSwordFromInventory();

                                PlayUILeftPanel.UpdateWeaponTypeVal("Not Found");
                                PlayUILeftPanel.UpdateWeaponrPowerLevel(0);
                                PlayUILeftPanel.UpdateSwordItem(GameState.CountSwordInInventory());
                                PlayUITopItem.UpdateWeaponType("No");
                            }
                        }
                        toProcessing = false;
                        break;

                        /*
                         * case 'Q':
                         *  //DEBUG
                         *  ScreenManager.WriteDebugLine("Quit Attack @@@@@@@@@@@@@@@@@@@@@@@@@@@@");
                         *  toProcessing = false;
                         *  GameState.setBatteOff();
                         *  //DEBUG
                         *  break;
                         */
                    }
                }
            }
        }