Exemple #1
0
void		Drone::Hello()
{
  std::string   tmp = this->net.getmsg();
  this->net.putmsg(this->team.name + "\n");
  tmp = this->net.getmsg();
  if (tmp == "NO SUCH TEAM\n")
    throw My_Exception("Drone: error: no such team.");
  else if (tmp.find("ko") != std::string::npos)
    throw My_Exception("Drone: error: can't connect in this team.");
  this->team.slots = translate<std::string, int>(tmp);
  if (tmp.find("\n") + 1 == tmp.size())
    this->net.getmsg();
}
void PrefabWithCollider_Plant::_setInaccurateCollider( const wstring & attribute, const wstring & value )
{
	if (attribute == PrefabPlant::closeNode)
	{
		if (prefabWithCollider == NULL)
		{
			throw My_Exception("PrefabWithCollider setCollider: Can't add Collider into nonexistent prefab");
		}
		prefabWithCollider->setInaccurateCollider(Collider_str);
		clearCollider();
	} else
	{
		throw My_Exception("PrefabWithCollider _setCollider: Missing attribute type");
	}
}
void PrefabWithMesh_Plant::_setRotation( const wstring & attribute, const wstring & value )
{
	static rotation_struct rot;
	if (attribute == x_rot)
	{
		rot.x_rot = ValueToDouble(value);
	} else if (attribute == y_rot)
	{
		rot.y_rot = ValueToDouble(value);
	} else if (attribute == z_rot)
	{
		rot.z_rot = ValueToDouble(value);
	} else if (attribute == closeNode)
	{
		if (_prefabWithMesh == NULL)
		{
			throw("PrefabWithMesh SetRotation: try to use uninitialized prefab");
		}
		_prefabWithMesh->setRotation(rot);
		rot.x_rot = rot.y_rot = rot.z_rot = 0;
	} else
	{
		throw My_Exception("PrefabPlantWithMesh _setRotation: Missing attribute type");
	}
}
void PrefabWithMesh_Plant::_setScale( const wstring & attribute, const wstring & value )
{
	static Vector3 scale;
	if (attribute == x_scale)
	{
		scale.x = ValueToDouble(value);
	} else if (attribute == y_scale)
	{
		scale.y = ValueToDouble(value);
	} else if (attribute == z_scale)
	{
		scale.z = ValueToDouble(value);
	} else if (attribute == closeNode)
	{
		if (_prefabWithMesh == NULL)
		{
			throw("PrefabWithMesh SetScale: try to use uninitialized prefab");
		}
		_prefabWithMesh->setScale(scale);
		scale.x = scale.y = scale.z = 0.0;
	} else
	{
		throw My_Exception("PrefabWithMesh_Plant _setScale: Missing attribute type");
	}
}
void ObjectStateUpdateSystem::destroyPlayer( GameData& mGameData)
{
	Player * player = mGameData.getPlayer();
	if (player != NULL)
	{
		createExplosionFor(player, mGameData);
		player->setVisible(false);
	} else
	{
		throw My_Exception("Try to remove nonexistent player");
	}
}
void PrefabPlant::closeElement( const wstring & name )
{
	setAttribute(L"close", L"");
	
	if(elements.empty() || elements.top() != name)
		throw My_Exception("Close XML Element: XML document don't meet standard");
	else
		elements.pop();


	if (elements.empty())
	{
		prefabReady = true;
	} 
}
void PrefabWithCollider_Plant::_setColliderRadius( const wstring & attribute, const wstring & value )
{
	if (attribute == PrefabPlant::value)
	{
		Collider_str.radius = ValueToUINT(value);

	} else if (attribute == PrefabPlant::closeNode)
	{
		return;
	} else
	{
		wstring tmp(L"EnemyPrefabPlant _setColliderRadius: Missing attribute type: ");
		tmp += attribute; 
		throw My_Exception(tmp);
	}
}
void MovablePrefab_Plant::_setThrusterOffset( const wstring & attribute, const wstring & value )
{
	if (attribute == PrefabPlant::x_pos)
	{
		thr_offset.x= ValueToDouble(value);
	} else if (attribute == PrefabPlant::y_pos)
	{
		thr_offset.y = ValueToDouble(value);
	} else if (attribute == PrefabPlant::z_pos)
	{
		thr_offset.z = ValueToDouble(value);
	} else if (attribute == PrefabPlant::closeNode)
	{
		_MovablePrefab->setThrusterOffset(thr_offset);
	}	else
	{
		wstring tmp(L"MovablePrefab_Plant _setThrusterOffset: Missing attribute type: ");
		tmp += attribute; 
		throw My_Exception(tmp);
	}
}
void MovablePrefab_Plant::_setThrusterName( const wstring & attribute, const wstring & value )
{
	if (attribute == name)
	{
		if (value == L"no" || value == L"NO" || value == L"")
		{
			_MovablePrefab->setThrusterName("");
		} else
		{
			_MovablePrefab->setThrusterName(string(value.begin(), value.end()));
		}
	} else if (attribute == closeNode)
	{
		return;
	} else
	{
		wstring tmp(L"MovablePrefab_Plant _setThrusterName: Missing attribute type: ");
		tmp += attribute; 
		throw My_Exception(tmp);
	}
}
void PrefabWithCollider_Plant::_setColliderOffset( const wstring & attribute, const wstring & value )
{
	if (attribute == PrefabPlant::x_pos)
	{
		Collider_str.offset.x= ValueToDouble(value);
	} else if (attribute == PrefabPlant::y_pos)
	{
		Collider_str.offset.y = ValueToDouble(value);
	} else if (attribute == PrefabPlant::z_pos)
	{
		Collider_str.offset.z = ValueToDouble(value);
	} else if (attribute == PrefabPlant::closeNode)
	{
		return;
	}	else
	{
		wstring tmp(L"PrefabWithCollider_Plant _setColliderOffset: Missing attribute type: ");
		tmp += attribute; 
		throw My_Exception(tmp);
	}
}
Exemple #11
0
void		Drone::Recive()
{
  std::string	str = this->net.getmsg();
  std::string	tmp;
  unsigned int	pos;

  while (str.find("\n") != std::string::npos && this->level != MAX)
    {
      pos = str.find("\n");
      tmp = str.substr(0, pos);

      if (tmp.find("message") == 0)
	Check_msg(tmp);
      else if (tmp.find("deplacement") == 0)
	{}
      else if (tmp.find("mort") == 0)
	throw My_Exception("Sorry you are dead.");
      else if (!this->rep.empty())
	(this->*actions[this->rep.front()])(tmp);
      str = str.substr(pos + 1);
    }
}