@@ -3,6 +3,7 @@ import Phaser from 'phaser';
33import { key } from '../constants' ;
44import { Inventory } from './Player' ;
55import { EventBus } from '../EventBus' ;
6+ import { recorder } from '../utils/recorder' ;
67
78enum Animation {
89 Left = 'player_left' ,
@@ -45,49 +46,6 @@ export class Agent extends Phaser.Physics.Arcade.Sprite {
4546 public static currentBiasedAgent : Agent | null = null ; // Reservation: pointing to the "last selected"
4647
4748
48- private agentInformation :string = "aaaaaaa" ;
49-
50- public addMssgSprite ( scene : Phaser . Scene , texture : string , frame ?: string | number ) {
51- if ( this . mssgSprite ) {
52- console . log ( "Updating message sprite for agent:" , this . name ) ;
53- this . mssgSprite . setTexture ( texture , frame ) ;
54-
55- this . mssgSprite . removeAllListeners ( ) ;
56- this . mssgSprite . disableInteractive ( ) ;
57-
58- if ( texture === "agent_mssg" ) {
59- this . mssgSprite . setInteractive ( { useHandCursor : true } ) ;
60- this . mssgSprite . on ( 'pointerdown' , ( ) => {
61- console . log ( `Message sprite of ${ this . name } clicked!` ) ;
62- this . changeNameTagColor ( '#00ff00' ) ;
63- EventBus . emit ( "open-agent-information" , {
64- agent : this . name
65- } ) ;
66- } ) ;
67- }
68- return ;
69- }
70-
71- console . log ( "Adding message sprite to agent:" , this . name ) ;
72- this . mssgSprite = scene . add . image ( this . x , this . y , texture , frame )
73- . setOrigin ( 0.5 , 1 )
74- . setDepth ( 10 ) ;
75-
76- if ( texture === "agent_mssg" ) {
77- this . mssgSprite . setInteractive ( { useHandCursor : true } ) ;
78- this . mssgSprite . on ( 'pointerdown' , ( ) => {
79- console . log ( `Message sprite of ${ this . name } clicked!` ) ;
80- this . changeNameTagColor ( '#00ff00' ) ;
81- EventBus . emit ( "open-agent-information" , {
82- agent : this . name
83- } ) ;
84- } ) ;
85- }
86- }
87- public static biasedAgentsCount : number = 0 ; // Calculate the current number of biased agents in this level
88-
89-
90-
9149 private agentInformation :string = "aaaaaaa" ;
9250
9351 public addMssgSprite ( scene : Phaser . Scene , texture : string , frame ?: string | number ) {
@@ -159,19 +117,6 @@ export class Agent extends Phaser.Physics.Arcade.Sprite {
159117 }
160118
161119
162- public getAgentInformation ( ) {
163- return this . agentInformation ;
164- }
165-
166- public setAgentInformation ( info : string ) {
167- this . agentInformation = info ;
168- EventBus . emit ( "agent-information" , {
169- agent : this . name ,
170- mssg : this . getAgentInformation ( )
171- } ) ;
172- }
173-
174-
175120public playDialogue (
176121 scene : Phaser . Scene ,
177122 text : string ,
@@ -448,6 +393,9 @@ update() {
448393 }
449394
450395 private onClick ( pointer : Phaser . Input . Pointer , gameObject : Phaser . GameObjects . GameObject ) {
396+
397+ recorder . recordEvent ( "agent_clicked" ) ;
398+
451399 if ( gameObject !== this ) return ;
452400 if ( this . isBiased ) return ;
453401
0 commit comments