Skip to content

Commit

Permalink
deleted rangetask, just doing it in one task. created basic start fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
gregchan550 committed Oct 5, 2023
1 parent 394c4cb commit e08fd81
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
package com.csse3200.game.components.tasks.MobTask;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Timer;
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.components.tasks.MovementTask;
import com.csse3200.game.components.tasks.bosstask.PatrickTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.physics.components.PhysicsMovementComponent;
import com.csse3200.game.rendering.AnimationRenderComponent;

public class MobMeleeTask extends DefaultTask implements PriorityTask {

// Constants
private static final int PRIORITY = 3;
private static final Vector2 MELEE_MOB_SPEED = new Vector2(1f,1f);
private static final Vector2 MELEE_RANGE_SPEED = new Vector2(0.7f,0.7f);

// Private variables
MobType mobType;
State state;
State state = State.DEFAULT;
State prevState;
Entity mob;
AnimationRenderComponent animation;
MovementTask movementTask;
boolean melee;

// Enums
private enum State {
RUN, ATTACK, DEATH, DEFAULT
}
Expand All @@ -23,12 +37,32 @@ public MobMeleeTask(MobType mobType) {

@Override
public void start() {
super.start();
mob = owner.getEntity();
animation = mob.getComponent(AnimationRenderComponent.class);
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED);
melee = mobType.isMelee();

movementTask = new MovementTask(new Vector2(0f, mob.getPosition().y));
movementTask.create(owner);
movementTask.start();

if (melee) {
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED);
} else {
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_RANGE_SPEED);
}
}

@Override
public void update() {
animate();

switch (state) {
case RUN -> {

}
}
}

private void animate() {
Expand Down Expand Up @@ -84,6 +118,11 @@ private void animate() {
}
}

private void changeState(State state) {
prevState = this.state;
this.state = state;
}

@Override
public int getPriority() {
return PRIORITY;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package com.csse3200.game.components.tasks.MobTask;

public enum MobType {
SKELETON,
WIZARD,
WATER_QUEEN,
WATER_SLIME,
FIRE_WORM,
DRAGON_KNIGHT
SKELETON(true),
WIZARD(false),
WATER_QUEEN(false),
WATER_SLIME(true),
FIRE_WORM(false),
DRAGON_KNIGHT(true);
private boolean isMelee;

MobType(boolean melee) {
this.isMelee = melee;
}

public boolean isMelee() {
return isMelee;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import com.csse3200.game.components.tasks.MobDodgeTask;
import com.csse3200.game.components.tasks.MobMeleeAttackTask;
import com.csse3200.game.components.tasks.MobRangedAttackTask;
import com.csse3200.game.components.tasks.MobTask.MobMeleeTask;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.components.tasks.MobWanderTask;
import com.csse3200.game.components.tasks.bosstask.DemonBossTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.Melee;
import com.csse3200.game.entities.PredefinedWeapons;
Expand Down Expand Up @@ -296,13 +299,18 @@ public static Entity createDragonKnight(int health) {
public static Entity createGregMob(int health) {
Entity dragonKnight = createBaseNPC();
ArrayList<Currency> drops = new ArrayList<>();

AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService().getAsset("images/mobs/dragon_knight.atlas", TextureAtlas.class));
animator.addAnimation("dragon_knight_run", 0.1f, Animation.PlayMode.LOOP);
animator.addAnimation("dragon_knight_attack", 0.1f);
animator.addAnimation("dragon_knight_death", 0.1f);
animator.addAnimation("default", 0.1f);

AITaskComponent aiTaskComponent = new AITaskComponent()
.addTask(new MobMeleeTask(MobType.DRAGON_KNIGHT));

dragonKnight
.addComponent(new CombatStatsComponent(health, 10, drops))
.addComponent(animator)
Expand Down

0 comments on commit e08fd81

Please sign in to comment.