예제 #1
0
void ScrollingSystem::initScrolling(Entity e, ScrollingComponent* sc) {
    ScrollingElement se;

    TransformationComponent* ptc = TRANSFORM(e);
    for (int i=0; i<2; i++) {
        se.e[i] = theEntityManager.CreateEntity(HASH("scroll/e", 0x4ab48dfd));

        ADD_COMPONENT(se.e[i], Transformation);
        ADD_COMPONENT(se.e[i], Rendering);
        ADD_COMPONENT(se.e[i], Anchor);

        TRANSFORM(se.e[i])->size = sc->displaySize;
        auto* tc = ANCHOR(se.e[i]);
        tc->parent = e;
        tc->position = -glm::vec2(sc->direction.x * ptc->size.x, sc->direction.y * ptc->size.y) * (float)i;
        tc->z = i * 0.001f;

        RenderingComponent* rc = RENDERING(se.e[i]);
        se.imageIndex[i] = i % sc->images.size();
        rc->texture = sc->images[se.imageIndex[i]];
        // rc->color = debugColors[se.imageIndex[i]];
        se.hasBeenVisible[i] = false;
        rc->flags = sc->renderingFlags;
    }
    elements[e] = se;
}
예제 #2
0
void TouchInputManager::activateDebug(Entity camera) {
    for (int i=0; i<MAX_TOUCH_POINT; i++) {
        debugState[i] = theEntityManager.CreateEntity(HASH("debug_input", 0x0));
        ADD_COMPONENT(debugState[i], Transformation);
        ADD_COMPONENT(debugState[i], Anchor);
        ANCHOR(debugState[i])->parent = camera;
        ANCHOR(debugState[i])->z = 0.9999f - TRANSFORM(camera)->z;
        ADD_COMPONENT(debugState[i], Rendering);
        RENDERING(debugState[i])->show = 1;
    }
}
예제 #3
0
void GameModeManager::Setup() {
    herisson = theEntityManager.CreateEntityFromTemplate("gamemode/herisson");

    branch = theEntityManager.CreateEntityFromTemplate("gamemode/branch");

    decor2nd = theEntityManager.CreateEntityFromTemplate("gamemode/decor2nd");
    // HACK
    TRANSFORM(decor2nd)->size.x = PlacementHelper::ScreenSize.x;

    SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_0", 0x2da4a4da));
    SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_3", 0xb93314de));
    SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_2", 0xc2edcdae));
    SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_1", 0xe8c9a7d4));

    decor1er = theEntityManager.CreateEntityFromTemplate("gamemode/decor1er");
    TRANSFORM(decor1er)->size.x = PlacementHelper::ScreenSize.x;

    SCROLLING(decor1er)->images.push_back(HASH("decor1er_0", 0x3a3efebf));
    SCROLLING(decor1er)->images.push_back(HASH("decor1er_1", 0x5ba415d2));
    SCROLLING(decor1er)->images.push_back(HASH("decor1er_2", 0x68f8263e));
    SCROLLING(decor1er)->images.push_back(HASH("decor1er_3", 0x4d7b9af));

    fillVec();

    uiHelper.build();

    #if SAC_DEBUG
    _debug = false;
    for(int i=0; i<8; i++) {
        debugEntities[2*i] = theEntityManager.CreateEntity(HASH("debug/Entities", 0x15df1b7c));
        ADD_COMPONENT(debugEntities[2*i], Rendering);
        ADD_COMPONENT(debugEntities[2*i], Transformation);
        RENDERING(debugEntities[2*i])->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(i, 0));
        TRANSFORM(debugEntities[2*i])->z = DL_DebugLayer;
        TRANSFORM(debugEntities[2*i])->size = glm::vec2((float)PlacementHelper::GimpWidthToScreen(80));

        debugEntities[2*i + 1] = theEntityManager.CreateEntity(HASH("debug/Entities", 0x15df1b7c));
        ADD_COMPONENT(debugEntities[2*i + 1], Text);
        TEXT(debugEntities[2*i + 1])->positioning = TextComponent::CENTER;
        ADD_COMPONENT(debugEntities[2*i + 1], Transformation);
        TRANSFORM(debugEntities[2*i + 1])->position = TRANSFORM(debugEntities[2*i])->position;
        TRANSFORM(debugEntities[2*i+1])->z = DL_DebugLayer + 0.01f;
        TEXT(debugEntities[2*i + 1])->fontName = HASH("typo", 0x5a18f4a9);
        TEXT(debugEntities[2*i + 1])->charHeight = PlacementHelper::GimpHeightToScreen(25);
    }
    #endif
}
예제 #4
0
void load_energy_core_data()
{
    EntityType type = ENTITY_ENERGY_CORE;

    entity_data->begin_attaching_to(type);

    (void)ADD_COMPONENT(Position);

    auto dims = ADD_COMPONENT(Dimension);
    dims->set_height(1.0f);

    auto vox = ADD_COMPONENT(VoxelModel);
    vox->vox_dat = &VoxDats::energy_core;
    vox->init_hitscan = true;
    vox->init_draw = true;
    vox->frozen = true;

    auto health = ADD_COMPONENT(HitPoints);
    health->health = 200;
    health->health_max = 200;

    #if DC_SERVER
    auto healer = ADD_COMPONENT(Healer);
    healer->radius = 1.0f;

    auto limiter = ADD_COMPONENT(RateLimit);
    limiter->limit = MOB_BROADCAST_RATE;

    auto item_drop = ADD_COMPONENT(ItemDrop);
    item_drop->drop->set_max_drop_types(2);
    item_drop->drop->set_max_drop_amounts("energy_tank", 2);
    item_drop->drop->add_drop("energy_tank", 2, 0.5f);
    item_drop->drop->add_drop("energy_tank", 3, 0.5f);
    item_drop->drop->set_max_drop_amounts("small_charge_pack", 3);
    item_drop->drop->add_drop("small_charge_pack", 4, 0.5f);
    item_drop->drop->add_drop("small_charge_pack", 5, 0.3f);
    item_drop->drop->add_drop("small_charge_pack", 6, 0.2f);

    auto state = ADD_COMPONENT(StateMachine);
    auto conf = state->configuration;
    conf->add_state("idle", &stick_to_surface);
    #endif

    #if DC_CLIENT
    auto anim = ADD_COMPONENT(Animation);
    anim->count = 35;
    anim->count_max = 50;
    anim->size = 0.22f;
    anim->force = 5.0f;
    anim->color = Color(59, 99, 17);
    #endif
}
예제 #5
0
Entity GameModeManager::createAndAddLeave(int type, const glm::vec2& position, float rotation) {
    Entity e = theEntityManager.CreateEntity(HASH("branch/leave", 0x6ac1ed8f));
    ADD_COMPONENT(e, Transformation);
    ADD_COMPONENT(e, Rendering);
    ADD_COMPONENT(e, Twitch);
    RENDERING(e)->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(type, 0));
    RENDERING(e)->show = true;
    RENDERING(e)->flags = RenderingFlags::NonOpaque;

    TRANSFORM(e)->size = HeriswapGame::CellSize(8, type) * HeriswapGame::CellContentScale();

    TRANSFORM(e)->position = position;
    TRANSFORM(e)->rotation = rotation;

    TRANSFORM(e)->z = glm::lerp(DL_LeafMin, DL_LeafMax, glm::linearRand(0.f, 1.f));

    return e;
}
예제 #6
0
	static Entity createCell(Feuille& f, bool assignGridPos) {
		Entity e = theEntityManager.CreateEntityFromTemplate("spawn/cell");
		ADD_COMPONENT(e, HeriswapGrid);
	    ADD_COMPONENT(e, Twitch);

		TRANSFORM(e)->position = HeriswapGame::GridCoordsToPosition(f.X, f.Y, theHeriswapGridSystem.GridSize);
		TRANSFORM(e)->z = DL_Cell + Random::Float(0.f, 1.f) * 0.001f;
		RenderingComponent* rc = RENDERING(e);
		rc->show = true;

		TRANSFORM(e)->size = glm::vec2(0.f);
		ADSR(e)->idleValue = HeriswapGame::CellSize(theHeriswapGridSystem.GridSize, f.type).x * HeriswapGame::CellContentScale();
		HERISWAPGRID(e)->type = f.type;
		if (assignGridPos) {
			HERISWAPGRID(e)->i = f.X;
			HERISWAPGRID(e)->j = f.Y;
		}
		rc->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(f.type, &TRANSFORM(e)->rotation));
		return e;
	}
