Changeset 905
- Timestamp:
- 02/01/2011 03:08:18 PM (10 years ago)
- Location:
- scenarios/GerminationX
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
scenarios/GerminationX/fungi/src/Fungi.hx
r873 r905 85 85 tf.border = true; 86 86 tf.wordWrap = true; 87 tf.autoSize = flash.text.TextFieldAutoSize.LEFT; 88 var t = new flash.text.TextFormat(); 89 t.font = "Verdana"; 90 t.size = 8; 91 t.color= 0x000000; 92 tf.setTextFormat(t); 87 93 Spr.parent.addChild(tf); 88 94 tf.visible=false; … … 141 147 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 142 148 143 class Ghost extends SpriteEntity149 class Spirit extends SkeletonEntity 144 150 { 145 151 public var Name:String; 146 152 var Debug:flash.text.TextField; 147 public var TexBase:String; 148 149 public function new(world:World, name:String,pos) 150 { 151 TexBase="ghost-"+name.toLowerCase(); 152 super(world,pos,Resources.Get(TexBase)); 153 154 public function new(world:World, name:String, pos) 155 { 156 super(world,pos); 153 157 Name = name; 154 155 Debug = new flash.text.TextField(); 156 Debug.wordWrap=true; 157 Debug.y=-50; 158 Debug.width=300; 159 Debug.text = "nothing yet"; 160 Spr.addChild(Debug); 158 } 159 160 public function BuildDebug(c) 161 { 162 var tf = new flash.text.TextField(); 163 tf.text = "nowt yet."; 164 tf.x=Pos.x-50; 165 tf.y=Pos.y-25; 166 tf.height=150; 167 tf.width=100; 168 tf.background = true; 169 tf.autoSize = flash.text.TextFieldAutoSize.LEFT; 170 //tf.backgroundColor = 0x8dd788; 171 tf.border = true; 172 tf.wordWrap = true; 173 var t = new flash.text.TextFormat(); 174 t.font = "Verdana"; 175 t.size = 8; 176 t.color= 0x000000; 177 tf.setTextFormat(t); 178 c.addChild(tf); 179 Debug=tf; 180 /*tf.visible=false; 181 Root.MouseOver(this,function(c) { tf.visible=true; }); 182 Root.MouseOut(this,function(c) { tf.visible=false; });*/ 183 184 Root.MouseDown(c,function(c) 185 { 186 trace("perc..."); 187 c.Server.Request("perceive",1,function(c,d){}); 188 }); 161 189 } 162 190 … … 165 193 var ee = e.emotions.content; 166 194 var mood=Std.parseFloat(ee[0].content[0]); 167 if (mood>1) Spr.ChangeBitmap(Resources.Get(TexBase+"-happy")); 168 else if (mood<-1) Spr.ChangeBitmap(Resources.Get(TexBase+"-sad")); 169 else Spr.ChangeBitmap(Resources.Get(TexBase)); 170 171 Debug.text=Name+"\nMood:"+ee[0].content[0]+"\n"; 195 196 var text=Name+"\nMood:"+ee[0].content[0]+"\n"; 172 197 173 198 for (i in 1...ee.length) 174 199 { 175 Debug.text+=ee[i].attrs.type+" "+ee[i].attrs.direction+"\n"; 176 Debug.text+=ee[i].attrs.cause+"\n"; 177 } 200 text+=ee[i].attrs.type+" "+ee[i].attrs.direction+"\n"; 201 text+=ee[i].attrs.cause+"\n"; 202 } 203 204 Debug.text=text; 205 206 var t = new flash.text.TextFormat(); 207 t.font = "Verdana"; 208 t.size = 8; 209 t.color= 0x000000; 210 Debug.setTextFormat(t); 211 212 213 //trace(text); 178 214 } 179 215 } … … 247 283 var Frame:Int; 248 284 var TickTime:Int; 249 var Ghosts:Array<Ghost>; 285 var PerceiveTime:Int; 286 var Spirits:Array<Spirit>; 250 287 public var Seeds:SeedStore; 251 288 var Server : ServerConnection; … … 256 293 Frame=0; 257 294 TickTime=0; 295 PerceiveTime=0; 258 296 Width=w; 259 297 Height=h; 260 298 Plants = []; 261 299 Objs = []; 262 Ghosts = [];300 Spirits = []; 263 301 Seeds = new SeedStore(1); 264 302 WorldPos = new Vec3(0,0,0); … … 307 345 UpdateWorld(new Vec3(0,0,0)); 308 346 309 var Names = ["Vertical","Canopy","Cover"];310 /*311 for (i in 0...3)312 {313 var g = new Ghost(this,Names[i],new Vec3(2,(i*3)+2,1));314 Ghosts.push(g);315 }316 */317 347 MyTextEntry=new TextEntry(300,10,310,30,NameCallback); 318 348 addChild(MyTextEntry); … … 320 350 Update(0); 321 351 SortScene(); 322 Server.Request("spirit-sprites",this,UpdateSpiritSprites); 352 var names = ["CanopySpirit","CoverSpirit","VerticalSpirit"]; 353 var positions = [new Vec3(0,5,4), new Vec3(7,0,4), new Vec3(2,10,4)]; 354 355 for (i in 0...3) 356 { 357 Server.Request("spirit-sprites/"+names[i], 358 this, 359 function (c,data:Array<Dynamic>) 360 { 361 var sp:Spirit = new Spirit(c,names[i],positions[i]); 362 sp.NeedsUpdate=true; 363 sp.Build(c,data); 364 sp.BuildDebug(c); 365 c.SortScene(); 366 c.Spirits.push(sp); 367 }); 368 } 323 369 } 324 370 … … 398 444 return Objs[cast(pos.x+pos.y*Width,Int)]; 399 445 } 400 401 public function UpdateSpiritSprites(c,data:Array<Dynamic>) 402 { 403 var sk:SkeletonEntity = new SkeletonEntity(this,new Vec3(0,5,4)); 404 sk.NeedsUpdate=true; 405 sk.Build(this,data); 406 SortScene(); 407 } 408 446 409 447 public function SpaceClear(pos:Vec3) 410 448 { … … 422 460 } 423 461 424 public function UpdateGhosts( t:Dynamic)462 public function UpdateGhosts(c,t:Dynamic) 425 463 { 426 464 for(i in 0...t.length) 427 465 { 428 for (g in Ghosts)466 for (g in Spirits) 429 467 { 430 468 if (g.Name==t[i].name) … … 444 482 if (time>TickTime) 445 483 { 446 //WorldClient.Call("agent-info",UpdateGhosts);484 Server.Request("spirit-info",this,UpdateGhosts); 447 485 448 486 Server.Request("get-tile/"+Std.string(cast(WorldPos.x,Int))+"/" -
scenarios/GerminationX/fungi/src/truffle/SkeletonEntity.hx
r820 r905 24 24 var g:Graph; 25 25 var bones:Array<Bone>; 26 public var Id:Int; 26 27 27 28 public function new(world:World,pos:Vec3) … … 29 30 super(world,pos); 30 31 Root = null; 32 // hack for the animation 33 Id=cast(pos.y,Int); 31 34 } 32 35 … … 135 138 136 139 //UpdateDepth(); 140 var c=this; 137 141 138 142 Root.Recurse(function(b:Bone,depth:Int) 139 143 { 140 b.SetRotate(15*Math.sin((10-depth)*0.58+frame* 0.04));144 b.SetRotate(15*Math.sin((10-depth)*0.58+frame*(0.04+0.01*c.Id))); 141 145 } 142 146 ); -
scenarios/GerminationX/oak/data/characters/minds/roles/CanopySpirit/CanopySpirit.xml
r904 r905 1 1 <Character role="CanopySpirit"> 2 2 <EmotionalThresholds> 3 <EmotionalThreshold emotion="Love" threshold=" 1" decay="10"/>3 <EmotionalThreshold emotion="Love" threshold="0" decay="10"/> 4 4 <EmotionalThreshold emotion="Hate" threshold="0" decay="5"/> 5 5 <EmotionalThreshold emotion="Hope" threshold="3" decay="2"/> … … 44 44 45 45 <!-- General emotional reactions used in more than one episode --> 46 46 <!-- 47 47 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> 48 48 <Event subject="*" action="flower"/> … … 52 52 <Event subject="*" action="drop-leaves"/> 53 53 </EmotionalReaction> 54 54 --> 55 55 </EventReactions> 56 56 -
scenarios/GerminationX/oak/data/characters/minds/roles/CoverSpirit/CoverSpirit.xml
r904 r905 1 1 <Character role="CoverSpirit"> 2 2 <EmotionalThresholds> 3 <EmotionalThreshold emotion="Love" threshold=" 3" decay="5"/>4 <EmotionalThreshold emotion="Hate" threshold=" 2" decay="5"/>3 <EmotionalThreshold emotion="Love" threshold="0" decay="5"/> 4 <EmotionalThreshold emotion="Hate" threshold="0" decay="5"/> 5 5 <EmotionalThreshold emotion="Hope" threshold="1" decay="2"/> 6 6 <EmotionalThreshold emotion="Fear" threshold="5" decay="8"/> … … 44 44 45 45 <!-- General emotional reactions used in more than one episode --> 46 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5">46 <!-- <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> 47 47 <Event subject="*" action="flower"/> 48 48 </EmotionalReaction> … … 51 51 <Event subject="*" action="drop-leaves"/> 52 52 </EmotionalReaction> 53 53 --> 54 54 </EventReactions> 55 55 -
scenarios/GerminationX/oak/data/characters/minds/roles/VerticalSpirit/VerticalSpirit.xml
r904 r905 1 1 <Character role="VerticalSpirit"> 2 2 <EmotionalThresholds> 3 <EmotionalThreshold emotion="Love" threshold=" 3" decay="5"/>4 <EmotionalThreshold emotion="Hate" threshold=" 2" decay="5"/>3 <EmotionalThreshold emotion="Love" threshold="0" decay="5"/> 4 <EmotionalThreshold emotion="Hate" threshold="0" decay="5"/> 5 5 <EmotionalThreshold emotion="Hope" threshold="1" decay="2"/> 6 6 <EmotionalThreshold emotion="Fear" threshold="5" decay="8"/> … … 42 42 43 43 <EventReactions> 44 45 <!-- General emotional reactions used in more than one episode -->44 <!-- 45 46 46 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> 47 47 <Event subject="*" action="flower"/> … … 51 51 <Event subject="*" action="drop-leaves"/> 52 52 </EmotionalReaction> 53 53 --> 54 54 </EventReactions> 55 55 -
scenarios/GerminationX/oak/src/oak/core.clj
r904 r905 44 44 (defn tick [] 45 45 (Thread/sleep 1000) 46 (println ".") 46 47 ;(game-world-print (deref my-game-world)) 47 48 (let [time (.getTime (java.util.Date.))] … … 59 60 (recur)) 60 61 61 (tick)62 ;(tick) 62 63 63 64 (defroutes main-routes … … 69 70 (json/encode-to-str tile) 70 71 (json/encode-to-str '())))) 72 71 73 (GET "/make-plant/:tilex/:tiley/:posx/:posy/:type/:owner/:size" 72 74 [tilex tiley posx posy type owner size] 73 (println "making plant...")74 75 (append-spit 75 76 log-filename … … 86 87 ;(println (deref my-game-world)) 87 88 (json/encode-to-str '("ok"))) 89 88 90 (GET "/spirit-sprites/:name" [name] 89 91 (update-islands (str "./" name) (str "./" name)) 90 (read-islands "./public/" name))92 (read-islands (str "./public/" name))) 91 93 92 94 (GET "/spirit-info" [] … … 95 97 {:name (remote-agent-name a) 96 98 :emotions (remote-agent-emotions a)}) 97 (world-agents (deref myworld)))99 (world-agents (deref fatima-world))) 98 100 :indent 2)) 99 101 (GET "/perceive" [] 100 (world-perceive-all (deref myworld))) 102 (world-perceive-all (deref fatima-world)) 103 (json/encode-to-str '("ok"))) 101 104 102 105 (comment … … 112 115 (run-jetty (wrap-file main-routes "public") {:port 8001})) 113 116 (fn [] 114 (tick) (println "DONE TICK")))]117 (tick)))] 115 118 116 119 (doseq [future (.invokeAll pool tasks)] -
scenarios/GerminationX/oak/src/oak/forms.clj
r904 r905 26 26 (defn max-cons [o l m] 27 27 (cons o (discard l m))) 28 29 (defn gg [] 30 (let [i (atom 0)] 31 (fn [] (swap! i inc)))) 32 33 (def generate-id (gg)) -
scenarios/GerminationX/oak/src/oak/game_world.clj
r904 r905 132 132 (do 133 133 (world-add-object fw 134 {"name" (str (:layer entity) "-" (:state entity) )134 {"name" (str (:layer entity) "-" (:state entity) "-" (str (:id entity))) 135 135 "owner" (:layer entity) 136 136 "position" (str (:x (:pos entity)) "," (:y (:pos entity))) -
scenarios/GerminationX/oak/src/oak/io.clj
r904 r905 98 98 (defn read-msg [reader] 99 99 (let [r (.readLine reader)] 100 (println "<----------------- " r)100 ;(println "<----------------- " r) 101 101 r)) 102 102 103 103 (defn send-msg [sc msg] 104 (println "----------------> " msg)104 ;(println "----------------> " msg) 105 105 (let [msg (str msg "\n") 106 106 enc (.newEncoder (Charset/forName "US-ASCII"))] 107 107 (.write sc (.encode enc (CharBuffer/wrap msg))))) 108 109 (let [i (atom 0)]110 (defn generate-id []111 (swap! i inc)))112 108 113 109 (defn load-object [fname] -
scenarios/GerminationX/oak/src/oak/plant.clj
r904 r905 27 27 28 28 (defrecord plant 29 [pos 29 [id 30 pos 30 31 type 31 32 layer … … 53 54 54 55 (defn make-plant [pos type owner size] 55 (plant. pos type (plant-type->layer type)56 (plant. (generate-id) pos type (plant-type->layer type) 56 57 'grow-a '() owner size 0 (+ 30 (Math/floor (rand 10))) start-health)) 57 58 -
scenarios/GerminationX/oak/src/oak/spirit.clj
r900 r905 35 35 36 36 (defn spirit-update [spirit remote-agent] 37 ( commentprintln (:name spirit))37 (println (:name spirit)) 38 38 (println (map 39 39 (fn [emotion] -
scenarios/GerminationX/oak/src/oak/world.clj
r904 r905 130 130 (reduce 131 131 (fn [r obj] 132 (if (and (not r) (and (= name (get obj "name")) 133 (= pos (get obj "position")))) 132 (if (and (not r) (= pos (get obj "position"))) 134 133 obj r)) 135 134 false
Note: See TracChangeset
for help on using the changeset viewer.