Exemplo n.º 1
0
	RayGun::Ray::Ray(byte playerNo, float x1, float y1) : Projectile(playerNo, x1, y1)
	{
		Animation*anim;
			
		anim = new Animation("left",1,"Images/Game/Items/RayGun/ray.png");
		addAnimation(anim);
			
		anim = new Animation("right",1,"Images/Game/Items/RayGun/ray.png");
		anim->mirror(true);
		addAnimation(anim);
		
		switch(itemdir)
		{
			case Player::LEFT:
			changeAnimation("left",FORWARD);
			xvelocity = -6;
			break;
				
			case Player::RIGHT:
			changeAnimation("right",FORWARD);
			xvelocity = 6;
			break;
		}
			
		startX = x;
	}
Exemplo n.º 2
0
void updateDoor(door_struct* d)
{
	if(!d || !d->used)return;

	if(d->active)
	{
		if(d->modelInstance.currentAnim==0)
		{
			changeAnimation(&d->modelInstance, 2, false);
			changeAnimation(&d->modelInstance, 1, true);
			playSFX(doorOpenSFX);
		}else if(d->modelInstance.oldAnim==1 && d->modelInstance.currentAnim==2)
		{
			if(d->rectangle[0]){d->rectangle[0]->collides=false;toggleAAR(d->rectangle[0]->AARid);}
			if(d->rectangle[1]){d->rectangle[1]->collides=false;toggleAAR(d->rectangle[1]->AARid);}
		}
	}else
	{
		if(d->modelInstance.currentAnim==2)
		{
			changeAnimation(&d->modelInstance, 0, false);
			changeAnimation(&d->modelInstance, 3, true);
			playSFX(doorCloseSFX);
			if(d->rectangle[0]){d->rectangle[0]->collides=true;toggleAAR(d->rectangle[0]->AARid);}
			if(d->rectangle[1]){d->rectangle[1]->collides=true;toggleAAR(d->rectangle[1]->AARid);}
		}
	}

	updateAnimation(&d->modelInstance);
	d->active=false;
}
Exemplo n.º 3
0
void ManageNONCombatModeAnimations() {
	arx_assert(entities.player());
	
	Entity *io = entities.player();

	AnimLayer & layer3 = io->animlayer[3];
	ANIM_HANDLE ** alist=io->anims;

	if(player.Current_Movement & (PLAYER_LEAN_LEFT | PLAYER_LEAN_RIGHT))
		return;

	if(ValidIONum(player.equiped[EQUIP_SLOT_SHIELD]) && !BLOCK_PLAYER_CONTROLS) {
		if ( (layer3.cur_anim==NULL)  ||
			( (layer3.cur_anim!=alist[ANIM_SHIELD_CYCLE])
			&& (layer3.cur_anim!=alist[ANIM_SHIELD_HIT])
			&& (layer3.cur_anim!=alist[ANIM_SHIELD_START]) ) )
		{
			changeAnimation(io, 3, alist[ANIM_SHIELD_START]);
		} else if(layer3.cur_anim==alist[ANIM_SHIELD_START] && (layer3.flags & EA_ANIMEND)) {
			changeAnimation(io, 3, alist[ANIM_SHIELD_CYCLE], EA_LOOP);
		}
	} else {
		if(layer3.cur_anim==alist[ANIM_SHIELD_CYCLE]) {
			changeAnimation(io, 3, alist[ANIM_SHIELD_END]);
		} else if(layer3.cur_anim == alist[ANIM_SHIELD_END] && (layer3.flags & EA_ANIMEND)) {
			layer3.cur_anim=NULL;
		}
	}
}
Exemplo n.º 4
0
	void BeamSword::onAnimationFinish(const String&name)
	{
		if(name.equals("swing_left") || name.equals("swing_right")
		|| name.equals("swing2_left") || name.equals("swing2_right"))
		{
			active = false;
			Player*playr = getPlayer();
			if(playr!=null)
			{
				switch(playr->getPlayerDir())
				{
					case Player::LEFT:
					changeAnimation("carry_left",FORWARD);
					break;
					
					case Player::RIGHT:
					changeAnimation("carry_right",FORWARD);
					break;
				}
			}
			else
			{
				changeAnimation("normal",FORWARD);
			}
		}
	}
