예제 #1
0
void CameraDefend::Update() {
	dotAngle += 5;
	if (dotAngle > 359)
		dotAngle = 0;

	Ghost* ghost = getGameState()->getGhost();

	if (ghost != NULL && ghost->isAttackDefendable() && !(ghost->getAttack() == NULL || ghost->getAttack()->isOver())) {
		if (!active) {
			reinit();
		}
		active = true;
		getFightTutorial()->triggerTutorial(TUTORIAL_DEFEND);
	} else {
		active = false;
	}
}
예제 #2
0
void CameraDefend::Motion(int32 x, int32 y, uint32 id) {
	if (!isActive()) return;
	Ghost* ghost = getGameState()->getGhost();

	CIwFVec2 drawEnd = CIwFVec2(x, y);

	bool dotsCollideWithDrawing = 
		(dotCollides(&dotVertsTopLeftLeft, &dotVertsSizeLeft,  touch[id]->drawStart) && dotCollides(&dotVertsTopLeftRight, &dotVertsSizeRight, drawEnd)) ||
		(dotCollides(&dotVertsTopLeftRight, &dotVertsSizeRight, touch[id]->drawStart) && dotCollides(&dotVertsTopLeftLeft, &dotVertsSizeLeft,  drawEnd));

	if (dotsCollideWithDrawing) {
		active = false;
		if (ghost->getAttack() != NULL)
			defended = true;
			ghost->getAttack()->setDefended();

		/*IwTrace(GHOST_HUNTER, ("Player defend drawing %s; coords %.0f.%.0f to %.0f.%.0f - dot left coord %.0f.%.0f right coord %.0f.%.0f", 
			dotsCollideWithDrawing ? "accpeted" : "rejected",
			drawStart.x, drawStart.y, drawEnd.x, drawEnd.y, defendVertsLeft[0].x, defendVertsLeft[0].y,
			defendVertsRight[0].x, defendVertsRight[0].y));*/
	}
}
예제 #3
0
void CameraDefend::Render() {
	if (defended) {
		IwGxLightingOff();

		animMatSuccess->SetModulateMode(CIwMaterial::MODULATE_NONE);
		animMatSuccess->SetAlphaMode(CIwMaterial::ALPHA_BLEND);

		IwGxSetMaterial(animMatSuccess);
		IwGxSetUVStream(anim_uvs_success);

		IwGxSetVertStreamScreenSpace(animVertsLeftSuccess, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		IwGxSetVertStreamScreenSpace(animVertsRightSuccess, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		if (animMatSuccess->GetAnimCelID() == animMatSuccess->GetAnimCelNum() - 1) {
			defended = false;
		}
	} else {
		animMatSuccess->SetAnimCelID(0);
	}

	if (!isActive()) return;

	{
		Ghost* ghost = getGameState()->getGhost();
		GhostAttack* attack = (ghost != NULL) ? ghost->getAttack() : NULL;

		if (attack != NULL && 
			((attack->getInterval() <  750 && attack->getInterval() > 600) ||
			 (attack->getInterval() <  400 && attack->getInterval() > 250))) {
			dotTexture = dotTextureRed;
		} else {
			dotTexture = dotTextureGreen;
		}
	}

	Iw2DSetAlphaMode(IW_2D_ALPHA_NONE);
	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);

	CIwFMat2D rot;
	rot.SetRot(rad(dotAngle), CIwFVec2(
		dotVertsTopLeftLeft.x + dotVertsSizeLeft.x/2, 
		dotVertsTopLeftLeft.y + dotVertsSizeLeft.y/2));
	Iw2DSetTransformMatrix(rot);
	Iw2DDrawImage(dotTexture, dotVertsTopLeftLeft, dotVertsSizeLeft);

	rot.SetRot(rad(dotAngle), CIwFVec2(
		dotVertsTopLeftRight.x + dotVertsSizeRight.x/2, 
		dotVertsTopLeftRight.y + dotVertsSizeRight.y/2));
	Iw2DSetTransformMatrix(rot);
	Iw2DDrawImage(dotTexture, dotVertsTopLeftRight, dotVertsSizeRight);

	bool isDrwaing = true;
	for (int i = 0; i < DEFEND_TOUCHES_MAX; i++) {
		// Is any touch drawing?
		if (touch[i]->drawing) break;

		if (i == DEFEND_TOUCHES_MAX - 1) {
			isDrwaing = false;
			animMat->SetAnimCelID(0);
		}
	}

	if (isDrwaing) {
		IwGxLightingOff();

		animMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
		animMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);

		IwGxSetMaterial(animMat);
		IwGxSetUVStream(anim_uvs);

		IwGxSetVertStreamScreenSpace(animVertsLeft, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);

		IwGxSetVertStreamScreenSpace(animVertsRight, 4);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
	}
}