Пример #1
0
/*!
 * \copydoc MythUIType::Reset()
 */
void MythUIStateType::Reset()
{
    if (!DisplayState("default"))
    {
        if (!DisplayState(None))
        {
            if (m_CurrentState)
                m_CurrentState->SetVisible(false);

            m_CurrentState = NULL;
        }
    }

    MythUIType::Reset();
}
Пример #2
0
 void BattleAct()
 {
     while(1)
     {
         puts("=======================================");
         printf("要怎么办?\n\n\n    1,攻击 2,物品 3,查看状态 4,逃跑\n\n\n");
         switch(scanf("%d",&choose_number),choose_number)
         {
         case 1:
             s=SuiJi();
             printf("%s攻击! %sHP减少%d\n\n\n",player.name,guai.name,player.attack+s+gong-guai.defense/3);
             guai.health-=player.attack+s+gong-guai.defense/3;
             if(AttackResult())return;            //如果攻击有结果(敌人或玩家战死)退出函数
             else continue; 
         case 2: ChooseWupin();break;             //选择物品,可以使用,战斗中允许使用攻击性物品
         case 3:DisplayState();break;             //显示状态
         case 4:
             s=SuiJi();
             if(s<4)                               //40%的概率可以逃跑
             {
                 printf("%s逃跑了~\n\n\n",player.name);
                 battle=0;
                 return;
             }
             else printf("%s逃跑失败!\n\n\n",player.name);
             break;
         default:SlowDisplay("输入错误,重新输入!\n\n\n");
         }
     }
 }