Exemplo n.º 5
0
void EnemyView::die()
{
	state_b = DEAD;

	switch(type)
	{
		case REBEL  : changeAnimation(REBEL_DEATH,false);  break;
		case BOWSER : changeAnimation(BOWSER_DEATH,false); break;
		case FLYING : changeAnimation(FLYING_DEATH,false); break;
	}
    
    srand(time(NULL));
    
    if(type == REBEL)
    {
		RebelSounds tmp_snd[3] = {REBEL_DEATH_SND, REBEL_DEATH2_SND, REBEL_DEATH3_SND};
		sounds[tmp_snd[rand()%3]]->play();
    }
    else if(type == BOWSER)
	{
		sounds[BOWSER_DEATH_SND]->play();
		sounds[BOWSER_DEATH2_SND]->play();
    }
    else if(type == FLYING)
    {
    	sounds[FLYING_DEATH_SND]->play();
    }
    
}
Exemplo n.º 6
0
void EnemyView::shoot(list<AmmoView*>* air, Int2 angle)
{	
	if(state_b == DEAD)
		return;

	list<Ammo*> tmp;
	AmmoView* av;
	
	if(type == REBEL)
	{
		if(current_anim==REBEL_KNIFE && state_b==PRESHOOT)
		{
			Enemy::knife();
		}
		else
		{
			state_b = PRESHOOT;
			state_p = WAIT;
			save_air = air;
			save_angle = angle;
			changeAnimation(REBEL_KNIFE,false,REBEL_WATCH);
		}
	}

	else if(type == BOWSER)
	{
		if(current_anim==BOWSER_FIRE && state_b==PRESHOOT)
		{
			Enemy::shoot(&tmp,angle);
		}
		else
		{
			state_b = PRESHOOT;
			state_p = WAIT;
			save_air = air;
			save_angle = angle;
			changeAnimation(BOWSER_FIRE,false,BOWSER_STAND);
		}
	}

	else if(type == FLYING)
	{
		if(canShoot()) {
			Enemy::shoot(&tmp,angle);
		}
	}	

	for(list<Ammo*>::iterator a = tmp.begin(); a != tmp.end(); a++)
    {
    	av = new AmmoView(**a);
    	air->push_back(av);
    	tmp.erase(a++);
    }

}
Exemplo n.º 7
0
void AmmoView::die(Int2 pos)
{
	Ammo::die(pos);

	if(type==BULLET || type==HEAVY_BULLET || type==LIGHT_BULLET)
		changeAnimation(1,false);
	else if(type==GRENADE)
	{
		initRotation();
		changeAnimation(1,false);
		sounds[GRENADE]->play();
	}
}
Exemplo n.º 8
0
void EnemyView::walk(int way)
{
	if(state_b == DEAD)
		return;

	Enemy::walk(way);

	switch(type)
	{
		case REBEL : changeAnimation(REBEL_RUN); break;
		case BOWSER : changeAnimation(BOWSER_WALK); break;
	}

	updateIntRect();
}
Exemplo n.º 9
0
	CharSelectScreen::CharCoin::CharCoin(CharSelectScreen*screen,int num) : Actor(0,0)
	{
		drag = false;
		dragId = 0;
		this->screen = screen;
		Animation*anim;
		switch(num)
		{
			default:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin.png");
			break;
			
			case 1:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin1.png");
			break;
			
			case 2:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin2.png");
			break;
			
			case 3:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin3.png");
			break;
			
			case 4:
			anim = new Animation("normal",1,"Images/Menus/CharacterSelect/coins/coin4.png");
			break;
		}
		addAnimation(anim);
		changeAnimation("normal",FORWARD);
	}
Exemplo n.º 10
0
	void OffScreenExplode::setActive()
	{
		active = true;
		setAlpha(0);
		changeAnimation("normal", FORWARD);
		Console::WriteLine("setting OffScreenExplode Active");
	}
Exemplo n.º 11
0
	void WinnerScreen::CharStat::CharStatPlayer::onAnimationFinish(const String&name)
	{
		if(name.equals((String)"win"))
		{
			changeAnimation("win_hold",FORWARD);
		}
	}
Exemplo n.º 12
0
	CharSelectScreen::CharIcon::CharIcon(int num, float x1, float y1, Animation*anim) : Actor(x1,y1)
	{
		setScale(1.8f);
		addAnimation(anim);
		changeAnimation(anim->name, FORWARD);
		this->num = num;
	}
