Exemplo n.º 1
0
flag C2DPoly::DataXchg(DataChangeBlk &DCB) 
  {
  switch (DCB.lHandle)
    {
    case xidPolyOrder:
      if (DCB.rL)
        SetOrder(*(DCB.rL));
      DCB.L = Order;
      return 1;
    }
  return False; 
  }
Exemplo n.º 2
0
flag C2DPoly::ReFit()
  {
  if (NPts()>Order)
    {
    SetOrder(Order);
    CDVector DP;
    if (!pFn->LBEst(DP, dSa, iIter, iMaxIter))
      iIter = -1;   //singularity
    }
  else
    iIter = -2;  //insufficient points
  return True;
  }
Exemplo n.º 3
0
bool Enemy::InitData(const string& name)
{
	EnemyInfo* info = PlaneManager::getInstance()->GetEnemyInfo(name);
	SetName(name);
	ChangeBulletType(info->bulletType);
	SetHpMax(info->hpMax);
	SetHp(GetHpMax());
	_duration = info->duration;
	_stayTime = info->stayTime;
	SetMoveSpeed(info->moveSpeed);
	_score = info->score;
	_itemID = info->itemID;
	switch (info->layer)
	{
	case 1:
		SetOrder(LAYER_ENEMY_1);
		break;
	case 2:
		SetOrder(LAYER_ENEMY_2);
		break;
	case 3:
		SetOrder(LAYER_ENEMY_3);
		break;
	default:
		SetOrder(LAYER_ENEMY_1);
		break;
	}
	ChangeMoveState(info->moveStateID);
	SetMoveEnable(true);


	if (InitWithFile(info->imgPath))
	{
		return true;
	}

	return false;
}
Exemplo n.º 4
0
void ODSPropPath :: SetPath (char *prop_path, char *strname, logical is_collection, char *sort_index_name, ODSPropertyType prop_type, PIACC accmode_w )
{

  ResetPath();
  
  if ( prop_path )
    path = strdup(prop_path);

  SetStructure(strname);
  SetOrder(sort_index_name);
  
  type       = prop_type;
  acc_mode   = accmode_w;
  collection = type == PT_BaseCollection ? YES : is_collection;



}
Exemplo n.º 5
0
long C2DPoly::Parse(FxdEdtInfo &EI, Strng & Str)
  {
  if (CurrentBlk(EI))
    {
    bObjModified=1;
    switch (EI.FieldId)
      {
      case Id_Order: 
        {
        int OldOrder = Order;
        SetOrder(Str.SafeAtoL());
        if (Order!=OldOrder)
          View().DoRebuild();
        break;
        }
      }
    }
  ParseParmsBlk(EI, Str, bObjModified);
  return 1;
  }
