Skip to content

Commit 9b35366

Browse files
author
jzy
committed
Code init
1 parent fc7b0a0 commit 9b35366

File tree

92 files changed

+4290
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4290
-339
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.jzy.javalib</groupId>
2323
<artifactId>javalib-math</artifactId>
24-
<version>0.0.2</version>
24+
<version>0.0.4</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>org.dom4j</groupId>

src/main/java/com/jzy/ai/fma/BoundedSlotAssignmentStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.engine.math.Vector;
20+
21+
import com.jzy.javalib.math.geometry.Vector;
2122

2223
import java.util.List;
2324

src/main/java/com/jzy/ai/fma/Formation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
package com.jzy.ai.fma;
1818

19-
import com.game.ai.util.Location;
20-
import com.game.engine.math.Matrix3;
21-
import com.game.engine.math.Vector;
22-
import com.game.engine.math.Vector2;
23-
import com.game.engine.math.Vector3;
19+
20+
import com.jzy.ai.steer.Steerable;
21+
import com.jzy.ai.util.Location;
22+
import com.jzy.javalib.math.geometry.Matrix3;
23+
import com.jzy.javalib.math.geometry.Vector;
24+
import com.jzy.javalib.math.geometry.Vector2;
25+
import com.jzy.javalib.math.geometry.Vector3;
2426

2527
import java.util.ArrayList;
2628
import java.util.List;

src/main/java/com/jzy/ai/fma/FormationMember.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.ai.util.Location;
21-
import com.game.engine.math.Vector;
20+
import com.jzy.ai.util.Location;
21+
import com.jzy.javalib.math.geometry.Vector;
2222

