• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂f7ff312b9d09cc026badcecf8d51136d59792847 (tree)
時間2021-08-05 07:04:15
作者sebastian_bugiu
Commitersebastian_bugiu

Log Message

Added AI now prioritize the enemy cargo ships. Added some performance indicators.

Change Summary

差異

diff -r 6ebc2563a247 -r f7ff312b9d09 core/src/headwayent/blackholedarksun/APP_Game.java
--- a/core/src/headwayent/blackholedarksun/APP_Game.java Mon Aug 02 23:06:57 2021 +0300
+++ b/core/src/headwayent/blackholedarksun/APP_Game.java Thu Aug 05 01:04:15 2021 +0300
@@ -978,7 +978,7 @@
978978 }
979979
980980 protected void initializeGson() {
981- final GsonBuilder gsonBuilder = new GsonBuilder();
981+ final GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting();
982982 gson = gsonBuilder.create();
983983 }
984984
diff -r 6ebc2563a247 -r f7ff312b9d09 core/src/headwayent/blackholedarksun/APP_SinglePlayerGame.java
--- a/core/src/headwayent/blackholedarksun/APP_SinglePlayerGame.java Mon Aug 02 23:06:57 2021 +0300
+++ b/core/src/headwayent/blackholedarksun/APP_SinglePlayerGame.java Thu Aug 05 01:04:15 2021 +0300
@@ -33,6 +33,8 @@
3333 import headwayent.blackholedarksun.net.NetManager;
3434 import headwayent.blackholedarksun.net.clientapi.ClientAPI;
3535 import headwayent.blackholedarksun.physics.PhysicsUtility;
36+import headwayent.blackholedarksun.statistics.InGameStatistics;
37+import headwayent.blackholedarksun.statistics.InGameStatisticsManager;
3638 import headwayent.blackholedarksun.systems.*;
3739 import headwayent.blackholedarksun.world.WorldManager;
3840 import headwayent.blackholedarksun.world.WorldManagerBase;
@@ -544,6 +546,14 @@
544546 hudManager.updateRadarFinalState();
545547 hudManager.unlockRadarData();
546548
549+ renderWindow.updateStats();
550+
551+ InGameStatisticsManager statisticsManager = InGameStatisticsManager.getInstance();
552+ InGameStatistics statistics = statisticsManager.getInGameStatistics();
553+ statistics.performanceStatistics.averageFps = renderWindow.getAverageFPS();
554+ statistics.performanceStatistics.maxFps = renderWindow.getBestFPS();
555+ statistics.performanceStatistics.minFps = renderWindow.getWorstFPS();
556+
547557 if (HudManager.SHOW_DEBUGGING_INDICATORS) {
548558 hudManager.setFps(renderWindow.getLastFPS());
549559 // System.out.println("LastFPS: " + renderWindow.getLastFPS());
diff -r 6ebc2563a247 -r f7ff312b9d09 core/src/headwayent/blackholedarksun/gamestatedebugger/FrameInterval.java
--- a/core/src/headwayent/blackholedarksun/gamestatedebugger/FrameInterval.java Mon Aug 02 23:06:57 2021 +0300
+++ b/core/src/headwayent/blackholedarksun/gamestatedebugger/FrameInterval.java Thu Aug 05 01:04:15 2021 +0300
@@ -115,6 +115,7 @@
115115 public static final String SPHERE_AROUND_POINT_SIGNUM_X = "sphere_around_point_signum_x";
116116 public static final String SPHERE_AROUND_POINT_SIGNUM_Y = "sphere_around_point_signum_y";
117117 public static final String SPHERE_AROUND_POINT_SIGNUM_Z = "sphere_around_point_signum_z";
118+ public static final String CARGO_SHIP_SELECT_CLOSEST = "cargo_ship_select_closest ";
118119
119120 // private HashMap<String, AIEntity> aiEntityMap = new HashMap<>();
120121 // private HashMap<String, TrackerEntity> trackerEntityMap = new HashMap<>();
diff -r 6ebc2563a247 -r f7ff312b9d09 core/src/headwayent/blackholedarksun/systems/AISystem.java
--- a/core/src/headwayent/blackholedarksun/systems/AISystem.java Mon Aug 02 23:06:57 2021 +0300
+++ b/core/src/headwayent/blackholedarksun/systems/AISystem.java Thu Aug 05 01:04:15 2021 +0300
@@ -1,5 +1,6 @@
11 package headwayent.blackholedarksun.systems;
22
3+import headwayent.blackholedarksun.entitydata.ShipData;
34 import headwayent.blackholedarksun.entitydata.ShipData.ShipTeam;
45 import headwayent.blackholedarksun.entitydata.WeaponData;
56 import headwayent.blackholedarksun.entitydata.WeaponData.WeaponType;
@@ -714,20 +715,43 @@
714715 // Find smallest distance
715716 long closestEnemy = -1;
716717 int enemyTeamSize = entities.size();
718+ currentMinLen = Float.MAX_VALUE;
717719 for (int i = 0; i < enemyTeamSize; ++i) {
718720 Entity entity = entities.get(i);
719721 EntityProperties otherShipEntityProperties = entityPropertiesMapper.get(entity);
720- ShipProperties otherShipShipProperties = shipPropertiesMapper.get(entity);
721-
722- otherShipEntityProperties.getNode().getPosition(otherPos);
723- otherPos.sub(currentPos, distVec);
724- if (i == 0) {
725- currentMinLen = distVec.squaredLength();
726- closestEnemy = otherShipEntityProperties.getItemId();
727- } else {
728- if (distVec.squaredLength() < currentMinLen) {
722+ ShipProperties otherShipShipProperties = shipPropertiesMapper.getSafe(entity);
723+ if (otherShipShipProperties != null && otherShipShipProperties.getShipData().shipType == ShipData.ShipType.CARGO) {
724+ // Try to prioritize the enemy cargo ship.
725+ if (i == 0) {
729726 currentMinLen = distVec.squaredLength();
730727 closestEnemy = otherShipEntityProperties.getItemId();
728+ } else {
729+ if (distVec.squaredLength() < currentMinLen) {
730+ currentMinLen = distVec.squaredLength();
731+ closestEnemy = otherShipEntityProperties.getItemId();
732+ }
733+ }
734+ }
735+ }
736+ if ((closestEnemy == -1) ||
737+ (closestEnemy != -1 &&
738+ ENG_Utility.getRandom().nextInt(FrameInterval.CARGO_SHIP_SELECT_CLOSEST + entityProperties.getNode().getName(), 3) == 0)) {
739+ for (int i = 0; i < enemyTeamSize; ++i) {
740+ Entity entity = entities.get(i);
741+ EntityProperties otherShipEntityProperties = entityPropertiesMapper.get(entity);
742+// ShipProperties otherShipShipProperties = shipPropertiesMapper.get(entity);
743+
744+ otherShipEntityProperties.getNode().getPosition(otherPos);
745+ otherPos.sub(currentPos, distVec);
746+
747+ if (i == 0) {
748+ currentMinLen = distVec.squaredLength();
749+ closestEnemy = otherShipEntityProperties.getItemId();
750+ } else {
751+ if (distVec.squaredLength() < currentMinLen) {
752+ currentMinLen = distVec.squaredLength();
753+ closestEnemy = otherShipEntityProperties.getItemId();
754+ }
731755 }
732756 }
733757 }
diff -r 6ebc2563a247 -r f7ff312b9d09 core/src/headwayent/blackholedarksun/world/WorldManagerBase.java
--- a/core/src/headwayent/blackholedarksun/world/WorldManagerBase.java Mon Aug 02 23:06:57 2021 +0300
+++ b/core/src/headwayent/blackholedarksun/world/WorldManagerBase.java Thu Aug 05 01:04:15 2021 +0300
@@ -1102,23 +1102,25 @@
11021102 levelEvent.state = LevelEvent.EventState.LOST;
11031103 }
11041104
1105- InGameStatistics statistics = InGameStatisticsManager.getInstance().getInGameStatistics();
1106- SessionStatistics latestSessionStatistics = statistics.getLatestSessionStatistics();
1107- if (latestSessionStatistics != null) {
1108- LevelStatistics latestLevelStatistics = latestSessionStatistics.getLatestLevelStatistics();
1109- if (latestLevelStatistics != null) {
1110- LevelEventStatistics latestLevelEventStatistics = latestLevelStatistics.getLatestLevelEventStatistics();
1111- if (latestLevelEventStatistics != null) {
1112- latestLevelEventStatistics.state = levelEvent.state.toString();
1113- latestLevelEventStatistics.levelEventEndDate = ENG_DateUtils.getCurrentDateTimestamp();
1114- latestLevelEventStatistics.levelEventDuration = ENG_Utility.currentTimeMillis() - latestLevelEventStatistics.levelEventBeginTime;
1105+ if (eventWon || eventLost) {
1106+ InGameStatistics statistics = InGameStatisticsManager.getInstance().getInGameStatistics();
1107+ SessionStatistics latestSessionStatistics = statistics.getLatestSessionStatistics();
1108+ if (latestSessionStatistics != null) {
1109+ LevelStatistics latestLevelStatistics = latestSessionStatistics.getLatestLevelStatistics();
1110+ if (latestLevelStatistics != null) {
1111+ LevelEventStatistics latestLevelEventStatistics = latestLevelStatistics.getLatestLevelEventStatistics();
1112+ if (latestLevelEventStatistics != null) {
1113+ latestLevelEventStatistics.state = levelEvent.state.toString();
1114+ latestLevelEventStatistics.levelEventEndDate = ENG_DateUtils.getCurrentDateTimestamp();
1115+ latestLevelEventStatistics.levelEventDuration = ENG_Utility.currentTimeMillis() - latestLevelEventStatistics.levelEventBeginTime;
11151116
1116- updateWeaponData(latestLevelEventStatistics, latestLevelEventStatistics.weaponTypeStatisticsEventEndList);
1117+ updateWeaponData(latestLevelEventStatistics, latestLevelEventStatistics.weaponTypeStatisticsEventEndList);
11171118
1118- Entity entity = getEntity(playerShipEntityId);
1119- if (entity != null) {
1120- EntityProperties entityProperties = entityPropertiesComponentMapper.get(entity);
1121- latestLevelEventStatistics.healthEventEnd = entityProperties.getHealth();
1119+ Entity entity = getEntity(playerShipEntityId);
1120+ if (entity != null) {
1121+ EntityProperties entityProperties = entityPropertiesComponentMapper.get(entity);
1122+ latestLevelEventStatistics.healthEventEnd = entityProperties.getHealth();
1123+ }
11221124 }
11231125 }
11241126 }