コード例 #1
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateWeapon(const Weapon::WeaponInfo& info, Player* owner, Unit* unit)
{
    auto weapon = Weapon::create();
    weapon->SetDef(info);
    weapon->SetOwner(owner);
    weapon->SetIcon(info.m_IconImage);
    this->addChild(weapon);

    unit->PushWeapon(weapon);
}
コード例 #2
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateUnit(const Vec2& pos, Player* owner, const Unit::UnitInfo& info)
{
    auto unit = Mob::create();
    unit->SetDef(info);
    unit->SetOwner(owner);
    unit->setPosition(Vec2(pos.x, pos.y + unit->getContentSize().height / 2));
    unit->setScale(0.5f);
    unit->Move();
    this->addChild(unit);

    m_UnitList.pushBack(unit);
}
コード例 #3
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateOven(const Vec2& pos, Player* owner)
{
    Unit::DefInfo info;
    info.m_ImageName = PATH_IMAGE_CASTLE;
    info.m_CurHp = info.m_MaxHp = 300;
    info.m_Damage = 1000;
    info.m_MoveSpeed = 0.0f;

    auto oven = Oven::create();
    oven->SetDef(info);
    oven->SetOwner(owner);
    oven->setPosition(Vec2(pos.x, pos.y + oven->getContentSize().height / 2 + 3.0f));
    this->addChild(oven);
}
コード例 #4
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateLaser(const cocos2d::Vec2& pos, Player* owner, const Weapon::WeaponInfo& info, Unit::Direction dir)
{
    auto speed = info.m_Speed;
    if (dir == Unit::DIR_LEFT)
        speed = -speed;

    auto physicsLayer = this->getParent();
    auto layerPos = physicsLayer->getPositionX();

    auto missile = Laser::create();
    missile->SetDef(info.m_DefInfo);
    missile->SetOwner(owner);
    missile->setPosition(Vec2(pos.x - layerPos, pos.y));
    missile->setScale(info.m_Size);
    missile->getPhysicsBody()->setVelocity(Vec2(speed, 0));
    this->addChild(missile);
}
コード例 #5
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateHero(const cocos2d::Vec2& pos, Player* owner)
{
    Hero::UnitInfo info;
    info.m_DefInfo.m_ImageName = PATH_IMAGE_UNIT_B;
    info.m_DefInfo.m_CurHp = info.m_DefInfo.m_MaxHp = 100;
    info.m_DefInfo.m_Damage = 10;
    info.m_DefInfo.m_MoveSpeed = 250.0f;
    info.m_Direction = Unit::DIR_LEFT;
    info.m_State = Unit::US_STANDBY;

    auto hero = Hero::create();
    hero->SetDef(info);
    hero->SetOwner(owner);
    hero->setPosition(Vec2(pos.x, pos.y + hero->getContentSize().height / 2));
    this->addChild(hero);

    m_Hero = hero;
    CreateWeaponDefault(hero);
}
コード例 #6
0
ファイル: ObjectLayer.cpp プロジェクト: dlakwwkd/WeaponCook
void ObjectLayer::CreateSpaceShip(const cocos2d::Vec2& pos, const Unit::UnitInfo& info)
{
    static int n = 0;
    Unit::DefInfo defInfo;
    defInfo.m_ImageName = PATH_IMAGE_SPACE_SHIP2;
    defInfo.m_CurHp = defInfo.m_MaxHp = 100 + 2*n++;
    defInfo.m_Damage = 0;
    defInfo.m_MoveSpeed = 0.0f;

    auto ship = SpaceShip::create();
    ship->SetDef(defInfo);
    ship->SetOwner(GET_GAME_SCENE->GetEnemy());
    ship->setPosition(Vec2(pos.x, pos.y - ship->getContentSize().height / 2));
    ship->setScale(0.5f);
    this->addChild(ship);

    ship->PushUnit(info);

    GET_GM->CallFuncAfter(3.0f, ship, &SpaceShip::CreateUnit);
}
コード例 #7
0
ファイル: CityGate.cpp プロジェクト: ueverything/mmo-resourse
BOOL CGate::InitProperty(CGateList::tagGate *p)
{
	SetName(p->cName);//名字
	SetLenth(p->wLenth);//长		
	SetWidth(p->wWidth);//宽
	SetLevel(p->wLevel);//等级
	SetGraphicsID(p->dwModelId);//模型ID
	SetMaxHP(p->wMaxHp);//最大HP
	SetHP(p->wMaxHp);	//当前HP
	SetUnAttack(p->bIsunbeatable);//是否无敌
	SetBlockType(p->byBlockType);//阻挡类型
	SetDef(p->lDef);//物防	
	SetMagicDef(p->lMagicDef);//魔防
	SetNameColor(p->wNameColor);//名字颜色
	SetHitSound(string(p->cHitSound));//击中音效
	SetDestorySound(string(p->cDestorySound));//损毁音效
	SetOpenSound(string(p->cOpenSound));//打开音效
	SetCloseSound(string(p->cCloseSound));//关闭音效
	return TRUE;
}
コード例 #8
0
bool JoystickController::init(const int observed_state_dim, const int action_dim, double deltat, const char *fname, const char* chapter)
{

  joydev		= "/dev/input/js1";
  rumbdev		= "/dev/input/event7";
  udim			= action_dim;
  odim			= observed_state_dim;

  xwork			= SetDef();

  fail_controller	= 0;
  fail_controller_name	= "";
  fail_controller_fname = fname;
  fail_controller_active = false;

  for (int i=0; i<MAX_CONTROLLER; i++) {
    aux_controller[i]		= 0;
    aux_controller_name[i]	= "";
    aux_controller_fname[i]	= fname;
    aux_controller_button[i]	= i;
    aux_controller_active[i]	= false;
  }

  if (!read_options(fname, chapter==0 ? "Controller" : chapter)) {
    EOUT("in reading options.");
    return false;
  }

  if (fail_controller_name!="") {
    fail_controller = ControllerFactory::getTheControllerFactory()->create(fail_controller_name.c_str());
    if (fail_controller == 0) {
      EOUT ("No implementation found for Controller (" <<  fail_controller_name << ")!");
      return false;
    }
    if (!fail_controller->init(observed_state_dim,
                               action_dim,
                               deltat,
                               fail_controller_fname.c_str())) {
      EOUT("Can not init fail_controller");
      return false;
    }
  }

  for (int i=0; i<MAX_CONTROLLER; i++) {
    if (aux_controller_name[i]!="") {
      aux_controller[i] = ControllerFactory::getTheControllerFactory()->create(aux_controller_name[i].c_str());
      if (aux_controller[i] == 0) {
        EOUT ("No implementation found for Controller (" <<  aux_controller_name[i] << ")!");
        return false;
      }
      if (!aux_controller[i]->init(observed_state_dim,
                                   action_dim,
                                   deltat,
                                   aux_controller_fname[i].c_str())) {
        EOUT("Can not init aux_controller" << i+1);
        return false;
      }
      IOUT("Inited aux_controller" << i+1 << " " << aux_controller_name[i]);
    }
  }

  joy = 0;
  try {
    joy = new Joystick(joydev.c_str());
  } catch (std::exception& e) {
    joy = 0;
    EOUT("No Joystick available ... on " << joydev << " : " << e.what());
    return false;
  }

  rumb = new Rumble(rumbdev.c_str());

  return true;
}