Exemplo n.º 1
0
// Get the next free weapon of this 'type'
Weapon* SimpleStoresMgr::getSpecificWeapon(const std::type_info& type)
{
   Weapon* wpn = 0;
   if (&type != 0) {

      Basic::PairStream* list = getWeapons();
      if (list != 0) {

         // Find the first free (inactive) bomb
         Basic::List::Item* item = list->getFirstItem();
         while (item != 0 && wpn == 0) {
            Basic::Pair* pair = (Basic::Pair*)(item->getValue());
            Weapon* p = dynamic_cast<Weapon*>( pair->object() );
            if (p != 0 && p->isInactive() && p->isClassType(type)) {
               p->ref();
               wpn = p;
            }
            item = item->getNext();
         }

         list->unref();
      }

   }
   return wpn;
}
Exemplo n.º 2
0
Bomb* SimpleStoresMgr::getNextBombImp()
{
   Bomb* bomb = nullptr;

   base::PairStream* list = getWeapons();
   if (list != nullptr) {

      // find the first free (inactive) bomb
      base::List::Item* item = list->getFirstItem();
      while (item != nullptr && bomb == nullptr) {
         base::Pair* pair = static_cast<base::Pair*>(item->getValue());
         Bomb* p = dynamic_cast<Bomb*>(pair->object());
         if (p != nullptr) {
            if (p->isInactive() || p->isReleaseHold()) {
               bomb = static_cast<Bomb*>(p->getPointer());
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return bomb;
}
Exemplo n.º 3
0
Flare* SimpleStoresMgr::getNextFlareImp()
{
   Flare* flare = nullptr;

   base::PairStream* list = getWeapons();
   if (list != nullptr) {

      // find the first free (inactive) flare
      base::List::Item* item = list->getFirstItem();
      while (item != nullptr && flare == nullptr) {
         base::Pair* pair = static_cast<base::Pair*>(item->getValue());
         Flare* p = dynamic_cast<Flare*>(pair->object());
         if (p != nullptr) {
            if (p->isInactive() || p->isReleaseHold()) {
               flare = static_cast<Flare*>(p->getPointer());
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return flare;
}
Exemplo n.º 4
0
Chaff* SimpleStoresMgr::getNextChaffImp()
{
   Chaff* chaff = nullptr;

   base::PairStream* list = getWeapons();
   if (list != nullptr) {

      // find the first free (inactive) chaff bundle
      base::List::Item* item = list->getFirstItem();
      while (item != nullptr && chaff == nullptr) {
         base::Pair* pair = static_cast<base::Pair*>(item->getValue());
         Chaff* p = dynamic_cast<Chaff*>(pair->object());
         if (p != nullptr) {
            if (p->isInactive() || p->isReleaseHold()) {
               chaff = static_cast<Chaff*>(p->getPointer());
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return chaff;
}
Exemplo n.º 5
0
Decoy* SimpleStoresMgr::getNextDecoyImp()
{
   Decoy* decoy = nullptr;

   base::PairStream* list = getWeapons();
   if (list != nullptr) {

      // find the first free (inactive) decoy
      base::List::Item* item = list->getFirstItem();
      while (item != nullptr && decoy == nullptr) {
         base::Pair* pair = static_cast<base::Pair*>(item->getValue());
         Decoy* p = dynamic_cast<Decoy*>( pair->object() );
         if (p != nullptr) {
            if (p->isInactive() || p->isReleaseHold()) {
               decoy = static_cast<Decoy*>(p->getPointer());
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return decoy;
}
Exemplo n.º 6
0
// Get the next free missile of type 'missileType'
Missile* SimpleStoresMgr::getSpecificMissile(const base::String* const missileType)
{
   Missile* msl = nullptr;
   if (missileType != nullptr) {

      base::PairStream* list = getWeapons();
      if (list != nullptr) {

         // Find the first free (inactive) missile of type weaponType
         base::List::Item* item = list->getFirstItem();
         while (item != nullptr && msl == nullptr) {
            base::Pair* pair = static_cast<base::Pair*>(item->getValue());
            Missile* p = dynamic_cast<Missile*>(pair->object());
            if (p != nullptr && p->isInactive()) {
               // Ok, we have a missile, but is it the type we want?
               if (*p->getType() == *missileType) {
                  p->ref();
                  msl = p;
               }
            }
            item = item->getNext();
         }

         list->unref();
      }

   }
   return msl;
}
Exemplo n.º 7
0
// Get the next free bomb of type 'bombType'
Bomb* SimpleStoresMgr::getSpecificBomb(const base::String* const bombType)
{
   Bomb* bomb = nullptr;
   if (bombType != nullptr)  {

      base::PairStream* list = getWeapons();
      if (list != nullptr)  {

         // Find the first free (inactive) bomb
         base::List::Item* item = list->getFirstItem();
         while (item != nullptr && bomb == nullptr) {
            base::Pair* pair = static_cast<base::Pair*>(item->getValue());
            Bomb* p = dynamic_cast<Bomb*>(pair->object());
            if (p != nullptr && p->isInactive()) {
               // Ok, we have a bomb, but is it the type we want?
               if (*p->getType() == *bombType) {
                  p->ref();
                  bomb = p;
               }
            }
            item = item->getNext();
         }

         list->unref();
      }

   }
   return bomb;
}
Exemplo n.º 8
0
Sam* SimpleStoresMgr::getNextSamImp()
{
   Sam* msl = nullptr;

   base::PairStream* list = getWeapons();
   if (list != nullptr) {

      // find the first free (inactive) SAM
      base::List::Item* item = list->getFirstItem();
      while (item != nullptr && msl == nullptr) {
         base::Pair* pair = static_cast<base::Pair*>(item->getValue());
         Sam* p = dynamic_cast<Sam*>(pair->object());
         if (p != nullptr) {
            if (p->isInactive() || p->isReleaseHold()) {
               msl = static_cast<Sam*>(p->getPointer());
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return msl;
}
Exemplo n.º 9
0
//------------------------------------------------------------------------------
// Default weapons reload event handler
//------------------------------------------------------------------------------
bool StoresMgr::onWpnReload()
{
   // Reset the weapons only
   Basic::PairStream* list = getWeapons();
   if (list != 0) {
      resetStores(list);
      list->unref();
      list = 0;
   }
   return true;
}
Exemplo n.º 10
0
//------------------------------------------------------------------------------
// Default weapons reload event handler
//------------------------------------------------------------------------------
bool StoresMgr::onWpnReload()
{
   // Reset the weapons only
   base::PairStream* list = getWeapons();
   if (list != nullptr) {
      resetStores(list);
      list->unref();
      list = nullptr;
   }
   return true;
}
Exemplo n.º 11
0
/// <summary>
/// When this fighter died, he will give some item and some gold to the fighter who killed him.
/// </summary>
void Enemy::onDeath(Fighter &player)
{
	m_drop->addGold(Randomiser(1,10).getRandomNumber() * getLevel());

	if (Randomiser(1, 15).getRandomNumber() == Randomiser(1, 15).getRandomNumber())
	{
		m_drop->addWeapon(getWeapons());
	}
	if (Randomiser(1, 15).getRandomNumber() == Randomiser(1, 15).getRandomNumber())
	{
		m_drop->addArmor(getArmor());
	}

	player.setDrop(*m_drop);
	player.setExperiencePoints(m_experiencePoints + player.getExperiencePoints());
}
Exemplo n.º 12
0
Missile* SimpleStoresMgr::getNextMissileImp()
{
   Missile* msl = 0;

   Basic::PairStream* list = getWeapons();
   if (list != 0) {

      Basic::List::Item* item = list->getFirstItem();
      while (item != 0 && msl == 0) {
         Basic::Pair* pair = (Basic::Pair*) item->getValue();
         Missile* p = dynamic_cast<Missile*>( pair->object() );
         if (p != 0) {
            if (p->isInactive() || p->isReleaseHold()) {
               msl = (Missile*) p->getPointer();
            }
         }
         item = item->getNext();
      }
      list->unref();
   }

   return msl;
}
Exemplo n.º 13
0
Bomb* SimpleStoresMgr::getNextBombImp()
{
   Bomb* bomb = 0;

   Basic::PairStream* list = getWeapons();
   if (list != 0) {

      Basic::List::Item* item = list->getFirstItem();
      while (item != 0 && bomb == 0) {
         Basic::Pair* pair = (Basic::Pair*) item->getValue();
         Bomb* p = dynamic_cast<Bomb*>( pair->object() );
         if (p != 0) {
            if (p->isInactive() || p->isReleaseHold()) {
               bomb = (Bomb*) p->getPointer();
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return bomb;
}
Exemplo n.º 14
0
Chaff* SimpleStoresMgr::getNextChaffImp()
{
   Chaff* chaff = 0;

   Basic::PairStream* list = getWeapons();
   if (list != 0) {

      Basic::List::Item* item = list->getFirstItem();
      while (item != 0 && chaff == 0) {
         Basic::Pair* pair = (Basic::Pair*) item->getValue();
         Chaff* p = dynamic_cast<Chaff*>( pair->object() );
         if (p != 0) {
            if (p->isInactive() || p->isReleaseHold()) {
               chaff = (Chaff*) p->getPointer();
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return chaff;
}
Exemplo n.º 15
0
Flare* SimpleStoresMgr::getNextFlareImp()
{
   Flare* flare = 0;

   Basic::PairStream* list = getWeapons();
   if (list != 0) {

      Basic::List::Item* item = list->getFirstItem();
      while (item != 0 && flare == 0) {
         Basic::Pair* pair = (Basic::Pair*) item->getValue();
         Flare* p = dynamic_cast<Flare*>( pair->object() );
         if (p != 0) {
            if (p->isInactive() || p->isReleaseHold()) {
               flare = (Flare*) p->getPointer();
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return flare;
}
Exemplo n.º 16
0
Decoy* SimpleStoresMgr::getNextDecoyImp()
{
   Decoy* decoy = 0;

   Basic::PairStream* list = getWeapons();
   if (list != 0) {

      Basic::List::Item* item = list->getFirstItem();
      while (item != 0 && decoy == 0) {
         Basic::Pair* pair = (Basic::Pair*) item->getValue();
         Decoy* p = dynamic_cast<Decoy*>( pair->object() );
         if (p != 0) {
            if (p->isInactive() || p->isReleaseHold()) {
               decoy = (Decoy*) p->getPointer();
            }
         }
         item = item->getNext();
      }

      list->unref();
   }

   return decoy;
}
Exemplo n.º 17
0
//////////////////////////////////////////////////////////////////////////
// getWeapons
std::vector< class GaWeaponComponent* > GaRobotComponent::getWeapons( MaVec3d Position, BcF32 Radius )
{
	auto WorldComponent = getParentEntity()->getComponentAnyParentByType< GaWorldComponent >();
	return std::move( WorldComponent->getWeapons( Position, Radius ) );
}
Exemplo n.º 18
0
bool BaseAI::startTurn()
{
  int count = 0;
  count = getWallCount();
  walls.clear();
  walls.resize(count);
  for(int i = 0; i < count; i++)
  {
    walls[i] = Wall(getWalls()+i);
  }
  count = getCrateCount();
  crates.clear();
  crates.resize(count);
  for(int i = 0; i < count; i++)
  {
    crates[i] = Crate(getCrates()+i);
  }
  count = getWeaponCount();
  weapons.clear();
  weapons.resize(count);
  for(int i = 0; i < count; i++)
  {
    weapons[i] = Weapon(getWeapons()+i);
  }
  count = getHumanCount();
  humans.clear();
  humans.resize(count);
  for(int i = 0; i < count; i++)
  {
    humans[i] = Human(getHumans()+i);
  }
  count = getZombieCount();
  zombies.clear();
  zombies.resize(count);
  for(int i = 0; i < count; i++)
  {
    zombies[i] = Zombie(getZombies()+i);
  }
  count = getAirstrikeCount();
  airstrikes.clear();
  airstrikes.resize(count);
  for(int i = 0; i < count; i++)
  {
    airstrikes[i] = Airstrike(getAirstrikes()+i);
  }
  count = getSpawnzoneCount();
  spawnzones.clear();
  spawnzones.resize(count);
  for(int i = 0; i < count; i++)
  {
    spawnzones[i] = Spawnzone(getSpawnzones()+i);
  }

  if(turnNum() == 1)
  {
    init();
    if(!isHuman())
    {
      return true;
     }
  }

  if(isHuman())
  {
    return runHuman();
  }
  else
  {
    return runZombie();
  }
}