Пример #3
0
void Display::Update() {
  Thermocycler::ProgramState state = GetThermocycler().GetProgramState();
  if (iLastState != state)
    iLcd.clear();
  iLastState = state;
  
  // check for reset
  if (millis() - iLastReset > RESET_INTERVAL) {  
    iLcd.begin(20, 4);
    iLastReset = millis();
  }
  
  switch (state) {
  case Thermocycler::ERunning:
  case Thermocycler::EComplete:
  case Thermocycler::ELidWait:
  case Thermocycler::EStopped:
    iLcd.setCursor(0, 1);
 #ifdef DEBUG_DISPLAY
    iLcd.print(iszDebugMsg);
 #else
    iLcd.print(GetThermocycler().GetProgName());
 #endif
           
    DisplayLidTemp();
    DisplayBlockTemp();
    DisplayState();

    if (state == Thermocycler::ERunning && !GetThermocycler().GetCurrentStep()->IsFinal()) {
      DisplayCycle();
      DisplayEta();
    } else if (state == Thermocycler::EComplete) {
      iLcd.setCursor(0, 3);
      iLcd.print(rps(RUN_COMPLETE_STR));
    }
    break;
  
  case Thermocycler::EOff:
  case Thermocycler::EStartup:
    iLcd.setCursor(6, 1);
    iLcd.print(rps(OPENPCR_STR));

    if (state == Thermocycler::EOff) {
      iLcd.setCursor(4, 2);
      iLcd.print(rps(POWERED_OFF_STR));
    } else {
      iLcd.setCursor(3, 2);
      iLcd.print(rps(VERSION_STR));
    }
    break;
  }
}
Пример #4
0
int main(int argc, char **argv) {

	std::string board = std::string(BOARD_WIDTH*BOARD_HEIGHT, '=');

	int p1Move = 1;
	int p2Move = -1;
	int p1Score = 0;
	int p2Score = 0;
	int fruitPos = 0;

	std::vector<int> player1;
	std::vector<int> player2;

	ResetBoard(board, player1, player2, fruitPos, p1Move, p2Move);


	bool quit = false;

	while (!quit) {
		//REMOVE FOR FINAL CODE
		system("cls");

		//REMOVE FOR FINAL CODE
		//Change to receive client comamnds
		if (_kbhit())
		{
			switch (_getch())
			{
			//Player 1 Movement
			case 'a': 
				if(p1Move != 1)
					p1Move = -1;
				break;
			case 'd':
				if(p1Move != -1)
					p1Move = 1;
				break;
			case 'w': 
				if(p1Move != BOARD_WIDTH)
					p1Move = BOARD_WIDTH*-1;
				break;
			case 's': 
				if(p1Move != BOARD_WIDTH*-1)
					p1Move = BOARD_WIDTH*1;
				break;

			//Player 2 Movement
			case 75:
				if(p2Move != 1)
					p2Move = -1;
				break;
			case 77:
				if(p2Move != -1)
					p2Move = 1;
				break;
			case 72:
				if(p2Move != BOARD_WIDTH)
					p2Move = BOARD_WIDTH*-1;
				break;
			case 80: 
				if(p2Move != BOARD_WIDTH*-1)
				p2Move = BOARD_WIDTH * 1;
				break;

			}
		}

		bool gameover = false;

		int p1Next = player1.front() + p1Move;
		player1.insert(player1.begin(),p1Next);

		int p2Next = player2.front() + p2Move;
		player2.insert(player2.begin(), p2Next);

		if (HitBoundary(player1.front(), p1Move)) {
			p2Score++;
			gameover = true;
		}
		if (HitBoundary(player2.front(), p2Move)) {
			p1Score++;
			gameover = true;
		}

		if (!gameover) {
			if (fruitPos != player1.front())
				player1.pop_back();
			else {
				RandomSpawn(fruitPos, board);
				p1Score++;
			}

			if (fruitPos != player2.front())
				player2.pop_back();
			else {
				RandomSpawn(fruitPos, board);
				p2Score++;
			}
		}

		ClearBoard(board);
		if(gameover || !UpdateBoard(board, player1,player2,fruitPos,p1Score,p2Score,p1Move,p2Move))
			ResetBoard(board, player1, player2, fruitPos, p1Move, p2Move);


		//REMOVE FOR FINAL CODE
		DisplayState(board,p1Score,p2Score);
		Sleep(100);
	}


	
	return 0;
}
void ClientStateIndicator::ReskinInterface()
{
	DisplayState();
}
Пример #6
0
    void OrdinaryAct()                    //正常行为菜单(移动,物品,对话,查看状态,装备,退出游戏)
    {
        
        while(1)
        {
//            \(1000);
//            system("cls");
            puts("====================================");
            printf("要做什么?\n\n\n   1,移动  2,道具  3,对话  4,查看状态  5,装备  0,退出游戏\n\n\n");
            puts("===================================");
        switch(scanf("%d",&choose_number),choose_number)
        { 
        case 1:                                    //显示移动菜单
            SlowDisplay("要去哪里?\n\n\n");
            printf("1,酒吧 2,旅馆 3,森林一层 4,森林二层 5,森林三层 6,草原一层 7,草原二层 8,草原三层\n\n\n");
            switch(scanf("%d",&choose_number),choose_number)
            {
            case 1:place_sign=place.bar;                        //记录目前位置-酒吧
        //           OrdinaryAct();
                   break;
            case 2:place_sign=place.hotel;                      //进入旅店
                   SlowDisplay("要住店吗? 200个金币 1,是  0,否\n\n\n");
                   choose_number=1;
                   switch(scanf("%d",&choose_number),choose_number)
                   {
                   case 1:if(money-200<0)                       //判断钱是否够
                            {
                                SlowDisplay("Sorry,你的钱不够~\n\n\n");        
                            }
                            else 
                            {
                                SlowDisplay("好好休息\n\tHP满\n\t\t第二天了\n\n");
                                money-=200;                         //花费200住店费
                                player.health=player.max_health;    //体力满
                            }
                            break;
                   case 0:SlowDisplay("下次再来!\n\n\n");break;
                   default:printf("hotel talk error!\n\n\n");
                   }
                   place_sign=0;
                   break;
            case 3:
                place_sign=place.forest1;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=xiyi;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;
                    guai=witch;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                    //不用调用OAct函数,会自动执行OAct函数;
                }
                break;
            case 4:
                place_sign=place.forest2;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=witch;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;
                    guai=strongman;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                }
                break;
            case 5:
                place_sign=place.forest3;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=strongman;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;
                    guai=big_strongman;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                }
                break;
            case 6:
                place_sign=place.grass1;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=bee;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;
                    guai=horse;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                }
                break;
            case 7:
                place_sign=place.grass2;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=horse;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;
                    guai=lion;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                }
                break;
            case 8:
                place_sign=place.grass3;
                s=SuiJi();    
                if(s<7)
                {
                    battle=1;
                    guai=lion;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                }
                else if(s<9)
                {
                    battle=1;                    
                    if(strongman_arm)
                    {
                        SlowDisplay("神秘老人:\n\n\n    哈哈,年轻人,做的不错,不过...嘿嘿,你上当啦!巨人之臂我要了,公主你也别想带走!\n\n\n");
                        guai=shitu;
                    printf("%s扑了过来!\n\n\n",guai.name);
                    BattleAct();
                    }
                    else SlowDisplay("神秘老人:\n\n\n    年轻人,你好啊.如果你有巨人之臂,我可以告诉你公主的下落哦~\n\n\n");
                }
                else
                {
                    SlowDisplay("这里安全\n\n\n");
                }
                break;
            default:printf("choose map error!\n\n\n");
            }
            break;
        case 2:   ChooseWupin();break;              //显示道具,并可以使用.
        case 3:                                               //对话选项
            if(place_sign==place.bar) 
            {
                SlowDisplay("要和谁说话?\n\n\n1,红发女郎 2,赏金猎人 3,酒吧老板\n\n\n");     //显示对话人物
               switch(scanf("%d",&choose_number),choose_number)
               {
               case 1:
                   SlowDisplay("红发女郎:\n\n\n    吧台边那个Hunter好帅啊!(~脸红~)\n\n\n听说他经常外出打猎,外面的路他应该很熟悉的!\n\n\n");
                   break;
               case 2:
                   if(fang1n<1&&gong1n<1)
                   {
                       SlowDisplay("赏金猎人:\n\n\n    你要救公主啊!好胆量!\n\n\n    不过外面的丛林和草原很险恶,而且越深越危险,这是匕首和布衣,对你会有些帮助的,拿去吧!\n\n\n");
                       printf("%s心想:(哇,这位大叔人真好啊!\n\n\n)",player.name);
                       gong1n++;
                       fang1n++;
                   }
                   else SlowDisplay("赏金猎人:\n\n\n    加油吧,年轻人!\n\n\n    不要被外面丛林和草原所吓倒!\n\n\n");
                   break;
               case 3:
                   printf("要喝点什么?\n\n\n    1,二锅头25金币 HP+20  2,XO酒80金币 HP+50  3,人头马面150金币 HP+100  0,返回\n\n\n");
                   choose_number=1;
                   while(choose_number)
                   {
                        switch(scanf("%d",&choose_number),choose_number)
                        {
                        case 1:if(money<25)
                               {
                                 SlowDisplay("钱不够!");                              
                               }
                               else
                               {
                                 if(player.health+20<=player.max_health)
                                 {
                                     SlowDisplay("HP+20.");
                                     money-=25;
                                     player.health+=20;
                                 }
                                 else
                                 {
                                     SlowDisplay("HP满了");                                    
                                     player.health=player.max_health;
                                 }
                               }
                               break;
                        case 2:if(money<80)
                               {
                                 SlowDisplay("钱不够!");                              
                               }
                               else
                               {
                                 if(player.health+50<=player.max_health)
                                 {
                                     SlowDisplay("HP+50.");
                                     money-=80;
                                     player.health+=50;
                                 }
                                 else
                                 {
                                     SlowDisplay("HP满了");                                    
                                     player.health=player.max_health;
                                 }
                               }
                               break;
                        case 3:if(money<150)
                               {
                                 SlowDisplay("钱不够!");                              
                               }
                               else
                               {
                                 if(player.health+100<=player.max_health)
                                 {
                                     SlowDisplay("HP+100.");
                                     money-=150;
                                     player.health+=100;
                                 }
                                 else
                                 {
                                     SlowDisplay("HP满了");                                    
                                     player.health=player.max_health;
                                 }
                               }
                               break;
                        case 0:SlowDisplay("下次在来!\n");break;
                        default:SlowDisplay("输入错误\n\n\n");
                        }
                   }
               }
            }
            else if(place_sign==place.hotel)
                    SlowDisplay("“老板娘!我...”\n\n\n“我忙着呢,没空理你~”\n\n\n");
            else SlowDisplay("这里好像没人可以聊天\n\n\n");
            break;
        case 4:   DisplayState(); break;             //显示状态
        case 5:                                 //装备
            printf("攻装: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n\n\n",gong1n,gong2n,gong3n,gong4n);
            printf("防装: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个   8,黄金圣衣:%d个\t\t0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n);
            SlowDisplay("选择要装备的武器或防具:\n\n\n");
            switch(scanf("%d",&choose_number),choose_number)
            {
            case 1:if(gong1n>=1)
                   {
                       SlowDisplay("拿起了匕首\n\n\n");
                       gong=gong1;
                       strcpy(gongname,"匕首");
                   }
                   else SlowDisplay("你没有匕首可以装备\n\n\n");
                   break;
            case 2:if(gong2n>=1)
                   {
                       SlowDisplay("拿起了长剑\n\n\n");
                       gong=gong2;
                       strcpy(gongname,"长剑");
                   }
                   else SlowDisplay("你没有长剑可以装备\n\n\n");
                   break;
            case 3:if(gong3n>=1)
                   {
                       SlowDisplay("拿起了碧血剑\n\n\n");
                       gong=gong3;
                       strcpy(gongname,"碧血剑");
                   }
                   else SlowDisplay("你没有碧血剑可以装备\n\n\n");
                   break;
            case 4:if(gong4n>=1)
                   {
                       SlowDisplay("拿起了绝世好剑\n\n\n");
                       gong=gong4;
                       strcpy(gongname,"绝世好剑");
                   }
                   else SlowDisplay("你没有绝世好剑可以装备\n\n\n");
                   break;
            case 5:if(fang1n>=1)
                   {
                       SlowDisplay("穿上了布衣\n\n\n");
                       fang=fang1;
                       strcpy(fangname,"布衣");
                   }
                   else SlowDisplay("你没有布衣可以装备\n\n\n");
                   break;
            case 6:if(fang2>=1)
                   {
                       SlowDisplay("穿上了铁甲\n\n\n");
                       fang=fang2;
                       strcpy(fangname,"铁甲");
                   }
                   else SlowDisplay("你没有铁甲可以装备\n\n\n");
                   break;
            case 7:if(fang3n>=1)
                   {
                       SlowDisplay("穿上了银甲\n\n\n");
                       fang=fang3;
                       strcpy(fangname,"银甲");
                   }
                   else SlowDisplay("你没有银甲可以装备\n\n\n");
                   break;
            case 8:if(fang4n>=1)
                   {
                       SlowDisplay("穿上了黄金圣衣\n\n\n");
                       fang=fang4;
                       strcpy(fangname,"黄金圣衣");
                   }
                   else SlowDisplay("你没有黄金圣衣可以装备\n\n\n");
                   break;
            case 0:SlowDisplay("未更换装备\n\n\n");break;
            default:printf("change error!");
            }
            break;
        case 0: 
            SlowDisplay("确定推出游戏?(Y/N)\n\n\n");
            getchar();
            proof=getchar();
            if(proof=='y'||proof=='Y')
            {
                SlowDisplay("数据存储中...");
                //向文件中更新数据;
                getchar();
                SlowDisplay("按回车退出");
                getchar();
                return;
            }
            else if(proof=='n'||proof=='N')printf("继续游戏!\n\n\n");
            else SlowDisplay("继续!\n\n\n");
            break;
        default:SlowDisplay("输入错误!\n\n\n");
        }
    }
    }
Пример #7
0
void MythUIStateType::Finalize(void)
{
    if (!DisplayState("default"))
        DisplayState(None);
}