Beispiel #1
0
void playerAttack(App *app, Player *player){
	int i;
	Body *body = &player->body;
	Body *head_body = &app->game.head.body;

	if(body->action == ACTION_DEATH) return;
	if(player->grabbing){
		head_body->action = ACTION_MOVE;
		player->grabbing = 0;
		return;
	}

	if(player->special_attack >= 100) {
		player->power_body.action = ACTION_ATTACK;
		player->power_body.damage = PLAYER_DAMAGE;
		playSpecialAttack();
	}else{
		playAttack();
	}

	body->action = ACTION_ATTACK;
	body->frame = 0;

	for(i=0; i< 360; i+=10) {
		float range = (i > 180 ? i-180 : 180-i) / 180. * tileSize*1.2;
		shoot(app, &player->body, 20, i, range);
	}

	player->special_attack = 0;
}
Beispiel #2
0
void Walker::delayPlayAnimation(){
    
    if (m_iconSpr == NULL||m_iconSpr->getReferenceCount()<=0) {
        return ;
    }
    Action* action = createAnimation();
    if(action)
    {
        //CCCallFuncO* fun1 = CCCallFuncO::create(this, callfuncO_selector(Walker::continueMove), NULL);
        //Action *  result = CCSequence::create(action, fun1, NULL);
        //CCSequence *  result = CCSequence::create(action, fun1, NULL);
        m_iconSpr->runAction(action);
    }
    
   // myArray->release();
    this->unschedule(schedule_selector(Walker::playAttack));
    if (m_armType==1||m_armType==4||m_armType==3||m_armType==7) {//
        this->schedule(schedule_selector(Walker::playAttack), 2);
        playAttack(0);
    }
}
Beispiel #3
0
/**
 * Menu de sélection de l'unité
 * @param choice    Choix de l'action pour l'unité
 */
void unitMenu(int choice){
    char yn[2];

    printf("\n");
    switch(choice){
            case 1:

            		clearScreen(); // Met à jour l'affichage pour le tour
					gridDisp();
            		if(!hasAttacked && !hasMoved){
            			movable(white); // Fait la liste des unités pouvant se déplacer

	                    clearScreen(); // Met à jours les couleurs des unités déplaçables
						gridDisp();

	                    printf("\nSe déplacer ? y/n\n");
	        		    readS(yn);
	                  	printf("\n");

	                    if(strcmp(yn,"y") == 0 || strcmp(yn,"Y") == 0) {
	                    	playMove();
	                    }else if(strcmp(yn,"n") != 0 && strcmp(yn,"N") != 0){
                        	printf("Saisie invalide\n");
                    	}

                    	movable(black);
            		}else if(hasAttacked){
            			color(red, "Vous ne pouvez pas déplacer votre unité après avoir attaqué !\n");
            		}else{
            			color(red, "Vous ne pouvez pas déplacer une unité à nouveau !\n");
            		}

                break;
            case 2:

            		clearScreen(); // Met à jour l'affichage pour le tour
					gridDisp();
        		    if(!hasAttacked){
        		    	attackable(white); // Attaquants en blanc
	        		    
        		    	clearScreen(); // Met à jours les couleurs des unités pouvant attaquer
						gridDisp();

	        		    printf("\nAttaquer ? y/n\n");
	        		    readS(yn);
	        		    printf("\n");

	                    if(strcmp(yn,"y") == 0 || strcmp(yn,"Y") == 0) {
	                        playAttack();
	                    }else if(strcmp(yn,"n") != 0 && strcmp(yn,"N") != 0){
	                        printf("Saisie invalide\n");
	                    }

	                    attackable(black); // Attaquants en noir
                	}else{
                		color(red, "Vous ne pouvez pas réattaquer !\n");
                	}
                break;
            case 3:
            	
            	movable(white);

            	clearScreen();
				gridDisp();
            	
            	printList(noPlayer);

            	printf("\nChanger de direction ? y/n\n");
    		    readS(yn);
    		    printf("\n");

                if(strcmp(yn,"y") == 0 || strcmp(yn,"Y") == 0) {
                    changeDirection();
                }else if(strcmp(yn,"n") != 0 && strcmp(yn,"N") != 0){
                    printf("Saisie invalide\n");
                }
                
                movable(black);

            	clearScreen();
				gridDisp();

				
        		break;
        }
}
Beispiel #4
0
void Walker::moveOnePoint(float tab){
    if(m_movePositions.size()>m_moveIndex){
        mCurrentSeq = mTargetSeq;
        mTargetSeq = m_moveSeqs[m_moveIndex];
        CCPoint onePos = m_movePositions[m_moveIndex];
        CCPoint lastPos = m_point;
        if(m_moveIndex!=0){
            lastPos = m_movePositions[m_moveIndex-1];
        }
        
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_CHECK_ZORDER, this);
        m_lastDirect = getDirection(lastPos,onePos);
        if(m_moveIndex != 0)
        {
            this->changeDirect(m_lastDirect);
        }
        m_status = WALKER_ACTION_MOVE;
        m_loopTimes = numeric_limits<int>::max();
        
        this->unschedule(schedule_selector(Walker::playAttack));
        if (m_armType == 1 || m_armType == 4 || m_armType == 3 || m_armType == 7)
        {
            this->schedule(schedule_selector(Walker::playAttack), 2);
            playAttack(0);
        }
        
        CCPoint gap = ccpSub(lastPos, onePos);
        float len = ccpLength(gap);
        float useTime = len/m_moveSpd;//len/120.0;
        CCSequence* sc = nullptr;
        Action* action = nullptr;
        if(useTime == 0)
        {
            sc = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Walker::moveOnePoint)),NULL);
        }
        else
        {
            sc = CCSequence::create(CCMoveTo::create(useTime, onePos),CCCallFunc::create(this, callfunc_selector(Walker::moveOnePoint)),NULL);
            action = createAnimation();
        }
        //Action* action = createAnimation();
        if (action)
        {
            auto sp = Spawn::create(sc, action, NULL);
            m_iconSpr->runAction(sp);
        }
        else
        {
            m_iconSpr->runAction(sc);
        }
        m_moveIndex += 1;
        
    }else{
        /*
        m_status = WALKER_ACTION_STAND;
        this->changeDirect(m_lastDirect,true);
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_SOLDIER_STOP, this);
        */
        onMoveFinished();
    }
}