Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to change player type #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ shooter.iml
src/main/resources/**/*.png
src/main/resources/**/*.ogg
src/main/resources/**/*.fnt

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишнее

19 changes: 19 additions & 0 deletions nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
<netbeans.hint.jdkPlatform>JDK_11.0.2</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
49 changes: 49 additions & 0 deletions nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишнее

<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath aunmag.shooter.game.client.App mvn clean compile &amp;&amp; mvn compile exec:java</exec.args>
<exec.executable>java</exec.executable>
<exec.workingdir>"/home/fedot/Рабочий стол/Files/shooter"</exec.workingdir>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath aunmag.shooter.game.client.App mvn clean compile &amp;&amp; mvn compile exec:java</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
<exec.workingdir>"/home/fedot/Рабочий стол/Files/shooter"</exec.workingdir>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath aunmag.shooter.game.client.App mvn clean compile &amp;&amp; mvn compile exec:java</exec.args>
<exec.executable>java</exec.executable>
<exec.workingdir>"/home/fedot/Рабочий стол/Files/shooter"</exec.workingdir>
</properties>
</action>
</actions>
6 changes: 5 additions & 1 deletion src/main/java/aunmag/shooter/core/gui/PageStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public void back() {
}
}

public void remove(int index) {
pages.remove(index);
}

/* Setters */

