void SteamDeathEffect::update(float dTime)
{
	if (GET_GAME_MANAGER()->getMicroSecondTime() - m_StartTime < 2000)
	{
		auto player = GET_STAGE_MANAGER()->getPlayer();

		int randNum = 20 - (GET_GAME_MANAGER()->getMicroSecondTime() - m_StartTime) / 100;
		int createNum = 1 + (GET_GAME_MANAGER()->getMicroSecondTime() - m_StartTime) / 400;

		if (rand() % randNum == 0)
		{

			for (int i = 0; i < createNum; i++)
			{
				float xPos = rand() % 20;

				if (player->getInfo().m_UpperDir == DIR_RIGHT)
				{
					xPos -= 30;
				}
				else
				{
					xPos += 10;
				}

				cocos2d::Point randPos(xPos, static_cast<float>(player->getInfo().m_Size.height / 2 - rand() % 10));

				GET_EFFECT_MANAGER()->createEffect(ET_SMOKE, player->getPosition() + randPos)->enter();
			}
		}
	}
	else if (GET_GAME_MANAGER()->getMicroSecondTime() - m_StartTime < 4000)
	{
		if (!m_MakeParalysis)
		{
			auto effect = GET_EFFECT_MANAGER()->createEffect(ET_PARALYSIS, getPosition());

			effect->setChasingPlayer(true);
			effect->enter();

			m_MakeParalysis = true;
		}
	}
	else
	{
		m_IsDead = true;
	}
}
Example #2
0
void BladeMissile::update(float dTime)
{
    auto playerPos = GET_STAGE_MANAGER()->getPlayer()->getPosition();

    if (m_AttackDir == DIR_LEFT)
    {
        setPosition(cocos2d::Point(playerPos.x - m_TargetSize.width, playerPos.y));
    }
    else
    {
        setPosition(cocos2d::Point(playerPos.x + m_TargetSize.width, playerPos.y));
    }

    int nowTime = GET_GAME_MANAGER()->getMicroSecondTime();

    if (nowTime - m_StartTime > SUSTAINMENT_TIME)
    {
        //미사일 완전 삭제
        m_IsDead = true;
        exit();
        removeChild(m_Sprite);
        m_IsUsable = true;
        removeFromParent();
    }

}
Example #3
0
void MonsterDevil::enterMove()
{
	m_IsArrived = false;
	m_MoveStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
	
	auto playerPos = GET_STAGE_MANAGER()->getPlayer()->getPosition();
	auto myPos = getPosition();
	auto tileSize = GET_DATA_MANAGER()->getTileSize();

	int goalX = playerPos.x / tileSize.width;
	int goalY = playerPos.y / tileSize.height;
	int startX = myPos.x / tileSize.width;
	int startY = myPos.y / tileSize.height;

	if (m_PathFinder->getPath(startX,startY,goalX,goalY,&m_Path))
	{
		m_PathIdx = 0;
		m_DstPos.x = m_Path[m_PathIdx].x * tileSize.width + tileSize.width/2;
		m_DstPos.y = m_Path[m_PathIdx].y * tileSize.height + tileSize.height/2;

		float distance = sqrt((m_DstPos.x - myPos.x)*(m_DstPos.x - myPos.x) +
							  (m_DstPos.y - myPos.y)*(m_DstPos.y - myPos.y));

		cocos2d::Vec2 velocity;
		velocity.x = m_Info.m_Speed * (m_DstPos.x - myPos.x) / distance;
		velocity.y = m_Info.m_Speed * (m_DstPos.y - myPos.y) / distance;
		m_Body->setVelocity(velocity);
	}
}
Example #4
0
void StageManager::start()
{
	auto scene = GET_GAME_MANAGER()->getScene(GAME_SCENE);
	m_GameScene = static_cast<GameScene*>( scene->getChildByTag(GAME_SCENE_TAG) );
	m_GameScene->scheduleUpdate();
	initStage(0);
}
Example #5
0
void BombMissile::setAttribute(cocos2d::Point pos, Direction attackDir /*= DIR_NONE*/, float damage /*= 0*/, cocos2d::Size contentsSize /*= cocos2d::Size::ZERO*/, cocos2d::Vec2 velocity /*= cocos2d::Point::ZERO*/, cocos2d::Point targetPos /*= cocos2d::Point::ZERO*/)
{
	m_IsDead = false;
	m_IsUsable = false;
	m_IsPlayerMissile = true;
	m_Damage = damage;
	m_AttackDir = attackDir;
	m_TargetSize = contentsSize;
	m_StartTime = GET_GAME_MANAGER()->getMicroSecondTime();
	m_State = MST_KNOCKBACK;
	m_IsPhysics = true;

	m_Sprite = cocos2d::Sprite::create();
	addChild(m_Sprite);
	auto animate = cocos2d::Animate::create(GET_RESOURCE_MANAGER()->createAnimation(AT_GRENADEEXPLOSION));

	m_Sprite->runAction(animate);
	m_Sprite->setScale(6);

	auto meterial = cocos2d::PhysicsMaterial(0, 0, 0);
	m_Body = cocos2d::PhysicsBody::createCircle(96, meterial);
	m_Body->setContactTestBitmask(PHYC_MONSTER);
	m_Body->setCategoryBitmask(PHYC_MISSILE);
	m_Body->setCollisionBitmask(PHYC_MONSTER);
	m_Body->setTag(static_cast<int>(getType()));
	m_Body->setDynamic(false);
	m_Body->setMass(10);
	m_Body->setRotationEnable(false);
	m_Body->retain();
	setPhysicsBody(m_Body);
}
Example #6
0
void MonsterRush::knockbackTransition(Creature* target, double dTime, int idx)
{
	int time = GET_GAME_MANAGER()->getMicroSecondTime();


	//임시 지정
	if (time - m_KnockbackStartTime > 1000)
	{
		setState(idx, STAT_IDLE);
	}
}
bool SteamDeathEffect::init()
{
	if (!Effect::init())
	{
		return false;
	}

	m_StartTime = GET_GAME_MANAGER()->getMicroSecondTime();
	GET_SOUND_MANAGER()->allStopSound();
	GET_SOUND_MANAGER()->createSound(SoundManager::PLAYER_DEAD, false);

	return true;
}
Example #8
0
bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLView::create("My Game");
        director->setOpenGLView(glview);
    }

	glview->setDesignResolutionSize(960, 540, ResolutionPolicy::SHOW_ALL);
    //director->setDisplayStats(true);
    director->setAnimationInterval(1.0 / 60);
	GET_GAME_MANAGER()->changeScene(SceneType::TITLE_SCENE);

    return true;
}
Example #9
0
void BombMissile::update(float dTime)
{
	int nowTime = GET_GAME_MANAGER()->getMicroSecondTime();

	if (!m_IsPhysics)
	{
		setEnabled(false);
		m_IsPhysics = true;
	}

	if (nowTime - m_StartTime > SUSTAINMENT_TIME)
	{
		//미사일 완전 삭제
		m_IsDead = true;
		
	}
}
Example #10
0
void StageManager::playerDead()
{
	if(m_GameScene == nullptr)
	{
		return;
	}
	auto layer = m_GameScene->getGameLayer();
	if(layer == nullptr)
	{
		return;
	}
	//layer->exit();
	GET_SOUND_MANAGER()->allStopSound();
	GET_DATA_MANAGER()->setPlayerInfo(getPlayer()->getInfo());
	GET_DATA_MANAGER()->saveGameData();
	GET_GAME_MANAGER()->changeScene(ASSEMBLY_SCENE);
}
Example #11
0
void BladeMissile::setAttribute(cocos2d::Point pos, Direction attackDir /*= DIR_NONE*/, float damage /*= 0*/, cocos2d::Size contentsSize /*= cocos2d::Size::ZERO*/, cocos2d::Vec2 velocity /*= cocos2d::Point::ZERO*/, cocos2d::Point targetPos /*= cocos2d::Point::ZERO*/)
{
    GET_SOUND_MANAGER()->createSound(SoundManager::BLADEMISSILE, false);
    m_IsDead = false;
    m_IsUsable = false;
    m_IsPlayerMissile = true;
    m_Damage = damage;
    m_AttackDir = attackDir;
    m_TargetSize = contentsSize;
    m_StartTime = GET_GAME_MANAGER()->getMicroSecondTime();
    m_State = MST_NONE;

    m_Sprite = GET_RESOURCE_MANAGER()->createSprite(ST_PLAYER_ATTACK);
    auto fadeIn = cocos2d::FadeIn::create(SUSTAINMENT_TIME / 4000.f);
    auto delay = cocos2d::DelayTime::create(SUSTAINMENT_TIME / 2000.f);
    auto fadeOut = cocos2d::FadeOut::create(SUSTAINMENT_TIME / 4000.f);
    auto sequence = cocos2d::Sequence::create(fadeIn, delay, fadeOut, nullptr);

    if (m_AttackDir == DIR_LEFT)
    {
        setPosition(cocos2d::Point(pos.x - contentsSize.width, pos.y));
    }
    else
    {
        m_Sprite->setFlippedX(true);
        setPosition(cocos2d::Point(pos.x + contentsSize.width, pos.y));
    }
    addChild(m_Sprite);

    m_Sprite->runAction(sequence);


    auto meterial = cocos2d::PhysicsMaterial(0, 0, 0);
    m_Body = cocos2d::PhysicsBody::createBox(m_Sprite->getContentSize(), meterial);
    m_Body->setContactTestBitmask(PHYC_MONSTER);
    m_Body->setCategoryBitmask(PHYC_MISSILE);
    m_Body->setCollisionBitmask(PHYC_MONSTER);
    m_Body->setTag(static_cast<int>(getType()));
    m_Body->setGravityEnable(false);
    m_Body->setMass(10);
    m_Body->setRotationEnable(false);
    m_Body->retain();
    setPhysicsBody(m_Body);
}
Example #12
0
void UILayer::update( float dTime )
{
    m_CurrentScene = GET_GAME_MANAGER()->getCurrentSceneType();
    if (m_CurrentScene == TITLE_SCENE)
    {
        m_TitleUILayer->update(dTime);
    }
    else if (m_CurrentScene == LOADING_SCENE)
    {
        m_LodingUILayer->update(dTime);
    }
    else if (m_CurrentScene == ASSEMBLY_SCENE)
    {
        m_AssemblyUILayer->update(dTime);
    }
    else if (m_CurrentScene == GAME_SCENE)
    {
        m_GameUILayer->update(dTime);

    }
}
Example #13
0
void HpBar::update(float dTime)
{
	if(GET_GAME_MANAGER()->isGamePlaying())
	{
		if(m_Subject == nullptr)
		{
			return;
		}

		float maxHp = m_Subject->getMaxHp();
		float curHp = m_Subject->getCurHp();

		if(maxHp < 0.001f || maxHp < curHp)
		{
			return;
		}

		m_Percent = curHp / maxHp * 100.f;
		m_ProgressBar->setPercentage(m_Percent);
	}
}
Example #14
0
void LaserTrap::update(float dTime)
{
	if(m_IsOn)
	{
		m_AccTime += dTime;
		if(m_AccTime > m_Duration)
		{
			m_AccTime = 0.f;
			m_IsOn = false;
			switchTurn(m_IsOn);
		}
	}
	else
	{
		auto time = GET_GAME_MANAGER()->getTime();
		if((time.tv_sec) % MAX_INTERVAL == m_Interval - 1 )
		{
			m_IsOn = true;
			GET_SOUND_MANAGER()->createSound(SoundManager::LASERTRAP, false, getPosition());
			switchTurn(m_IsOn);
		}
	}
}
Example #15
0
bool MonsterRush::onContactBegin(cocos2d::PhysicsContact& contact)
{
	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;

	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}

	//미사일이랑 충돌 처리
	if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
	{
		Missile* missile = static_cast<Missile*>(enemyComponent);

		//수류탄은 뎀 안 입음
		if (missile->getType() == OT_MISSILE_GRENADE)
		{
			return false;
		}

		//몹이 쏜 건 안 맞음.
		if (!missile->isPlayerMissile())
		{
			return false;
		}

		float damage = missile->getDamage();

		m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);

		//미사일에 의한 상태 이상 처리

		if (missile->getState() == Missile::MST_KNOCKBACK)
		{
			GET_SOUND_MANAGER()->createSound(SoundManager::PIG, false);
			m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
			if (missile->getAttackDir() == DIR_LEFT)
			{
				CommonState::enterKnockback(this, DIR_LEFT);
			}
			else
			{
				CommonState::enterKnockback(this, DIR_RIGHT);
			}

			setState(0,STAT_KNOCKBACK);
		}
		else if (missile->getState() == Missile::MST_BIND)
		{
			m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
			getPhysicsBody()->setVelocity(cocos2d::Vect(0, 0));
			setState(0,STAT_KNOCKBACK);
		}

		//사망
		if (m_Info.m_CurrentHp <= 0)
		{
			m_IsDead = true;
		}
	}

	//플레이어랑 부딪친 경우 이펙트 생성
	if (enemyComponent->getType() == OT_PLAYER)
	{
		GET_EFFECT_MANAGER()->createEffect(ET_PUNCH_MISSILE, enemyComponent->getPosition())->enter();
	}
	return true;
}
Example #16
0
void TitleScene::menuStartCallback(cocos2d::Ref* pSender)
{
	GET_GAME_MANAGER()->gameStart();
}
Example #17
0
bool StageManager::init()
{
	auto scene = GET_GAME_MANAGER()->getScene(GAME_SCENE);
	m_GameScene = static_cast<GameScene*>( scene->getChildByTag(GAME_SCENE_TAG) );
	return true;
}