1 package SteeringProperties;
2
3 import SteeringStuff.SteeringType;
4 import XMLSteeringProperties.XMLWalkAlongProperties;
5 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
6
7
8
9
10
11 public class WalkAlongProperties extends SteeringProperties {
12
13
14 private int partnerForce;
15
16
17 private String partnerName;
18
19
20 private Location targetLocation;
21
22
23 private int distance;
24
25
26 private boolean giveWayToPartner;
27
28
29 private boolean waitForPartner;
30
31 public WalkAlongProperties() {
32 super(SteeringType.WALK_ALONG);
33 partnerForce = 200;
34 this.partnerName = "Partner";
35 targetLocation = new Location(9440,-10500,-3446.65);
36 distance = 500;
37 giveWayToPartner = false;
38 waitForPartner = false;
39 }
40
41 public WalkAlongProperties(BehaviorType behaviorType) {
42 super(SteeringType.WALK_ALONG, behaviorType);
43 partnerForce = 200;
44 this.partnerName = "Partner";
45 targetLocation = new Location(9440,-10500,-3446.65);
46 distance = 500;
47 giveWayToPartner = false;
48 waitForPartner = false;
49 setNewBehaviorType(behaviorType);
50 }
51
52 public WalkAlongProperties(XMLWalkAlongProperties xml) {
53 super(SteeringType.WALK_ALONG, xml.active, xml.weight, xml.behavior);
54 partnerForce = xml.attractiveForce;
55 partnerName = xml.partnerName;
56 targetLocation = new Location(xml.xTargetLocation,xml.yTargetLocation,xml.zTargetLocation);
57 distance = xml.distance;
58 giveWayToPartner = xml.giveWayToPartner;
59 waitForPartner = xml.waitForPartner;
60 }
61
62 public WalkAlongProperties(int partnerForce, String partnerName, Location targetLocation, int distanceFromThePartner, boolean giveWayToPartner, boolean waitForPartner) {
63 super(SteeringType.WALK_ALONG);
64 this.partnerForce = partnerForce;
65 this.partnerName = partnerName;
66 this.targetLocation = targetLocation;
67 this.distance = distanceFromThePartner;
68 this.giveWayToPartner = giveWayToPartner;
69 this.waitForPartner = waitForPartner;
70 }
71
72 protected void setNewBehaviorType(BehaviorType behaviorType) {
73 if (behaviorType.equals(BehaviorType.BASIC)) {
74 giveWayToPartner = false;
75 waitForPartner = false;
76 } else if (behaviorType.equals(BehaviorType.ADVANCED)) {
77 giveWayToPartner = true;
78 waitForPartner = true;
79 }
80 }
81
82 public int getPartnerForce() {
83 return partnerForce;
84 }
85
86 public void setPartnerForce(int attractiveForce) {
87 this.partnerForce = attractiveForce;
88 }
89
90 public int getDistanceFromThePartner() {
91 return distance;
92 }
93
94 public void setDistanceFromThePartner(int distanceFromThePartner) {
95 this.distance = distanceFromThePartner;
96 }
97
98 public Location getTargetLocation() {
99 return targetLocation;
100 }
101
102 public void setTargetLocation(Location targetLocation) {
103 this.targetLocation = targetLocation;
104 }
105
106 public String getPartnerName() {
107 return partnerName;
108 }
109
110 public void setPartnerName(String partnerName) {
111 this.partnerName = partnerName;
112 }
113
114 public boolean isGiveWayToPartner() {
115 return giveWayToPartner;
116 }
117
118 public void setGiveWayToPartner(boolean giveWayToPartner) {
119 this.giveWayToPartner = giveWayToPartner;
120 }
121
122 public boolean isWaitForPartner() {
123 return waitForPartner;
124 }
125
126 public void setWaitForPartner(boolean waitForPartner) {
127 this.waitForPartner = waitForPartner;
128 }
129
130 @Override
131 public String getSpecialText() {
132 String text = "";
133 text += " * Partner Force: " + partnerForce + "\n";
134 text += " * Partner: " + partnerName + "\n";
135 text += " * Target Location: " + targetLocation.toString() + "\n";
136 text += " * Distance: " + distance + "\n";
137 text += " * Give Way: " + giveWayToPartner + "\n";
138 text += " * Wait for Partner: " + waitForPartner + "\n";
139 return text;
140 }
141
142 @Override
143 public void setProperties(SteeringProperties newProperties) {
144 this.partnerForce = ((WalkAlongProperties)newProperties).getPartnerForce();
145 this.partnerName = ((WalkAlongProperties)newProperties).getPartnerName();
146 this.targetLocation = ((WalkAlongProperties)newProperties).getTargetLocation();
147 this.distance = ((WalkAlongProperties)newProperties).getDistanceFromThePartner();
148 this.giveWayToPartner = ((WalkAlongProperties)newProperties).isGiveWayToPartner();
149 this.waitForPartner = ((WalkAlongProperties)newProperties).isWaitForPartner();
150 }
151
152 public XMLWalkAlongProperties getXMLProperties() {
153 XMLWalkAlongProperties xmlProp = new XMLWalkAlongProperties();
154 xmlProp.attractiveForce = partnerForce;
155 xmlProp.partnerName = partnerName;
156 xmlProp.distance = distance;
157 xmlProp.xTargetLocation = (int) targetLocation.x;
158 xmlProp.yTargetLocation = (int) targetLocation.y;
159 xmlProp.zTargetLocation = (int) targetLocation.z;
160 xmlProp.giveWayToPartner = giveWayToPartner;
161 xmlProp.waitForPartner = waitForPartner;
162 xmlProp.active = active;
163 xmlProp.weight = weight;
164 xmlProp.behavior = behaviorType;
165 return xmlProp;
166 }
167 }