Exemplo n.º 13
0
void Enemy::moveUp(int px)
{
	Action GoUp;
	GoUp.is_blocking = true;
	GoUp.thread_id = 1;
	Action AnimReset;
	AnimReset.is_blocking = true;
	AnimReset.thread_id = 1;

	GoUp.action = get_action([this, px](sf::Time dt)
	{
		if (getAnimationState() != static_cast<int>(Animations::GoUp))
		{
			animation.play();
			changeAnimation(static_cast<int>(Animations::GoUp));
			getAnimation().play();
		}
		return goUpUntil(px, dt);
	});

	AnimReset.action = get_action([this](sf::Time dt)
	{
		animation.reset();
		return false;
	});

	action_tree.push(GoUp);
	action_tree.push(AnimReset);
}
Exemplo n.º 14
0
	void SmashBall::onAnimationFinish(const String&n)
	{
		if(n.equals("hit"))
		{
			changeAnimation("normal",FORWARD);
		}
	}
Exemplo n.º 15
0
void ARX_EQUIPMENT_LaunchPlayerUnReadyWeapon() {
	arx_assert(entities.player());
	arx_assert(arrowobj);
	
	Entity * io = entities.player();
	
	ANIM_HANDLE * anim;
	WeaponType type = ARX_EQUIPMENT_GetPlayerWeaponType();

	switch(type) {
		case WEAPON_DAGGER:
			anim = io->anims[ANIM_DAGGER_UNREADY_PART_1];
			break;
		case WEAPON_1H:
			anim = io->anims[ANIM_1H_UNREADY_PART_1];
			break;
		case WEAPON_2H:
			anim = io->anims[ANIM_2H_UNREADY_PART_1];
			break;
		case WEAPON_BOW:
			anim = io->anims[ANIM_MISSILE_UNREADY_PART_1];
			EERIE_LINKEDOBJ_UnLinkObjectFromObject(io->obj, arrowobj);
			break;
		default:
			anim = io->anims[ANIM_BARE_UNREADY];
			break;
	}

	changeAnimation(io, 1, anim);
}
Exemplo n.º 16
0
void ARX_EQUIPMENT_LaunchPlayerReadyWeapon() {
	arx_assert(entities.player());
	Entity *io = entities.player();
	
	WeaponType type = ARX_EQUIPMENT_GetPlayerWeaponType();
	ANIM_HANDLE * anim = NULL;

	switch(type) {
		case WEAPON_DAGGER:
			anim = io->anims[ANIM_DAGGER_READY_PART_1];
			break;
		case WEAPON_1H:
			anim = io->anims[ANIM_1H_READY_PART_1];
			break;
		case WEAPON_2H:
			if(!ValidIONum(player.equiped[EQUIP_SLOT_SHIELD]))
				anim = io->anims[ANIM_2H_READY_PART_1];

			break;
		case WEAPON_BOW:
			if(!ValidIONum(player.equiped[EQUIP_SLOT_SHIELD]))
				anim = io->anims[ANIM_MISSILE_READY_PART_1];

			break;
		default:
			anim = io->anims[ANIM_BARE_READY];
			break;
	}

	changeAnimation(io, 1, anim);
}
Exemplo n.º 17
0
/*---------------------------------------------------------------------------------*/
bool NPC::moveReset(const double& timeSinceLastFrame)
{
	//Updates the position here. Not as accurate as the method Player uses, but works fine.
	//See GameState::update to see how Player need two calls each update. One before and after physics timestep.
	updatePosition();

	//Get the direction to the spawnpoint
	Ogre::Vector3 dirNPCtoSpawnPoint = mtSpawnPoint - mtpCharNode->_getDerivedPosition();

	//Instead of length, use this approximation to check if the NPC is in range close enough of the spawn point
	//If so, the reset is done.
	if ((dirNPCtoSpawnPoint.x > -0.1 && dirNPCtoSpawnPoint.x < 0.1) && (dirNPCtoSpawnPoint.z > -0.1 && dirNPCtoSpawnPoint.z < 0.1))
	{
		mtReseting = false;
		//Returns true and tells the NPCHandler to delete it from a temporary Vector of reseting NPCs.
		return true;
	}
	//No movement in Y direciton
	dirNPCtoSpawnPoint.y = 0;
	//Movement velocity not dependent of the distance between Character and Camera.
	dirNPCtoSpawnPoint.normalise();

	//Make the NPC always face the spawn point when moving
	rotateCharacter(mtpCharNode,dirNPCtoSpawnPoint,*mtFaceDirection);

	//Animare and move the box
	changeAnimation("Walk", timeSinceLastFrame);
	mtpHitBox->setLinearVelocity(NxOgre::Vec3(dirNPCtoSpawnPoint.x*mtWalkSpeed ,mtpHitBox->getLinearVelocity().y,dirNPCtoSpawnPoint.z*mtWalkSpeed ));	
	
	//Returning false == no reset yet.
	return false;
}
Exemplo n.º 18
0
void Npc::moveUp(int px)
{
	Action GoUp;
	Action AnimReset;

	GoUp.action = get_action<Npc>([this, px](Npc &npc, sf::Time dt)
	{
		if (getAnimationState() != static_cast<int>(Animations::GoUp))
		{
			animation.play();
			changeAnimation(static_cast<int>(Animations::GoUp));
			getAnimation().play();
		}
		return goUpUntil(px);
	});

	AnimReset.action = get_action<Npc>([this](Npc &npc, sf::Time dt)
	{
		animation.reset();
		return false;
	});

	action_queue.push(GoUp);
	action_queue.push(AnimReset);
}
Exemplo n.º 19
0
	SmashBall::SmashBall(float x1, float y1) : Item(x1,y1, 40000,TYPE_WIELD)
	{
		moveTime = 0;
		speed = 1;
		hittable = true;
		unHittableTime = 0;
		health = 10;
		
		active = true;
		
		itemNo = Global::ITEM_SMASHBALL;

		readyFire = null;
		
		Animation*anim;
		
		anim = new Animation("normal", 5, 8, 1);
		anim->addFrame("Images/Game/Items/SmashBall/smashball.png");
		addAnimation(anim);
		
		anim = new Animation("hit", 6, 2, 1);
		anim->addFrame("Images/Game/Items/SmashBall/smashball_hit.png");
		addAnimation(anim);
		
		addFileResource("Images/Game/Items/SmashBall/finalsmash_fire.png");
		
		changeAnimation("normal",FORWARD);
		
		ignoreGoThroughPlatforms(true);
		setSolid(true);
		canBeCarried(false);
	}
