Skip to content

Laboratory Initialization

atharvagupta2003 edited this page Oct 4, 2023 · 9 revisions

Overview

Laboratory create a Laboratory for the player and companion to access and spawn different powerups to assist the player.

Design

Laboratory asset was selected to fits the overall Game Design objective. laboratory

Gameplay

When a player or companion approaches a powerup and presses M key, the lab window pops up. player can spawn particular powerups through this lab window.

Usage

Initialisation:

  1. Initialise a new LaboratoryFactory
  2. Addition of physics components.
  3. Toggle the lab window.

Example:

 Entity laboratory = new Entity()
                .addComponent(new TextureRenderComponent(config.spritePath))
                .addComponent(new ColliderComponent().setLayer(PhysicsLayer.LABORATORY))
                .addComponent(new PhysicsComponent().setBodyType(BodyDef.BodyType.StaticBody))
                .addComponent(new HitboxComponent().setLayer(PhysicsLayer.LABORATORY))
                .addComponent(new CombatStatsComponent(4, 0, 0, false));

Spawn Laboratory:

 private void spawnLaboratory(){
        LaboratoryConfig laboratoryConfig = mapConfig.areaEntityConfig.getEntity(LaboratoryConfig.class);
        if (laboratoryConfig !=null){
            Entity newLaboratory = LaboratoryFactory.createLaboratory();
            spawnEntityAt(newLaboratory, laboratoryConfig.position, true,false);
        }
    }

#UML

chatuml-diagram

Clone this wiki locally