2323
/**
2424
* 阵型成员<br>

src/main/java/com/jzy/ai/fma/FormationMotionModerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.ai.util.Location;
21-
import com.game.engine.math.Vector;
20+
21+
import com.jzy.ai.util.Location;
22+
import com.jzy.javalib.math.geometry.Vector;
2223

2324
import java.util.List;
2425

src/main/java/com/jzy/ai/fma/FormationPattern.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.ai.util.Location;
21-
import com.game.engine.math.Vector;
20+
import com.jzy.ai.util.Location;
21+
import com.jzy.javalib.math.geometry.Vector;
2222

2323
/** The {@code FormationPattern} interface represents the shape of a formation and generates the slot offsets, relative to its
2424
* anchor point. Since formations can be scalable the pattern must be able to determine if a given number of slots is supported.

src/main/java/com/jzy/ai/fma/FreeSlotAssignmentStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.engine.math.Vector;
20+
21+
import com.jzy.javalib.math.geometry.Vector;
2122

2223
import java.util.List;
2324

src/main/java/com/jzy/ai/fma/SlotAssignment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.engine.math.Vector;
20+
import com.jzy.javalib.math.geometry.Vector;
2121

2222
/**
2323
* 槽位分配<br>

src/main/java/com/jzy/ai/fma/SlotAssignmentStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.jzy.ai.fma;
1818

1919

20-
import com.game.engine.math.Vector;
20+
import com.jzy.javalib.math.geometry.Vector;
2121

2222
import java.util.List;
2323

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
22
* Copyright 2014 See AUTHORS file.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,68 +16,75 @@
1616

1717
package com.jzy.ai.fma.patterns;
1818

19-
import com.game.ai.fma.FormationPattern;
20-
import com.game.ai.util.Location;
21-
import com.game.engine.math.MathUtils;
22-
import com.game.engine.math.Vector;
19+
20+
import com.jzy.ai.fma.FormationPattern;
21+
import com.jzy.ai.util.Location;
22+
import com.jzy.javalib.base.util.MathUtil;
23+
import com.jzy.javalib.math.geometry.Vector;
2324

2425
/**
2526
* 防御圈阵型<br>
2627
* The defensive circle posts members around the circumference of a circle, so their backs are to the center of the circle. The
2728
* circle can consist of any number of members. Although a huge number of members might look silly, this implementation doesn't
2829
* put any fixed limit.
29-
*
30+
*
3031
* @param <T> Type of vector, either 2D or 3D, implementing the {@link Vector} interface
31-
*
32-
* @author davebaol */
32+
* @author davebaol
33+
*/
3334
public class DefensiveCircleFormationPattern<T extends Vector<T>> implements FormationPattern<T> {
34-
/** The number of slots currently in the pattern. */
35-
int numberOfSlots;
35+
/**
36+
* The number of slots currently in the pattern.
37+
*/
38+
int numberOfSlots;
3639

37-
/** The radius of one member. This is needed to determine how close we can pack a given number of members around circle. */
38-
float memberRadius;
40+
/**
41+
* The radius of one member. This is needed to determine how close we can pack a given number of members around circle.
42+
*/
43+
float memberRadius;
3944

40-
/** Creates a {@code DefensiveCircleFormationPattern}
41-
* @param memberRadius */
42-
public DefensiveCircleFormationPattern (float memberRadius) {
43-
this.memberRadius = memberRadius;
44-
}
45+
/**
46+
* Creates a {@code DefensiveCircleFormationPattern}
47+
*
48+
* @param memberRadius
49+
*/
50+
public DefensiveCircleFormationPattern(float memberRadius) {
51+
this.memberRadius = memberRadius;
52+
}
4553

46-
@Override
47-
public void setNumberOfSlots (int numberOfSlots) {
48-
this.numberOfSlots = numberOfSlots;
49-
}
54+
@Override
55+
public void setNumberOfSlots(int numberOfSlots) {
56+
this.numberOfSlots = numberOfSlots;
57+
}
5058

51-
@Override
52-
public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber) {
53-
if (numberOfSlots > 1) {
54-
// Place the slot around the circle based on its slot number
55-
float angleAroundCircle = (MathUtils.PI2 * slotNumber) / numberOfSlots;
59+
@Override
60+
public Location<T> calculateSlotLocation(Location<T> outLocation, int slotNumber) {
61+
if (numberOfSlots > 1) {
62+
// Place the slot around the circle based on its slot number
63+
float angleAroundCircle = (MathUtil.PI2 * slotNumber) / numberOfSlots;
5664

57-
// The radius depends on the radius of the member,
58-
// and the number of members in the circle:
59-
// we want there to be no gap between member's shoulders.
60-
float radius = memberRadius / (float)Math.sin(Math.PI / numberOfSlots);
65+
// The radius depends on the radius of the member,
66+
// and the number of members in the circle:
67+
// we want there to be no gap between member's shoulders.
68+
float radius = memberRadius / (float) Math.sin(Math.PI / numberOfSlots);
6169

62-
// Fill location components based on the angle around circle.
63-
outLocation.angleToVector(outLocation.getPosition(), angleAroundCircle).scl(radius);
70+
// Fill location components based on the angle around circle.
71+
outLocation.angleToVector(outLocation.getPosition(), angleAroundCircle).scl(radius);
6472

65-
// The members should be facing out
66-
outLocation.setOrientation(angleAroundCircle);
67-
}
68-
else {
69-
outLocation.getPosition().setZero();
70-
outLocation.setOrientation(MathUtils.PI2 * slotNumber);
71-
}
73+
// The members should be facing out
74+
outLocation.setOrientation(angleAroundCircle);
75+
} else {
76+
outLocation.getPosition().setZero();
77+
outLocation.setOrientation(MathUtil.PI2 * slotNumber);
78+
}
7279

73-
// Return the slot location
74-
return outLocation;
75-
}
80+
// Return the slot location
81+
return outLocation;
82+
}
7683

77-
@Override
78-
public boolean supportsSlots (int slotCount) {
79-
// In this case we support any number of slots.
80-
return true;
81-
}
84+
@Override
85+
public boolean supportsSlots(int slotCount) {
86+
// In this case we support any number of slots.
87+
return true;
88+
}
8289

8390
}

0 commit comments

Comments
 (0)