void showTapeLights(void) { int v0,v1,v2; getTapeVals(&v0,&v1,&v2); if(abs(v2-v0)<30) setTeam(NO_TEAM); if(v2<v0) setTeam(RED); else setTeam(BLUE); }
void ActorFactory::createChar(Encounter* parent, PFMapCharInstance& data) { GameObject* temp = new GameObject(parent, data.pos); temp->addComponent(new ActorComponent(temp, data.id)); temp->addComponent(new RenderComponent(temp, data.sprite.first, data.sprite.second)); // Get a reference to the actor component of our new character auto actor = temp->getComponent<ActorComponent>(ComponentType::ACTOR); actor->getCharacter().getRawData().name = data.name; actor->setTeam(data.team); // Construct and equip all of the items that this character is supposed to have equipped for (auto &item : data.equipped) { auto itemInstance = PFWeaponBuilder().load( item.second.id )->build(); actor->getInventory().equippedItems().equipItem(item.first, itemInstance); } // Construct and equip all of the items that this character is supposed to have equipped for (auto &item : data.backpack) { auto itemInstance = PFWeaponBuilder().load( item.id )->build(); actor->getInventory().backpack().addItem( itemInstance ); } parent->addGameObj(temp); }
CGO_Player::CGO_Player () { ani = NULL; shadow = &a_shadow; setArea(ea_gameBoard); moveAbs(0, 0); dx = CGO_Player::dy = 3; setActive(false); setLifeState(LALIVE); setAniDirState(SSTAND, ASOUTH); setRunState(XSTAND); setColor(cred); setType(GOT_PLAYER); setName("Unnamed Player"); setTeam(TEAM_RED); dropedBombs = 0; powerups[PBOMB ] = BWBOMB; powerups[PFLAME ] = BWFLAME; powerups[PSKATE ] = BWSKATE; powerups[PKICKER ] = BWKICKER; powerups[PJELLY ] = BWJELLY; powerups[PTRIGGER ] = BWTRIGGER; powerups[PPUNCH ] = BWPUNCH; powerups[PGRAB ] = BWGRAB; powerups[PSPOOGE ] = BWSPOOGE; powerups[PGOLDFLAME] = BWGOLDFLAME; powerups[PDISEASE ] = BWDISEASE; powerups[PDISEASE3 ] = BWDISEASE3; }
void Player::setBasePlayer(const BasePlayer *initial, Team *teams[Team::MAX_COUNT]) { assert(initial); number=initial->number; numberMask=initial->numberMask; teamNumber=initial->teamNumber; teamNumberMask=initial->teamNumberMask; name = initial->name; playerID = initial->playerID; type=initial->type; setTeam(teams[this->teamNumber]); if (type>=P_AI) { ai=new AI((AI::ImplementitionID)(type-P_AI), this); } else if(type==P_NONE) { ai=NULL; } else { ai=NULL; team->type=BaseTeam::T_HUMAN; } };
//-------------------------- ctor --------------------------------------------- //----------------------------------------------------------------------------- TargetSplashSkill::TargetSplashSkill( AbstCharacter* const shooter, AbstCharacter* const target, float splash_radius, int damage, int radius, int max_speed, double survive_time, const std::string& name, int team) : AbstTargetSkill( shooter->getWorld(), target, shooter->getId(), shooter->getPos(), shooter->getHeading(), damage, radius, max_speed, 1, 10, name, SKILL, survive_time), _activated(false) { CCASSERT(target, "target == nullptr"); setTeam(team); movePos(_heading * _bounding_radius); _activate_strategy.reset(new ActivateCollisionToTarget(this)); _impact_strategy.reset(new ImpactSplash(this, shooter, splash_radius)); }
//Initializ the spaceship Spaceship::Spaceship(Type type, ResourceHolder<sf::Texture, Textures::ID>& textureHolder, SceneNode * foreground, unsigned int team) : type(type), //The type, to define the behavior sprite(textureHolder.get(spaceshipData[type].textureID)), //Initilize the sprite deltaV(spaceshipData[type].deltaV), //Initialize the deltaV maxV(spaceshipData[type].maxV), //Initialize the maxV foregroundLayer(foreground), //Initialize the foregorund pointer hp(spaceshipData[type].hp), //Initialize the hitpoints trajectory(new Trajectory()), id(maxId++) { //attach the trajectory in the scene graph attachChild(trajectory); //Set the category category = Command::Spaceship; //Center the origin sf::FloatRect bounds = sprite.getLocalBounds(); sprite.setOrigin(bounds.width/2.f, bounds.height/2.f); //Get the ID setTeam(team); //Add the weapons for(Weapon::WeaponPrototype prototype : spaceshipData[type].weapons) { Weapon * weapon = new Weapon(prototype.type, foreground, textureHolder); weapon->setRotation(prototype.rotation); weapon->setPosition(prototype.position); weapon->setTeam(team); attachChild(weapon); } }
bool Player::load(GAGCore::InputStream *stream, Team *teams[Team::MAX_COUNT], Sint32 versionMinor) { stream->readEnterSection("Player"); char signature[4]; stream->read(signature, 4, "signatureStart"); if (memcmp(signature,"PLYb",4)!=0) { fprintf(stderr, "Player::load: Signature missmatch at begin of Player\n"); stream->readLeaveSection(); return false; } // if AI, delete if (type>=P_AI) { assert(ai); delete ai; ai = NULL; } // base player bool success = BasePlayer::load(stream, versionMinor); if (!success) { fprintf(stderr, "Player::load: Error during BasePlayer load\n"); stream->readLeaveSection(); return false; } // player startPositionX = stream->readSint32("startPositionX"); startPositionY = stream->readSint32("startPositionY"); setTeam(teams[teamNumber]); if (type >= P_AI) { ai = new AI(AI::NONE, this); if (!ai->load(stream, versionMinor)) { fprintf(stderr, "Player::load: Error during AI load\n"); stream->readLeaveSection(); return false; } } else { ai = NULL; team->type = BaseTeam::T_HUMAN; } stream->read(signature, 4, "signatureEnd"); if (memcmp(signature,"PLYe",4)!=0) { fprintf(stderr, "Player::load: Signature missmatch at end of Player\n"); stream->readLeaveSection(); return false; } stream->readLeaveSection(); return true; }
Player::Player() :BasePlayer() { startPositionX=0; startPositionY=0; setTeam(NULL); ai=NULL; }
ActorInfo::ActorInfo(AEvaCharacter * character) : name(character->getName()) { setDirection(character->getDirection()); setPosition(character->getPosition()); setTeam(character->team); setWeaponType(character->currentWeapon); setHealth(character->health); setArmour(character->armour); }
BallSprite::BallSprite(const Character& obj) { setType("Ball"); setName(obj.getBallName()); setTeam(obj.getTeam()); setAttackPoint(obj.getAttackPoint()); setVelocity(obj.getBallVelocity()); setBallSize(obj.getBallSize()); }
Turret::Turret(Map* map, uint32 id, const std::string& name, float x, float y, float hp, float ad, int team) : Unit(map, id, "", new TurretStats(), 50, x, y, 1200), name(name) { stats->setCurrentHealth(hp); stats->setMaxHealth(hp); stats->setBaseAd(ad); stats->setRange(TURRET_RANGE); autoAttackDelay = 4.35f/30.f; autoAttackProjectileSpeed = 1200.f; setTeam(team); }
Player::Player(Sint32 number, const std::string& name, Team *team, PlayerType type) :BasePlayer(number, name, team->teamNumber, type) { setTeam(team); if (type>=P_AI) { ai=new AI(implementitionIdFromPlayerType(type), this); } else { ai=NULL; team->type=BaseTeam::T_HUMAN; } startPositionX = startPositionY = 0; }
FlyingSaucerBoss::FlyingSaucerBoss(): m_target(NULL), m_timer(0), m_angle(0) { setHP(400); setTexture(Resources::getTexture("entities/flying-saucer-boss.png")); setY(CIRCLE_CENTER_Y); m_left_tube.init("laser-pink"); m_left_tube.setOwner(this); m_left_tube.setPosition(34, 122); m_right_tube.init("laser-pink"); m_right_tube.setOwner(this); m_right_tube.setPosition(157, 122); setTeam(Entity::BAD); }
TentaculatBoss::TentaculatBoss(): m_state(INIT), m_timer(0.f), m_speed(-100.f, 0.f), m_target(NULL) { setTeam(Entity::BAD); setHP(300); // init weapon m_weapon.init("laser-pink"); m_weapon.setOwner(this); m_weapon.setPosition(74, 42); m_weapon.setMultiply(3); m_animator.setAnimation(*this, EntityManager::getInstance().getAnimation("boss-tentacles")); }
Player::Player(int16_t playerId, sf::Vector2f position, OutputSocket socket, char * nick) : playerId(playerId), timeSinceLastShot(sf::Time::Zero), speed(500), rotation(0), cross_thickness(5), socket(socket), health(100), playerInfo(0), ip(socket.ip), nick(nick), ammo(10), invisibleTime(sf::Time::Zero) { boundingBox = BoundingBox(position.x, position.y, 50, 50); updateCross(); horz_rect.width = boundingBox.width; vert_rect.height = boundingBox.height; type = EntityType::Player_T; setTeam(0); setValid(0); }
// Create objects from parameters stored in level file // LineItem <team> <width> <x> <y> ... bool LineItem::processArguments(S32 argc, const char **argv, Level *level) { if(argc < 6) return false; setTeam (atoi(argv[0])); setWidth(atoi(argv[1])); int firstCoord = 2; if(strcmp(argv[2], "Global") == 0) { mGlobal = true; firstCoord = 3; } else mGlobal = false; readGeom(argc, argv, firstCoord, level->getLegacyGridSize()); updateExtentInDatabase(); return true; }
//-------------------------- ctor --------------------------------------------- //----------------------------------------------------------------------------- SplashContinuousSkill::SplashContinuousSkill( AbstCharacter* const shooter, cocos2d::Vec2 target_pos, double period, int damage, int radius, int max_speed, double survive_time, float splash_radius, const std::string& name, int team) : AbstNonTargetSkill( shooter->getWorld(), target_pos, shooter->getId(), target_pos, shooter->getHeading(), damage, radius, max_speed, 1, 10, name, SKILL, survive_time), _activated(false), _target_pos(target_pos), _splash_radius(splash_radius), _period(period) { setTeam(team); setPos(_target_pos); _activate_strategy.reset(new ActivateContinuous(this, shooter, _period, _survive_time)); _impact_strategy.reset(new ImpactContinuousSplash(this, shooter, splash_radius)); }
bool TeamSelectHandler::execute(GameNet::Box * box) { CCLOG("TEAM_SELECT: %s", box->getData().c_str()); int id = box->getId(); std::string team = box->getData(); auto player = game->getPlayer(id); // auto assign if(team.compare(TEAM_AUTO) == 0) { team = game->getAutoTeam(); } if(player != nullptr) { player->setTeam(team); // show player in the game player->getSprite()->setVisible(true); player->getSprite()->getPhysicsBody()->setEnabled(true); } return false; }
MultiPartEntity::MultiPartEntity() { setTeam(Entity::NEUTRAL); }
Player::Player(): m_panel(ControlPanel::getInstance()), m_overheat(false), m_heat(0.f), m_max_heat(0.f), m_shield(0), m_max_shield(0), m_max_hp(0), m_speed(0.f), m_missiles(0), m_icecubes(0), // Preload animations m_animation_up(EntityManager::getInstance().getAnimation("player-up")), m_animation_down(EntityManager::getInstance().getAnimation("player-down")), m_animation_normal(EntityManager::getInstance().getAnimation("player")), m_score(0) { setTeam(Entity::GOOD); setHP(1); // Init sprite texture m_animator.setAnimation(*this, m_animation_normal); // Init weapons int xweapon = 54, yweapon = 24; m_weapon.init("laser-red"); m_weapon.setOwner(this); m_weapon.setPosition(xweapon, yweapon); m_missile_launcher.init("missile"); m_missile_launcher.setOwner(this); m_missile_launcher.setPosition(xweapon, yweapon); // Init timed bonus for (int i = 0; i < TIMED_BONUS_COUNT; ++i) { bonus_[i] = 0.f; } // Init control panel m_panel.setIcecubes(m_icecubes); m_panel.setMissiles(m_missiles); m_panel.setOverheat(m_overheat); m_panel.activeSpeedPowerUp(0); m_panel.activeAttackPowerUp(0, PowerUp::DOUBLE_SHOT); // Init Konami code sequence m_konami_code[0] = Action::UP; m_konami_code[1] = Action::UP; m_konami_code[2] = Action::DOWN; m_konami_code[3] = Action::DOWN; m_konami_code[4] = Action::LEFT; m_konami_code[5] = Action::RIGHT; m_konami_code[6] = Action::LEFT; m_konami_code[7] = Action::RIGHT; m_konami_code[8] = Action::USE_MISSILE; m_konami_code[9] = Action::USE_LASER; m_current_konami_index = 0; m_konami_code_activated = false; // Init particles emitters m_shield_emitter.setTextureRect(sf::IntRect(40, 0, 8, 8)); m_shield_emitter.setLifetime(0); m_smoke_emitter.setTextureRect(sf::IntRect(0, 0, 16, 16)); m_smoke_emitter.setLooping(true); m_smoke_emitter.setSpeed(50, 25); m_smoke_emitter.setLifetime(1.5); m_smoke_emitter.setAngle(-math::PI, 0.5); m_smoke_emitter.setScale(0.5, 1.5); m_snowflakes_emitter.setTextureRect(sf::IntRect(16, 0, 16, 16)); m_snowflakes_emitter.setScale(0.2, 1.5); m_powerup_emitter.setTextureRect(sf::IntRect(32, 0, 8, 8)); }
bool BattleSquad::init(std::string srcpath, int team, int unitnum, int x, int y, int d) { if(!Squad::init(srcpath)) return false; DataLibrary *datalib = DataLibrary::getSingletonPtr(); setTeam(team); setGridX(x); setGridY(y); setDirection(d); setUnitNum(unitnum); int squadtype2; datalib->getData(srcpath + std::string("/Type"), squadtype2); if(squadtype2 == SQUAD_NORMAL) { setUnitMaxNum(unitnum); setFormation(Line); } else { setUnitMaxNum(20); setFormation(Loose); } float covert; covert = getAttr(ATTR_COVERT, ATTRCALC_FULL); if(covert > 0.0f) { switch(getFaction()) { case 0: setViewbyPlayer(1); setViewbyEnemy1(0); setViewbyEnemy2(0); setViewbyEnemy3(0); break; case 1: setViewbyPlayer(0); setViewbyEnemy1(1); setViewbyEnemy2(0); setViewbyEnemy3(0); break; case 2: setViewbyPlayer(0); setViewbyEnemy1(0); setViewbyEnemy2(1); setViewbyEnemy3(0); break; case 3: setViewbyPlayer(0); setViewbyEnemy1(0); setViewbyEnemy2(0); setViewbyEnemy3(1); break; } } else { setViewbyPlayer(1); setViewbyEnemy1(1); setViewbyEnemy2(1); setViewbyEnemy3(1); } setAmbushPlayer(0); setAmbushEnemy1(0); setAmbushEnemy2(0); setAmbushEnemy3(0); setActionPoint(0.0f); setAPSetup(0.0f); setAPBattle(0.0f); return true; }