void AFlySkillActor::Injury_Implementation()
{
	AAONGameState* ags = Cast<AAONGameState>(UGameplayStatics::GetGameState(GetWorld()));
	for (AHeroCharacter* hero : AttackCollision)
	{
		// 如果不同隊才造成傷害
		if (hero && hero->TeamId != this->TeamId)
		{
			// 物傷
			if (PhysicalDamage > 0)
			{
				float Injury = ags->ArmorConvertToInjuryPersent(hero->CurrentArmor);
				float Damage = PhysicalDamage * Injury;
				hero->CurrentHP -= Damage;

				// 顯示傷害文字
				ADamageEffect* TempDamageText = GetWorld()->SpawnActor<ADamageEffect>(AHeroCharacter::ShowDamageEffect);
				if (TempDamageText)
				{
					FVector pos = hero->GetActorLocation();
					pos.X += 10;
					TempDamageText->OriginPosition = pos;
					TempDamageText->SetString(FString::FromInt((int32)Damage));
					FVector scaleSize(TempDamageText->ScaleSize, TempDamageText->ScaleSize, TempDamageText->ScaleSize);
					TempDamageText->SetActorScale3D(scaleSize);
					FVector dir = hero->GetActorLocation() - GetActorLocation();
					dir.Normalize();
					TempDamageText->FlyDirection = dir;
				}
			}
			// 法傷
			if (MagicDamage > 0)
			{
				float Damage = MagicDamage * (1 - hero->CurrentMagicInjured);
				hero->CurrentHP -= Damage;

				// 顯示傷害文字
				ADamageEffect* TempDamageText = GetWorld()->SpawnActor<ADamageEffect>(AHeroCharacter::ShowDamageEffect);
				if (TempDamageText)
				{
					FVector pos = hero->GetActorLocation();
					pos.X += 10;
					TempDamageText->OriginPosition = pos;
					TempDamageText->SetString(FString::FromInt((int32)Damage));
					FVector scaleSize(TempDamageText->ScaleSize, TempDamageText->ScaleSize, TempDamageText->ScaleSize);
					TempDamageText->SetActorScale3D(scaleSize);
					FVector dir = hero->GetActorLocation() - GetActorLocation();
					dir.Normalize();
					TempDamageText->FlyDirection = dir;
				}
			}
			hero->BuffQueue.Append(Buffs);
		}
	}
	AttackCollision.Empty();
}
void ContentWindowGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent * event)
{
    // on Mac we've seen that mouse events can go to the wrong graphics item
    // this is due to the bug: https://bugreports.qt.nokia.com/browse/QTBUG-20493
    // here we ignore the event if it shouldn't have been sent to us, which ensures
    // it will go to the correct item...
    if(boundingRect().contains(event->pos()) == false)
    {
        event->ignore();
        return;
    }

    ContentWindowManagerPtr contentWindow = getContentWindowManager();

    if( contentWindow )
    {
        // handle wheel movements differently depending on state of item window
        if (selected())
        {
            contentWindow->getInteractionDelegate().wheelEvent(event);
        }
        else
        {
            // scale size based on wheel delta
            // typical delta value is 120, so scale based on that
            double factor = 1. + (double)event->delta() / (10. * 120.);

            scaleSize(factor);
        }
    }
}
void ContentWindowGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent * event)
{
    // on Mac we've seen that mouse events can go to the wrong graphics item
    // this is due to the bug: https://bugreports.qt.nokia.com/browse/QTBUG-20493
    // here we ignore the event if it shouldn't have been sent to us, which ensures
    // it will go to the correct item...
    if(boundingRect().contains(event->pos()) == false)
    {
        event->ignore();
        return;
    }

    // handle wheel movements differently depending on state of item window
    if(windowState_ == UNSELECTED)
    {
        // scale size based on wheel delta
        // typical delta value is 120, so scale based on that
        double factor = 1. + (double)event->delta() / (10. * 120.);

        scaleSize(factor);
    }
    else if(windowState_ == SELECTED)
    {
        // change zoom based on wheel delta
        // deltas are counted in 1/8 degrees. so, scale based on 180 degrees => delta = 180*8 = 1440
        double zoomDelta = (double)event->delta() / 1440.;
        double zoom = zoom_ * (1. + zoomDelta);

        setZoom(zoom);
    }
    // TODO: do something for INTERACTION state
}
EnemyNode* EnemyNode::createNode(const std::string &enemyImage)
{
    auto node = EnemyNode::create();
    
    //auto texture = Director::getInstance()->getTextureCache()->getTextureForKey(enemyImage);
    //node->mapEnemy = Sprite::createWithTexture(texture);
    
    auto icon = Sprite::create(enemyImage);
    if (icon == nullptr) {
        return nullptr;
    }
    node->mapEnemy = icon;
    icon->setPosition(node->_panel_icon->getPosition());
    auto tempSize = node->_panel_icon->getContentSize();
    icon->setScale(tempSize.width/(icon->getContentSize().width),
                   tempSize.height/(icon->getContentSize().height));
    //node->_panel_icon->addChild(icon);
    node->addChild(icon, 1, 1);
    
    auto hpbar = HealthBar::create();
    node->hpBar = hpbar;
    tempSize = node->_panel_hp->getContentSize();
    hpbar->setPosition(node->_panel_hp->getPosition());
    hpbar->scaleSize(tempSize);
    //node->_panel_hp->addChild(node->hpBar);
    node->addChild(hpbar, 2,2);
    
    return node;
}
Beispiel #5
0
//--------------------------------------------------------------
void testApp::setup(){ 
  //// utils
  char tmpstr[2000];
  ofFile f = ofFile();
  ofDirectory dir = ofDirectory();
  /// indexes
	rota = 0;
  nimg = 0;
  nsnd = 9;
  image_duration = 0.1;
  image_timer = 0;
  silence_timer = 0;
  silence_trigger = false;
  //// LOAD IMAGES
  string rep_images = "intelligentsia/images/";
  dir.open(rep_images);
  dir.allowExt("jpg");
  dir.listDir();
  Nimgs = dir.numFiles();
  cout << Nimgs << endl;
  
  for (int i = 0; i < Nimgs; i++){
    sprintf(tmpstr, "%s_%dx%d.jpeg",dir.getPath(i).c_str(), ofGetScreenWidth(), ofGetScreenHeight());

    if (f.doesFileExist(tmpstr)) images[i].loadImage(tmpstr);
    else {
      images[i].loadImage(dir.getPath(i));
      pt = scaleSize(images[i].width, images[i].height, ofGetScreenWidth(), ofGetScreenHeight());
      images[i].resize(pt.x,pt.y);
      cout << "will save" << tmpstr << endl;
      images[i].saveImage(tmpstr);
    }
    cout << dir.getPath(i) << endl;
  };

  //// LOAD SOUND
  string rep_sounds = "intelligentsia/sons/";
  dir.open(rep_sounds);
  dir.allowExt("wav");
  dir.listDir();
  Nsnds = dir.numFiles();
  cout << Nsnds << endl;
  
  for (int i = 0; i < Nsnds; i++){
      sounds[i].loadSound(dir.getPath(i));
      cout << dir.getPath(i) << endl;
  };
  sounds[nsnd].play();


  // GRAPHICS
  ofHideCursor();
  ofSetFrameRate(120);
  ofSetVerticalSync(true);

}
Beispiel #6
0
void TextureButton::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_DRAW: {
			DrawMode draw_mode = get_draw_mode();

			Ref<Texture> texdraw;

			switch (draw_mode) {
				case DRAW_NORMAL: {

					if (normal.is_valid())
						texdraw = normal;
				} break;
				case DRAW_PRESSED: {

					if (pressed.is_null()) {
						if (hover.is_null()) {
							if (normal.is_valid())
								texdraw = normal;
						} else
							texdraw = hover;

					} else
						texdraw = pressed;
				} break;
				case DRAW_HOVER: {

					if (hover.is_null()) {
						if (pressed.is_valid() && is_pressed())
							texdraw = pressed;
						else if (normal.is_valid())
							texdraw = normal;
					} else
						texdraw = hover;
				} break;
				case DRAW_DISABLED: {

					if (disabled.is_null()) {
						if (normal.is_valid())
							texdraw = normal;
					} else
						texdraw = disabled;
				} break;
			}

			if (texdraw.is_valid()) {
				Point2 ofs;
				Size2 size = texdraw->get_size();
				Rect2 tex_regin = Rect2(Point2(), texdraw->get_size());
				bool tile = false;
				if (expand) {
					switch (stretch_mode) {
						case STRETCH_KEEP:
							size = texdraw->get_size();
							break;
						case STRETCH_SCALE:
							size = get_size();
							break;
						case STRETCH_TILE:
							size = get_size();
							tile = true;
							break;
						case STRETCH_KEEP_CENTERED:
							ofs = (get_size() - texdraw->get_size()) / 2;
							size = texdraw->get_size();
							break;
						case STRETCH_KEEP_ASPECT_CENTERED:
						case STRETCH_KEEP_ASPECT: {
							Size2 _size = get_size();
							float tex_width = texdraw->get_width() * _size.height / texdraw->get_height();
							float tex_height = _size.height;

							if (tex_width > _size.width) {
								tex_width = _size.width;
								tex_height = texdraw->get_height() * tex_width / texdraw->get_width();
							}

							if (stretch_mode == STRETCH_KEEP_ASPECT_CENTERED) {
								ofs.x = (_size.width - tex_width) / 2;
								ofs.y = (_size.height - tex_height) / 2;
							}
							size.width = tex_width;
							size.height = tex_height;
						} break;
						case STRETCH_KEEP_ASPECT_COVERED: {
							size = get_size();
							Size2 tex_size = texdraw->get_size();
							Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height);
							float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height;
							Size2 scaledTexSize = tex_size * scale;
							Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f;
							tex_regin = Rect2(ofs, size / scale);
						} break;
					}
				}
				if (tile)
					draw_texture_rect(texdraw, Rect2(ofs, size), tile);
				else
					draw_texture_rect_region(texdraw, Rect2(ofs, size), tex_regin);
			}
			if (has_focus() && focused.is_valid()) {

				Rect2 drect(Point2(), get_size());
				draw_texture_rect(focused, drect, false);
			};
		} break;
	}
}
Beispiel #7
0
toxi::geom::Polygon2D * toxi::geom::Polygon2D::scaleSize( const Vec2D & p )
{
	return scaleSize(static_cast< float > ( p.getX() ), static_cast< float > ( p.getY() ) );
}
Beispiel #8
0
toxi::geom::Polygon2D * toxi::geom::Polygon2D::scaleSize( const float & scale )
{
	return scaleSize(scale, scale);
}