예제 #7
0
void menuwin_paint_button(cairo_t *cr,int xo, int yo, int wo, int ho, float r, float g, float b) {

	// coordinates and size are in width/KEYS_H_DIVISOR and height/KEYS_H_DIVISOR units
	// 0,0 is bottom-left

	float x=1.0+(xo*width)/KEYS_PER_ROW;
	float y=key_win.height-(((yo+1)*height)/KEYS_H_DIVISOR);
	float w=((((xo+wo)*width)/KEYS_PER_ROW)-x)-2.0;
	float h=(ho*height)/KEYS_H_DIVISOR;
	float scale;

	cairo_pattern_t *pattern;

	pattern = cairo_pattern_create_linear (x,y+BUTTON_MARGIN, x, y+h-BUTTON_E_RADIUS);
	cairo_pattern_add_color_stop_rgb(pattern,0.0,SUB_COMPONENT(r),SUB_COMPONENT(g),SUB_COMPONENT(b));
	cairo_pattern_add_color_stop_rgb(pattern,0.25,ADD_COMPONENT(r),ADD_COMPONENT(g),ADD_COMPONENT(b));
	cairo_pattern_add_color_stop_rgb(pattern,0.45,ADD_COMPONENT(r),ADD_COMPONENT(g),ADD_COMPONENT(b));
	cairo_pattern_add_color_stop_rgb(pattern,1.0,SUB_COMPONENT(r),SUB_COMPONENT(g),SUB_COMPONENT(b));
	cairo_set_source(cr,pattern);
	menuwin_trace_button(cr,x,y,w,h);
	cairo_fill(cr);
	cairo_set_source_rgb(cr,0,0,0);
	cairo_set_line_width(cr,0.5);
	menuwin_trace_button(cr,x,y,w,h);
	cairo_stroke(cr);

	cairo_save(cr);
	cairo_translate(cr,x+w/2,y+h/2);
	w=(width)/KEYS_PER_ROW;
	h=(height)/KEYS_H_DIVISOR;
	if (w>h) {
		scale=(float)h;
	} else {
		scale=(float)w;
	}
	scale/=2.0;
	cairo_scale(cr,scale,scale);
}
예제 #8
0
void load_turret_data()
{
    EntityType type = ENTITY_TURRET;

    entity_data->begin_attaching_to(type);

    (void)ADD_COMPONENT(Position);
    (void)ADD_COMPONENT(Owner);

    auto dims = ADD_COMPONENT(Dimension);
    dims->set_height(1.9f);
    dims->set_camera_height(1.6f);

    auto vox = ADD_COMPONENT(VoxelModel);
    vox->vox_dat = &VoxDats::turret;
    vox->init_hitscan = true;
    vox->init_draw = true;
    vox->frozen = true;

    auto health = ADD_COMPONENT(HitPoints);
    health->health = 125;
    health->health_max = 125;

    auto target = ADD_COMPONENT(WeaponTargeting);
    target->target_acquisition_failure_rate = 0.85f;
    target->fire_rate_limit = 45;
    target->uses_bias = true;
    target->accuracy_bias = 1.0f;
    target->sight_range = 32.0f;
    target->attack_at_random = true;
    // we dont have ID yet, need to set that in the ready() call
    target->attacker_properties.type = type;
    target->attacker_properties.block_damage = 8;
    target->attacker_properties.agent_damage_min = 2;
    target->attacker_properties.agent_damage_max = 3;
    target->attacker_properties.agent_protection_duration = ONE_SECOND * 5;
    target->attacker_properties.terrain_modification_action = TMA_TURRET;

    #if DC_SERVER
    auto explode = ADD_COMPONENT(Explosion);
    explode->radius = 2.0f;
    explode->damage = 10;
    explode->harms_owner = false;

    auto limiter = ADD_COMPONENT(RateLimit);
    limiter->limit = MOB_BROADCAST_RATE;

    auto state = ADD_COMPONENT(StateMachine);
    auto conf = state->configuration;
    conf->add_state("idle", &stick_to_surface);
    #endif

    #if DC_CLIENT
    auto anim = ADD_COMPONENT(Animation);
    anim->count = 35;
    anim->count_max = 50;
    anim->size = 0.1f;
    anim->force = 5.0f;
    anim->color = Color(1, 1, 1);
    #endif
}
예제 #9
0
void load_mob_lizard_thief_data()
{
    const EntityType type = ENTITY_MONSTER_LIZARD_THIEF;

    entity_data->begin_attaching_to(type);

    (void)ADD_COMPONENT(PositionMomentum);

    auto mob = ADD_COMPONENT(SpriteMob);
    mob->mob.set_type("lizard_thief");

    auto dims = ADD_COMPONENT(Dimension);
    dims->set_height(t_mob::get_mob_height(mob->mob.type) * 1.9f);
    dims->set_width(t_mob::get_mob_width(mob->mob.type) * 1.9f);

    auto health = ADD_COMPONENT(HitPoints);
    health->health = 80;
    health->health_max = 80;

    #if DC_CLIENT
    auto anim = ADD_COMPONENT(Animation);
    anim->color = Color(21, 150, 21);
    anim->count = 40;
    anim->count_max = 60;
    anim->size = 0.1;
    anim->force = 1.0f;
    #endif

    #if DC_SERVER
    auto dest = ADD_COMPONENT(DestinationTargeting);
    dest->sight_range = 15.0f;
    dest->destination_choice_x = 20;
    dest->destination_choice_y = 20;
    dest->speed = 0.125f;
    dest->max_z_diff = 5;

    auto agent = ADD_COMPONENT(AgentTargeting);
    agent->sight_range = 15.0f;
    agent->speed = 0.18f;
    agent->max_z_diff = 5;
    agent->max_lock_ticks = ONE_SECOND * 10;
    agent->proximity_radius = 2.1f;
    agent->attack_rate = (3 * ONE_SECOND) / 2;
    agent->attack_damage = 2;

    auto waiting = ADD_COMPONENT(Waiting);
    waiting->wait_time = ONE_SECOND * 3;

    auto limiter = ADD_COMPONENT(RateLimit);
    limiter->limit = MOB_BROADCAST_RATE;

    auto item_drop = ADD_COMPONENT(ItemDrop);
    item_drop->drop->set_max_drop_types(3);
    item_drop->drop->set_max_drop_amounts("synthesizer_coin", 3);
    item_drop->drop->add_drop("synthesizer_coin", 1, 0.3f);
    item_drop->drop->add_drop("synthesizer_coin", 2, 0.1f);
    item_drop->drop->add_drop("synthesizer_coin", 3, 0.05f);
    item_drop->drop->set_max_drop_amounts("plasma_grenade", 10);
    item_drop->drop->add_drop_range("plasma_grenade", 1, 10, 0.8f);
    item_drop->drop->set_max_drop_amounts("led_torch", 5);
    item_drop->drop->add_drop_range("led_torch", 1, 5, 0.2f);

    auto state = ADD_COMPONENT(StateMachine);
    auto conf = state->configuration;
    conf->add_state("waiting", &do_wait);
    conf->add_state("chase_agent", &chase_agent);
    conf->add_state("wander", &in_transit);
    conf->add_transition("waiting", "done_waiting", "wander", &go_to_next_destination);
    conf->add_transition("waiting", "agent_targeted", "chase_agent", NULL);
    conf->add_transition("wander", "agent_targeted", "chase_agent", NULL);
    conf->add_transition("waiting", "agent_attacked", "chase_agent", &target_attacker);
    conf->add_transition("wander", "agent_attacked", "chase_agent", &target_attacker);
    conf->add_transition("wander", "at_destination", "waiting", &begin_wait);
    conf->add_transition("chase_agent", "agent_target_lost", "waiting", &begin_wait);

    auto knockback = ADD_COMPONENT(Knockback);
    knockback->weight = 1.0f;
    #endif
}
예제 #10
0
파일: Player.cpp 프로젝트: fordacious/Relic
Player::Player (EventSystem * eventSystem) : Entity(eventSystem) {
    //ADD_COMPONENT(ShipComponent, eventSystem);
    ADD_COMPONENT(PhysicsComponent);
    ADD_COMPONENT(PlayerComponent);
    ADD_COMPONENT(PlayerInputComponent, eventSystem);
}