Exemplo n.º 20
0
	OffScreenExplode::OffScreenExplode(int playerNo) : GameElement(0,0)
	{
		this->playerNo = playerNo;
		active = false;
		addAnimation(new Animation("normal",1,"Images/Game/Misc/offscreen_explode.png"));
		changeAnimation("normal", FORWARD);
		setScale(1.1f);
	}
Exemplo n.º 21
0
	RayGun::RayGun(float x1, float y1) : Item(x1, y1, 20000, TYPE_HOLD)
	{
		itemNo = Global::ITEM_RAYGUN;
		
		weight = 0.2f;
		
		ammo = 16;
		active = false;
		activeTime = 0;
		attackType = 0;
		
		Animation*anim;
		
		anim = new Animation("left",1,"Images/Game/Items/RayGun/raygun.png");
		addAnimation(anim);
		
		anim = new Animation("right",1,"Images/Game/Items/RayGun/raygun.png");
		anim->mirror(true);
		addAnimation(anim);
		
		anim = new Animation("down_left",1,"Images/Game/Items/RayGun/raygun_down.png");
		addAnimation(anim);
		
		anim = new Animation("down_right",1,"Images/Game/Items/RayGun/raygun_down.png");
		anim->mirror(true);
		addAnimation(anim);
		
		dir = (byte)((GameEngine::random()*2)+1);
		
		switch(dir)
		{
			case Player::LEFT:
			changeAnimation("left",FORWARD);
			break;
			
			case Player::RIGHT:
			changeAnimation("right",FORWARD);
			break;
		}
		
		setHoldOffset(5, 1);
	}