Exemplo n.º 6
0
void EnergyReceiver::Update(float dt)
{	
	if( _state == ER_INIT || !GameSettings::gamefield[_index]->IsFlyType(Game::Square::FLY_STAY))
	{
		return;
	}

	_localTime += dt;
	if(_localTime < 0)
	{
		return;
	}

	_fly_offset_y = 6.0f * math::sin(_localTime * 1.2f);
	float t = math::clamp(0.f, 1.f, _timeAppear);
	float ampl = math::clamp(0.f, 1.f, (1.f - _timeAppear/4.f));
	ampl = 60.0f * ampl * ampl; //Очень быстрое затухание
	_fly_offset_y += -40.f * (1.0f - t) + ampl * math::sin(_timeAppear*math::PI - math::PI*0.5f);
	_fly_offset_y *= GameSettings::SQUARE_SCALE;

	if(_hideByThief)
	{
		if(_hideByThiefTime < 0)
		{
			_hideByThiefTime += dt;
		}
		else if(_hideByThiefTime < 1)
		{
			_hideByThiefTime += dt*1.5f;
			if(_hideByThiefTime >= 1)
			{
				_hideByThiefTime = 1.F;
			}
		}
	}

	if(_firstShowed)
	{
		if(_timeAppear < 0) {
			_timeAppear += dt;
		} else {
			_timeAppear += dt*1.5f;
		}
		if(_timeAppear >= 1.f && _state == ER_APPEAR)
		{
			//_timeAppear = 1.f;
			_state = ER_STAND;
		}
	}

	if(!_firstShowed && Game::activeRect.Inflated(1).Contains(GetIndex()))
	{
		_firstShowed = true;
		//Акцентирующий эффект при первом появлении на экране
		ParticleEffect *eff2 = 0;
		if(IsOrdered()) {
			eff2 = _effectCellCont.AddEffect("RecStartAccentLock");
		} else {
			eff2 = _effectCellCont.AddEffect("RecStartAccent");
		}
		eff2->SetPos(FPoint(0.0f, 0.0f));
		eff2->Reset();

		MM::manager.PlaySample("ReceiverShow");

		_timerForAppearOrder = gameInfo.getConstFloat("ShowOrderOnRecDelay", 3.f);
	}
	if(!IsOrdered())
	{
		_timerForAppearOrder = 0.f;
	}
	else if(_timerForAppearOrder > -1)
	{
		if(_timerForAppearOrder > 0)
		{
			_timerForAppearOrder -= dt;
		}else{
			_timerForAppearOrder -= dt*7.f;
		}
		if(_timerForAppearOrder <= 0.5f)
		{
			if(IsOrdered() && !_lockLiveEffectShowed)
			{
				ParticleEffect* eff = _effectCellCont.AddEffect("LockLive");
				eff->SetPos(FPoint(0.f, LockBarrierBase::YOffset_LOCK));
				eff->Reset();
				_effectCellCont.Update(0.f);
				_order->InitAppear(0.8f, 0.7f);
				_lockLiveEffectShowed = true;

				MM::manager.PlaySample("ReceiverOrderAppear");
			}
		}
		if(_timerForAppearOrder < -1)
		{
			_timerForAppearOrder = -1;
		} 
	}
	if(_order)
	{
		_order->Update(dt);
		if(!IsOrdered()) //Все больше не залочены
		{
			SetOrder(Game::Order::HardPtr());
			Energy::field.UpdateSquare(Game::FieldAddress(GetIndex()));
			_effectCellCont.KillAllEffects();

			Game::AddController(new FlashAnimationPlayer(Game::ANIM_RESOURCES["LockBreak"], FPoint(GetIndex())*GameSettings::SQUARE_SIDEF + FPoint(0.f, LockBarrierBase::YOffset_LOCK), FlashAnimationPlayer::DRAW_UP));

			MM::manager.PlaySample("ReceiverOrderComplete");
		}
	}

	_effectCellCont.Update(dt);
	_effContUpStatic.Update(dt);
	_effContUp.Update(dt);
	_effContDown.Update(dt);

	if(_crystalAnim.get())
	{
		if(_state == ER_STAND)
		{
			_crystalAnim->Update(dt*_crystalTimeScale);
		}else if(_state == ER_ACTIVATED_BREAK){
			Receiver::ReceiverEffect::keep_camera = true;
			//_crystalTime += dt*_crystalTimeScale;
			//if(_crystalTime >= 1)
			//{
			//	_crystalTime = 1.f;
			//	_crystalAnim.reset();
			//	Game::AddController(new Receiver::ReceiverEffect(FPoint(GetIndex())*GameSettings::SQUARE_SIDEF + FPoint(0.f, _fly_offset_y * GameSettings::SQUARE_SCALE), _uid));

			//	ParticleEffectPtr eff = Game::AddEffect(GameField::Get()->_effCont, "RecBreak");
			//	eff->SetPos(GetCenterPos());
			//	eff->Reset();

			//	ParticleEffectPtr eff2 = Game::AddEffect(GameField::Get()->_effTopCont, "RecBreak_2");
			//	eff2->SetPos(GetCenterPos());
			//	eff2->Reset();
			//}else{
			//	int frames_count = _crystalAnim->GetLastPlayedFrame() - _crystalAnim->GetFirstPlayedFrame();
			//	float t = math::ease(_crystalTime, 0.f, 1.f);
			//	int frame = _crystalAnim->GetFirstPlayedFrame() + (math::lerp(_frame1, _frame2, t) % frames_count);
			//	_crystalAnim->SetCurrentFrame(frame);
			//}
		}
	}

	//if(!HasOrder() && _state <= ER_ACTIVATED_BREAK)
	//{
	//	if(_timerLight > 0)
	//	{
	//		_timerLight -= dt;
	//		if(_timerLight < 0)
	//		{
	//			ParticleEffect *eff = _effContUp.AddEffect("RecLight");
	//			eff->SetPos(FPoint(0.0f, 0.0f));
	//			eff->Reset();
	//			_timerLight = math::random(10.f, 30.f);
	//		}
	//	}
	//}
	if(_timerForRunChipFall >= 0)
	{
		_timerForRunChipFall -= dt;
		if(_timerForRunChipFall <= 0)
		{
			Gadgets::receivers.AcceptMessage(Message("JumpFinished", _uid));
			_timerForRunChipFall = -1.f;
		}
	}
}
Exemplo n.º 7
0
void C2DPoly::Clear()
  {
  CBaseMdl::Clear();
  SetOrder(1);
  }
Exemplo n.º 8
0
 virtual bool Rewind()
 { return SetOrder(lastOrder); }
