Exemplo n.º 1
0
void ComponentRenderAsModel::draw() const
{
	if(!dead || getDeathBehavior()!=Ghost)
	{
		ASSERT(model, "Null pointer: model");

		const float modelScale = lastReportedHeight / modelHeight;

		CHECK_GL_ERROR();

		mat4 transformation(lastReportedPosition,
		                    lastReportedOrientation.getAxisX(),
		                    lastReportedOrientation.getAxisY(),
		                    lastReportedOrientation.getAxisZ());

		glPushMatrix();
		glMultMatrixf(transformation);
		glTranslatef(0.0f, 0.0f, -lastReportedHeight/2.0f);
		glScalef(modelScale, modelScale, modelScale);
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		drawModel(true);
		glPopAttrib();
		glPopMatrix();

		CHECK_GL_ERROR();
	}
}
Exemplo n.º 2
0
void ComponentHealth::update(float deltaTime)
{
    if(!dead) return;

    if((timeSpentDead += deltaTime) >= timeUntilResurrection)
    {
        if(getDeathBehavior() == Disappear)
        {
            MessageZombifyActor m;
            getParentBlackBoard().relayMessage(m);
        }
        else if(willResurrectAfterCountDown)
        {
            MessageCharacterHasBeenResurrected m;
            getParentBlackBoard().relayMessage(m);
        }
    }
}
Exemplo n.º 3
0
void ComponentMovement::update(float) {
	// Set model orientation properly
	{
		ActionLookAt m(facingAngle);
		sendAction(&m);
	}
	
	// Request animation change based on walk speed
	if (!dead || getDeathBehavior()==Ghost) {
		// Request to change the animation
		const string anim = determineCurrentAnim();
		ActionChangeAnimation m(anim);
		sendAction(&m);
		
		// Move the character
		dJointSetLMotorParam(lmotor, dParamVel,  velocity.x);
		dJointSetLMotorParam(lmotor, dParamVel2, velocity.y);
	}
	
	// house keeping
	velocity.zero();
	lastAction = Stand;
}
Exemplo n.º 4
0
void ComponentMovement::turn( float dAngle ) {
	if (!dead || getDeathBehavior()==Ghost) {
		facingAngle = angle_clamp(facingAngle + dAngle);
	}
}
Exemplo n.º 5
0
void ComponentMovement::applyAction(CharacterAction action) {
	vec2 x(-1,  1);
	vec2 y(-1, -1);
	
	if (!dead || getDeathBehavior()==Ghost) {
		switch (action) {
			/* Step in an absolute direction */
		case StepNorth:
			walk(y);
			turnToFace(velocity.xy());
			break;
		case StepSouth:
			walk(-y);
			turnToFace(velocity.xy());
			break;
		case StepEast:
			walk(x);
			turnToFace(velocity.xy());
			break;
		case StepWest:
			walk(-x);
			turnToFace(velocity.xy());
			break;
		case StepNorthEast:
			walk(y+x);
			turnToFace(velocity.xy());
			break;
		case StepNorthWest:
			walk(y-x);
			turnToFace(velocity.xy());
			break;
		case StepSouthEast:
			walk(-y+x);
			turnToFace(velocity.xy());
			break;
		case StepSouthWest:
			walk(-y-x);
			turnToFace(velocity.xy());
			break;
			
			/* Step in a relative direction */
		case StepForward:
			walk(getDirectionVector(facingAngle));
			break;
		case StepForwardRight:
			walk(getDirectionVector(facingAngle - (float)(M_PI * 0.25)));
			break;
		case StepRight:
			walk(getDirectionVector(facingAngle - (float)(M_PI * 0.50)));
			break;
		case StepBackWardRight:
			walk(getDirectionVector(facingAngle - (float)(M_PI * 0.75)));
			break;
		case StepBackWard:
			walk(getDirectionVector(facingAngle - (float)M_PI));
			break;
		case StepBackWardLeft:
			walk(getDirectionVector(facingAngle + (float)(M_PI * 0.75)));
			break;
		case StepLeft:
			walk(getDirectionVector(facingAngle + (float)(M_PI * 0.50)));
			break;
		case StepForwardLeft:
			walk(getDirectionVector(facingAngle + (float)(M_PI * 0.25)));
			break;
			
			/* Other */
		case BeginChargeUp:
			chargeUp();
			break;
		case EndChargeUp:
			endChargeUp();
			break;
		case AttackOnce:
			attackOnce();
			break;
		case Suicide:
			suicide();
			break;
			
		default:
			break;
		}
		lastAction = action;
	} else {
		lastAction = InvalidAction;
	}
}
Exemplo n.º 6
0
void ComponentDeathBehavior::handleEventDeathBehaviorUpdate(const EventDeathBehaviorUpdate *) {
	if (getDeathBehavior() != Ghost) {
		ActionPhysicsDisable m;
		sendAction(&m);
	}
}