Exemplo n.º 22
0
void controlUse(player_struct* p, bool down, bool held)
{
	if(!p || !down)return;

	if(!p->modelInstance.oneshot)
	{
		playSFX(gunSFX2);
		shootPlayerGun(p,false,1|2);
		changeAnimation(&p->modelInstance,1,true);
	}
}
Exemplo n.º 23
0
void controlShootYellow(player_struct* p, bool down, bool held)
{
	if(!p || !down)return;

	if(!p->modelInstance.oneshot)
	{
		playSFX(gunSFX1);
		shootPlayerGun(p,true,255);
		changeAnimation(&p->modelInstance,1,true);
	}
}
Exemplo n.º 24
0
void controlShootAll(player_struct* p, bool down, bool held)
{
	if(!p || !down)return;

	if(!p->modelInstance.oneshot)
	{
		playSFX(currentPortalColor?gunSFX1:gunSFX2);
		shootPlayerGun(p,currentPortalColor,255);
		changeAnimation(&p->modelInstance,1,true);
	}
}
Exemplo n.º 25
0
void ComponentRenderAsModel::loadModel(const FileName &fileName)
{
	ASSERT(g_ModelFactory, "modelFactory is null");
	model = g_ModelFactory->createFromFile(fileName);

	// Calculate height of unscaled model
	modelHeight = model->calculateHeight();

	// default animation
	changeAnimation("idle");
}
Exemplo n.º 26
0
void Song::nextAnimation()
{
    int goTo = _selectedAnimation + 1;
    
    if(_state == TRANSITION)
    {
        goTo = _transitionTo + 1;
    }
        
    changeAnimation(goTo);
}
Exemplo n.º 27
0
void Song::prevAnimation()
{
    int goTo = _selectedAnimation - 1;
    
    if(_state == TRANSITION)
    {
        goTo = _transitionTo - 1;
    }
    
    changeAnimation(goTo);
}
Exemplo n.º 28
0
	void RayGun::Ray::deflect(byte dir)
	{
		switch(dir)
		{
			case DIR_LEFT:
			case DIR_UPLEFT:
			case DIR_DOWNLEFT:
			itemdir = LEFT;
			xvelocity = -6;
			changeAnimation("left", FORWARD);
			break;
			
			case DIR_RIGHT:
			case DIR_UPRIGHT:
			case DIR_DOWNRIGHT:
			itemdir = RIGHT;
			xvelocity = 6;
			changeAnimation("right", FORWARD);
			break;
		}
	}
Exemplo n.º 29
0
void controlStrafeRight(player_struct* p, bool down, bool held)
{
	if(!p)return;

	if(p->object->contact)
	{
		moveCamera(NULL, vect(PLAYERGROUNDSPEED,0,0));
		p->walkCnt+=2500;
		changeAnimation(&p->playerModelInstance,4,false);
		idle=false;
	}else moveCamera(NULL, vect(PLAYERAIRSPEED,0,0));
}
Exemplo n.º 30
0
//What's in doStuff right now is only for testing purpose. Lot of stuff to do here.
void Elodie::doStuff(const EventHandler& event, const std::vector< std::vector<TileSprite*> >& tiles,
                     EntityMap& entities, sf::Time animate)
{
    //Compute the gravity
    computeGravity(animate);

    //Check the collisions, set the new distances and do the move
    Collide collideTiles = collideWithTiles(tiles, animate.asSeconds());
    setDistance(collideTiles);
    move(animate.asSeconds()*(speed.x), animate.asSeconds()*speed.y);
    spriteCast->update(animate);

    //Change the sprite in accord with the speed
    changeAnimation(collideTiles);
    handleEvent(event, entities, collideTiles);

    if (0 == speed.x && !collideTiles.right["surface"])
    {
        speed.x = moveSpeed;
    }

    float dist = cameraPos.x - spriteCast->getPosition().x;

    if (dist > 0 && !collideTiles.right["surface"] && !buffed)
    {
        buffed = true;
        speed.x = moveSpeed + dist;
    }

    buffed = !collideTiles.right["surface"];

    if (buffed && dist <= 0)
    {
        buffed = false;
        speed.x = moveSpeed;
    }

    //Other stuff to do
    attackTimer += animate.asSeconds();
    pvTimer += animate.asSeconds();
    if (pvTimer > interRecoveryTime)
    {
        pvTimer = 0;
        immersionLevel = immersionLevel == 100 ? 100 : immersionLevel + 1;
    }
    if (damageCD)
    {
        --damageCD;
    }
    cameraPos.x += (moveSpeed)*animate.asSeconds();
    cameraPos.y = spriteCast->getPosition().y;
}