void
SILAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SILAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("nSets")) != 0)
        SetNSets(node->AsInt());
    if((node = searchNode->GetNode("setNames")) != 0)
        SetSetNames(node->AsStringVector());
    if((node = searchNode->GetNode("setIds")) != 0)
        SetSetIds(node->AsIntVector());
    if((node = searchNode->GetNode("wholeList")) != 0)
        SetWholeList(node->AsIntVector());
    if((node = searchNode->GetNode("nCollections")) != 0)
        SetNCollections(node->AsInt());
    if((node = searchNode->GetNode("category")) != 0)
        SetCategory(node->AsStringVector());
    if((node = searchNode->GetNode("role")) != 0)
        SetRole(node->AsIntVector());
    if((node = searchNode->GetNode("superset")) != 0)
        SetSuperset(node->AsIntVector());

    // Clear all the NamespaceAttributess if we got any.
    bool clearedNspaces = false;
    // Go through all of the children and construct a new
    // NamespaceAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("NamespaceAttributes"))
            {
                if (!clearedNspaces)
                {
                    ClearNspaces();
                    clearedNspaces = true;
                }
                NamespaceAttributes temp;
                temp.SetFromNode(children[i]);
                AddNspace(temp);
            }
        }
    }


    // Clear all the SILMatrixAttributess if we got any.
    bool clearedMatrices = false;
    // Go through all of the children and construct a new
    // SILMatrixAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILMatrixAttributes"))
            {
                if (!clearedMatrices)
                {
                    ClearMatrices();
                    clearedMatrices = true;
                }
                SILMatrixAttributes temp;
                temp.SetFromNode(children[i]);
                AddMatrices(temp);
            }
        }
    }


    // Clear all the SILArrayAttributess if we got any.
    bool clearedArrays = false;
    // Go through all of the children and construct a new
    // SILArrayAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILArrayAttributes"))
            {
                if (!clearedArrays)
                {
                    ClearArrays();
                    clearedArrays = true;
                }
                SILArrayAttributes temp;
                temp.SetFromNode(children[i]);
                AddArrays(temp);
            }
        }
    }

    if((node = searchNode->GetNode("order")) != 0)
        SetOrder(node->AsIntVector());
}
Exemplo n.º 10
0
Arquivo: VQModel.cpp Projeto: nykm/sop
void VQModel::Adapt(const std::shared_ptr<Model>& other, const std::vector< DynamicVector<Real> >& samples,
    unsigned int iterations, Real relevanceFactor)
{
    const VQModel* model = dynamic_cast<VQModel*>(other.get());

    if (model == nullptr)
    {
        std::cout << "Not VQModel." << std::endl;
        return;
    }

    SetOrder(model->GetOrder());
    Init();

    std::vector<unsigned int> indices(samples.size());

    // Initialize the feature vectors of the centroids.

    for (unsigned int c = 0; c < GetOrder(); c++)
    {
        mClusterCentroids[c] = model->mClusterCentroids[c];
    }

    // Do the iterations.
    for (unsigned int i = 0; i < iterations; i++)
    {
        //Find the closest centroid to each sample
        for (unsigned int n = 0; n < samples.size(); n++)
        {
            Real minDist = std::numeric_limits<Real>::max();

            for (unsigned int c = 0; c < GetOrder(); c++)
            {
                Real dist = samples[n].Distance(mClusterCentroids[c]);

                if (dist < minDist)
                {
                    minDist = dist;
                    indices[n] = c;
                }
            }
        }

        //Set the centroids to the average of the samples in each centroid
        for (unsigned int c = 0; c < GetOrder(); ++c)
        {
            mClusterCentroids[c].Assign(0.0f);

            mClusterSizes[c] = 0;
        }

        for (unsigned int s = 0; s < samples.size(); ++s)
        {
            mClusterCentroids[indices[s]].Add(samples[s]);

            ++mClusterSizes[indices[s]];
        }

        for (unsigned int c = 0; c < GetOrder(); ++c)
        {
            if (mClusterSizes[c] > 0)
            {
                mClusterCentroids[c].Multiply(1.0f / static_cast<Real>(mClusterSizes[c]));
            }
        }

        //Calculate the adapted values
        for (unsigned int c = 0; c < GetOrder(); ++c)
        {
            Real size = static_cast<Real>(mClusterSizes[c]);
            Real w = size / (size + static_cast<Real>(relevanceFactor));

            DynamicVector<Real> ubmc = model->mClusterCentroids[c];
            ubmc.Multiply(1.0f - w);

            mClusterCentroids[c].Multiply(w);
            mClusterCentroids[c].Add(ubmc);
        }
    }
}