Esempio n. 1
0
Command* CommandSkill::createBullet(SkillResult* result)
{
	CommandParallel* cmds = CommandParallel::create();
	for (int i = 0; i < result->numRecipients; i++)
	{
		CommandSequence * seq = CommandSequence::create();
		CommandSkill* skill = new CommandSkill();
		skill->addEffect(BulletEffect::create(result->skill.effect, result->giver, result->recipients[i]));
		seq->push(skill, false);
		CommandHit* hit = CommandHit::create(result->recipients[i]);
		seq->push(hit, false);
		Actor* victim = Engine::world->getActor(result->recipients[i]);
		if (result->value[i] != 0)
		{
			CommandProgress* progress = CommandProgress::create(result->value[i], victim);
			seq->push(progress, false);
		}
		
		if (result->healthLeft[i] <= 0)
		{
			CommandDie* die = CommandDie::create(victim);
			seq->push(die, false);
		}
		cmds->addCommand(seq);
		
	}
	return cmds;
}
Esempio n. 2
0
Command* CommandBuff::create(BuffResult* result)
{
	CommandSequence * seq = CommandSequence::create();
	//to do implement command buff
	Actor* owner = Engine::world->getActor(result->owner);
	CommandProgress* progress = CommandProgress::create(result->value, owner);
	seq->push(progress, false);
	return seq;
}
Esempio n. 3
0
Command* CommandSkill::createArc(SkillResult* result)
{
	CommandParallel * cmds = CommandParallel::create();
	for (int i = 0; i < result->numRecipients; i++)
	{
		CommandSequence* seq = CommandSequence::create();
		CommandSkill* skill = new CommandSkill();
		skill->addEffect(ArcEffect::create(result->skill.effect, result->giver, result->recipients[i]));
		seq->push(skill, false);
		CommandHeal* heal = CommandHeal::create(result->recipients[i]);
		seq->push(heal, false);
		if (result->value != 0)
		{
			Actor* victim = Engine::world->getActor(result->recipients[i]);
			CommandProgress* progress = CommandProgress::create(result->value[i], victim);
			seq->push(progress,false);
		}
		cmds->addCommand(seq);
	}
	return cmds;
}
Esempio n. 4
0
Command* CommandSkill::createHack(SkillResult* result)
{
	CommandSequence *seq = CommandSequence::create();
	CommandSkill* skill = new CommandSkill();
	skill->addEffect(HackEffect::create(result->skill.effect, result->giver, result->recipients[0]));
	seq->push(skill, false);
	CommandHit* hit = CommandHit::create(result->recipients[0]);
	seq->push(hit, false);
	Actor* victim = Engine::world->getActor(result->recipients[0]);
	if (result->value != 0)
	{
		CommandProgress* progress = CommandProgress::create(result->value[0], victim);
		seq->push(progress, false);
	}
	
	if (result->healthLeft[0] <= 0)
	{
		CommandDie* die = CommandDie::create(victim);
		seq->push(die, false);
	}
	
	return seq;
}
Esempio n. 5
0
Command* CommandSkill::createFixed(SkillResult* result)
{
	CommandParallel* cmds = CommandParallel::create();

	CommandSkill* skill = new CommandSkill();
	
	Actor* attacker = Engine::world->getActor(result->giver);

	for (int i = 0; i < result->skill.range2.numGSets; i++)
	{
		ID cid = result->skill.range2.gSets[i];
		GSet path;
		Config::skill->fill(&path, cid);
		FrisbeeEffect* fEffect = FrisbeeEffect::create(result->skill.effect, attacker->position());
		bool flag = false;
		CommandSequence* seq = NULL;
		float interval = 0;
		
		for (int j = 0; j < path.numElements; j++)
		{
			char ox = path.elements[j].x; 
			char oy = path.elements[j].y;
			
			bool needbreak = false;
			interval += .1f;
			Actor* actor = Engine::world->getActor(ccp(ox * GRID_SIZE + attacker->position()->x, oy * GRID_SIZE + attacker->position()->y));
			for (int k = 0; k < result->numRecipients; k++)
			{
				if (actor != NULL && result->recipients[k] == actor->iid() && result->set[k] == i)
				{
					flag = true;
					if (actor->isBarrier())
					{
						seq = CommandSequence::create();
						CommandWait* wait = CommandWait::create(interval);
						CommandHit* hit = CommandHit::create(actor->iid());
						seq->push(wait, false);
						seq->push(hit, false);
						fEffect->addNode(ox, oy);
						needbreak = true;
					}
					else
					{
						seq = CommandSequence::create();
						CommandWait* wait = CommandWait::create(interval);
						CommandHit* hit = CommandHit::create(actor->iid());
						seq->push(wait, false);
						seq->push(hit, false);
						CommandProgress* progress = CommandProgress::create(result->value[k], actor);
						seq->push(progress, false);
					}

					if (result->healthLeft[k] <= 0)
					{
						CommandDie* die = CommandDie::create(actor);
						seq->push(die, false);
					}

					cmds->addCommand(seq);
				}
			}
			if (attacker->getData()->positon.x + ox > NUM_GRIDS_ROW) needbreak = true;
			if (attacker->getData()->positon.x + ox < 0) needbreak = true;
			if (needbreak) break;
			fEffect->addNode(ox, oy);
		}
		skill->addEffect(fEffect);
	}
	cmds->addCommand(skill);
	return cmds;
}