public void setOnQuit(@Nullable Runnable onQuit) {
Expand All @@ -47,7 +51,7 @@ public void setOnQuit(@Nullable Runnable onQuit) {

/* Getters */

private int getCurrentIndex() {
public int getCurrentIndex() {
return pages.size() - 1;
}

Expand Down
26 changes: 25 additions & 1 deletion src/main/java/aunmag/shooter/game/client/states/Pause.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class Pause {

page.add(version)
page.add(buttonContinue)
page.add(Button(4, 8, 4, 1, "New game") { Context.main.application.newGame() })
page.add(Button(4, 8, 4, 1, "New game",
createCharacterSelectionPage()
::open))
page.add(Button(4, 9, 4, 1, "Help", createPageHelp()::open))
page.add(Button(4, 10, 4, 1, "Exit", createPageExit()::open))

Expand Down Expand Up @@ -75,6 +77,28 @@ class Pause {
return page
}

private fun createCharacterSelectionPage(): Page {
val wallpaper = Texture.getOrCreate(
"images/wallpapers/main_menu", Texture.Type.WALLPAPER
)
val page = Page(wallpaper)
// val style = FontStyle.LABEL_LIGHT

page.add(Label(3, 3, 6, 1, "Select your character"))
page.add(Button(4, 7, 4, 1, "Classic") {
// TODO: Set actor
Context.main.application.newGame()
Page.STACK.remove(Page.STACK.getCurrentIndex())
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
})
page.add(Button(4, 8, 4, 1, "Cowboy") {
// TODO: Set actor
Context.main.application.newGame()
Page.STACK.remove(Page.STACK.getCurrentIndex())
})

return page
}

private fun createPageExit(): Page {
val wallpaper = Texture.getOrCreate(
"images/wallpapers/exit", Texture.Type.WALLPAPER
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/aunmag/shooter/game/environment/actor/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public void update() {
hands.update();
updateWeapon();
updateAudioSource();
if (
type.genus != ActorType.Genus.Human
&& health < 0.15f
) {
health -= 0.00005f;
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
remove();
}
Expand Down Expand Up @@ -218,6 +224,9 @@ private void turn() {
}

private void move(double velocity, double radiansTurn) {
if (weapon != null && weapon.magazine.isReloading()) {
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
velocity *= 0.7;
}
if (control.isSprinting() && control.isWalkingForward()) {
float efficiency = this.stamina.calculateEfficiency();
velocity *= type.velocityFactorSprint * efficiency + (1 - efficiency);
Expand Down Expand Up @@ -307,6 +316,10 @@ public void setWeapon(Weapon weapon) {

/* Getters */

public World getWorld() {
return world;
}

public float getHealth() {
return health;
}
Expand Down
45 changes: 40 additions & 5 deletions src/main/java/aunmag/shooter/game/environment/actor/ActorType.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package aunmag.shooter.game.environment.actor;

import aunmag.shooter.core.structures.Texture;
import aunmag.shooter.game.environment.weapon.WeaponType;
import org.jetbrains.annotations.Nullable;

public class ActorType {

public static final float STRENGTH_DEFAULT = 7500;

public final String name;
public final Genus genus;
public final float radius;
public final float mass;
public final float strength;
Expand All @@ -15,20 +18,24 @@ public class ActorType {
public final float velocityRotation;
public final float damage;
public final float reaction;
@Nullable public final WeaponType primaryWeaponType;
public final Texture texture;

public ActorType(
String name,
Genus genus,
float radius,
float mass,
float strength,
float velocity,
float velocityFactorSprint,
float velocityRotation,
float damage,
float reaction
float reaction,
@Nullable WeaponType primaryWeaponType
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
) {
this.name = name;
this.genus = genus;
this.radius = radius;
this.mass = mass;
this.strength = strength;
Expand All @@ -37,6 +44,7 @@ public ActorType(
this.velocityRotation = velocityRotation;
this.damage = damage;
this.reaction = reaction;
this.primaryWeaponType = primaryWeaponType;

texture = Texture.getOrCreate("actors/" + name + "/image", Texture.Type.SPRITE);
}
Expand All @@ -45,50 +53,77 @@ public ActorType(

public static final ActorType human = new ActorType(
"human",
Genus.Human,
0.225f,
80_000,
STRENGTH_DEFAULT,
2.58f,
2.76f,
8,
STRENGTH_DEFAULT / 16f,
0.1f
0.1f,
WeaponType.pm
);

public static final ActorType humanCowboy = new ActorType(
"human cowboy",
Genus.Human,
human.radius,
0.9f * human.mass,
0.8f * human.strength,
1.1f * human.velocity,
1.2f * human.velocityFactorSprint,
1.2f * human.velocityRotation,
0.9f * human.damage,
1.2f * human.reaction,
WeaponType.coltSingleActionArmy
);

public static final ActorType zombie = new ActorType(
"zombie",
Genus.Zombie,
human.radius,
70_000,
0.4f * human.strength,
0.4f * human.velocity,
0.4f * human.velocityFactorSprint,
0.4f * human.velocityRotation,
human.strength / 8f,
0.2f
0.2f,
null
);

public static final ActorType zombieAgile = new ActorType(
"zombie agile",
Genus.Zombie,
0.8f * zombie.radius,
40_000,
0.6f * zombie.strength,
1.5f * zombie.velocity,
zombie.velocityFactorSprint,
2.5f * zombie.velocityRotation,
0.4f * zombie.damage,
0.1f
0.1f,
null
);

public static final ActorType zombieHeavy = new ActorType(
"zombie heavy",
Genus.Zombie,
1.2f * zombie.radius,
120_000,
2.0f * zombie.strength,
0.7f * zombie.velocity,
zombie.velocityFactorSprint,
0.7f * zombie.velocityRotation,
1.8f * zombie.damage,
0.3f
0.3f,
null
);


public enum Genus {
Human,
FedotSoldier marked this conversation as resolved.
Show resolved Hide resolved
Zombie
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public void reset() {
turningTo = null;
}

/* Setters */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем?

Copy link
Collaborator Author

@FedotSoldier FedotSoldier Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну там же сеттеры по сути. Я и перенес этот комментарий, чтобы он был над ними. Раньше был под ними.
Метод reset не включил под этот комментарий, потому что это общий метод сброса состояния. Неизвестно, что туда ещё добавится. А те методы, над которыми я этот комментарий перенес типичные сеттеры - конкретное поле устанавливается в конкретное значение

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

walkForward не принимает ведь аргументов, это не сеттер.


public void walkForward() {
isWalkingForward = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ protected ProjectileType(
0.08f
);

public static final ProjectileType _11_48x33mmR = new ProjectileType(
1,
25f,
3f,
0.1f
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,15 @@ protected WeaponType(
GRIP_OFFSET_EXTENDED
);

public static final WeaponType coltSingleActionArmy = new WeaponType(
"Colt SAA",
SEMI_AUTO_SHOTS_PER_MINUTE / 4,
450,
0.01f,
0.1f,
false,
new MagazineType(ProjectileType._11_48x33mmR, true, 6, 3f),
GRIP_OFFSET_STEP
);

}
35 changes: 19 additions & 16 deletions src/main/java/aunmag/shooter/game/scenarios/ScenarioEncircling.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,24 @@ class ScenarioEncircling(world: World) : Scenario(world) {

private fun updateZombiesTypes() {
val skillFactor = (difficulty - 1) * (wave - 1) + 1
zombie = creteZombieType(ActorType.zombie, skillFactor)
zombieAgile = creteZombieType(ActorType.zombieAgile, skillFactor)
zombieHeavy = creteZombieType(ActorType.zombieHeavy, skillFactor)
zombie = createZombieType(ActorType.zombie, skillFactor)
zombieAgile = createZombieType(ActorType.zombieAgile, skillFactor)
zombieHeavy = createZombieType(ActorType.zombieHeavy, skillFactor)
}

private fun creteZombieType(type: ActorType, skillFactor: Float): ActorType {
private fun createZombieType(type: ActorType, skillFactor: Float): ActorType {
return ActorType(
type.name,
type.genus,
type.radius,
type.mass,
skillFactor * type.strength,
skillFactor * type.velocity,
type.velocityFactorSprint,
type.velocityRotation,
type.damage,
type.reaction
type.reaction,
type.primaryWeaponType
)
}

Expand Down Expand Up @@ -191,19 +193,20 @@ class ScenarioEncircling(world: World) : Scenario(world) {
}

private fun selectRandomWeaponType(): WeaponType {
return when (UtilsMath.randomizeBetween(1, 2 * wave)) {
return when (UtilsMath.randomizeBetween(1, 2 * wave + 1)) {
1 -> WeaponType.pm
2 -> WeaponType.tt
3 -> WeaponType.mp43sawedOff
4 -> WeaponType.mp27
5 -> WeaponType.pp91kedr
6 -> WeaponType.pp19bizon
7 -> WeaponType.aks74u
8 -> WeaponType.ak74m
9 -> WeaponType.rpk74
10 -> WeaponType.saiga12k
11 -> WeaponType.pkm
12 -> WeaponType.pkpPecheneg
3 -> WeaponType.coltSingleActionArmy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Изначально планировалось что бы не первой волне были только пистолеты, на второй двуствольные ружья, далее ПП, и так далее

Copy link
Collaborator Author

@FedotSoldier FedotSoldier Jun 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сейчас все твои оружия могут выпасть только на тех же волнах как раньше. Плюс, к тем, которые могут выпасть на первой волне, добавляется револьвер.

4 -> WeaponType.mp43sawedOff
5 -> WeaponType.mp27
6 -> WeaponType.pp91kedr
7 -> WeaponType.pp19bizon
8 -> WeaponType.aks74u
9 -> WeaponType.ak74m
10 -> WeaponType.rpk74
11 -> WeaponType.saiga12k
12 -> WeaponType.pkm
13 -> WeaponType.pkpPecheneg
else -> WeaponType.laserGun
}
}
Expand Down