Beispiel #1
0
 public override void OnCreate(GameObject gameObj)
 {
     base.OnCreate(gameObj);
     position      = new Vector3((float)random.NextDouble() * width, (float)random.NextDouble() * height, 0.0f);
     this.mediator = this.gameObject.UserMediator;
     this.session  = this.mediator.GetSession(this.gameObject.Name);
     condition     = this.AddComponent <UserCondition>() as UserCondition;
     coll          = this.AddComponent <Circle2DCollider>() as Circle2DCollider;
     coll.SetCollider(position, CharacterRadius);
 }
Beispiel #2
0
        public void Shot(Vector3 dir, Vector3 pos, string ownerNickname)
        {
            direction = dir;
            position  = pos + (direction * speed * this.gameObject.DeltaTime);

            coll = this.AddComponent <Circle2DCollider>() as Circle2DCollider;
            coll.CollideCallback += OnCollide;
            coll.SetCollider(position, 0.2f);

            firedTime = this.gameObject.GameTime;

            Packet shotPacket = new Packet(Packet.HEADER.GAME_BULLET_FIRE, Config.MAX_SESSION_BUFFER_SIZE);

            shotPacket.Push(this.gameObject.id);
            shotPacket.Push(position.X);
            shotPacket.Push(position.Y);
            shotPacket.Push(direction.X);
            shotPacket.Push(direction.Y);

            this.gameObject.UserMediator.BroadCast(shotPacket);
            this.ownerNickname = ownerNickname;
        }