Exemplo n.º 1
0
        /// <summary>
        ///   The set state world entered.
        /// </summary>
        /// <param name = "worldData">
        ///   The world Data.
        /// </param>
        public void SetStateWorldEntered(WorldData worldData)
        {
            this.WorldData     = worldData;
            this.stateStrategy = WorldEntered.Instance;
            InterestArea camera;

            this.cameras.TryGetValue(0, out camera);
            camera.ResetViewDistance();

            var r        = new Random();
            var position = new float[]
            {
                r.Next((int)this.WorldData.TopLeftCorner[0], (int)this.WorldData.BottomRightCorner[0]),
                r.Next((int)this.WorldData.TopLeftCorner[1], (int)this.WorldData.BottomRightCorner[1])
            };

            this.avatar.SetPositions(position, position, null, null);

            this.listener.OnWorldEntered(this);
        }
Exemplo n.º 2
0
        public void OnOperationResponse(OperationResponse response)
        {
            try
            {
                if (this.listener.IsDebugLogEnabled)
                {
                    this.listener.LogDebug(string.Format("{0}: received return {1}", this.avatar.Id, response.ReturnCode));
                }

                if (response.ReturnCode == 0)
                {
                    string itemId;
                    switch ((OperationCode)response.OperationCode)
                    {
                    case OperationCode.CreateWorld:
                        this.EnterWorld();
                        return;

                    case OperationCode.EnterWorld:
                        var worldData = new WorldData
                        {
                            Name           = (string)response.Parameters[(byte)ParameterCode.WorldName],
                            BoundingBox    = (BoundingBox)response.Parameters[(byte)ParameterCode.BoundingBox],
                            TileDimensions = (Vector)response.Parameters[(byte)ParameterCode.TileDimensions]
                        };
                        this.SetStateWorldEntered(worldData);
                        return;

                    case OperationCode.RemoveInterestArea:
                    case OperationCode.AddInterestArea:
                        return;

                    case OperationCode.AttachInterestArea:
                        itemId = (string)response[(byte)ParameterCode.ItemId];
                        this.OnCameraAttached(itemId);
                        return;

                    case OperationCode.DetachInterestArea:
                        this.OnCameraDetached();
                        return;

                    case OperationCode.SpawnItem:

                        itemId = (string)response[(byte)ParameterCode.ItemId];

                        string line = "sadding item: " + itemId + "\n";
                        //   System.IO.File.AppendAllText(@"D:\client-" + Avatar.Id + ".log", line);
                        this.OnItemSpawned(itemId);
                        return;

                    case OperationCode.FireLaser:
                        //   itemId = (string)response[(byte)ParameterCode.ItemId];
                        ////   Vector pos = (Vector)response[(byte)ParameterCode.Position];
                        // //  Vector rot = (Vector)response[(byte)ParameterCode.Rotation];
                        //   this.OnLaserFired(itemId);
                        return;

                    case OperationCode.FireSaber:
                        //itemId = (string)response[(byte)ParameterCode.ItemId];
                        //this.OnSaberFired(itemId);
                        return;

                    case OperationCode.RadarSubscribe:
                        return;
                    }
                }
                else
                {
                    switch ((OperationCode)response.OperationCode)
                    {
                    case OperationCode.EnterWorld:
                        Operations.CreateWorld(
                            this, this.WorldData.Name, this.WorldData.BoundingBox, this.WorldData.TileDimensions);
                        return;
                    }
                }

                this.OnUnexpectedOperationError(response);
            }
            catch (Exception e)
            {
                this.listener.LogError(e);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///   The set state world entered.
        /// </summary>
        /// <param name = "worldData">
        ///   The world Data.
        /// </param>
        public void SetStateWorldEntered(WorldData worldData)
        {
            this.WorldData = worldData;
            this.stateStrategy = WorldEntered.Instance;
            InterestArea camera;
            this.cameras.TryGetValue(0, out camera);
            camera.ResetViewDistance();

            var r = new Random();
            var position = new float[]
                {
                    r.Next((int)this.WorldData.TopLeftCorner[0], (int)this.WorldData.BottomRightCorner[0]), 
                    r.Next((int)this.WorldData.TopLeftCorner[1], (int)this.WorldData.BottomRightCorner[1])
                };
            this.avatar.SetPositions(position, position, null, null);

            this.listener.OnWorldEntered(this);
        }
Exemplo n.º 4
0
 public void SetStateWorldEntered(WorldData worldData)
 {
     this.WorldData = worldData;
     this.WorldEntered = true;
     InterestArea camera;
     this.cameras.TryGetValue(0, out camera);
     camera.ResetViewDistance();
     this.Avatar.SetInterestAreaAttached(true);
     this.listener.OnWorldEntered();
 }
Exemplo n.º 5
0
        public void OnOperationResponse(OperationResponse response)
        {
            try
            {
                if (this.listener.IsDebugLogEnabled)
                {
                    this.listener.LogDebug(string.Format("{0}: received return {1}", this.avatar.Id, response.ReturnCode));
                }

                if (response.ReturnCode == 0)
                {
                    string itemId;
                    switch ((OperationCode)response.OperationCode)
                    {
                        case OperationCode.CreateWorld:
                            this.EnterWorld();
                            return;

                        case OperationCode.EnterWorld:
                            var worldData = new WorldData
                            {
                                Name = (string)response.Parameters[(byte)ParameterCode.WorldName],
                                BoundingBox = (BoundingBox)response.Parameters[(byte)ParameterCode.BoundingBox],
                                TileDimensions = (Vector)response.Parameters[(byte)ParameterCode.TileDimensions]
                            };
                            this.SetStateWorldEntered(worldData);
                            return;
                        case OperationCode.RemoveInterestArea:
                        case OperationCode.AddInterestArea:
                            return;

                        case OperationCode.AttachInterestArea:
                            itemId = (string)response[(byte)ParameterCode.ItemId];
                            this.OnCameraAttached(itemId);
                            return;

                        case OperationCode.DetachInterestArea:
                            this.OnCameraDetached();
                            return;

                        case OperationCode.SpawnItem:
                            itemId = (string)response[(byte)ParameterCode.ItemId];
                            this.OnItemSpawned(itemId);
                            return;

                        case OperationCode.RadarSubscribe:
                            return;
                    }
                }
                else
                {
                    switch ((OperationCode)response.OperationCode)
                    {
                        case OperationCode.EnterWorld:
                            Operations.CreateWorld(
                                this, this.WorldData.Name, this.WorldData.BoundingBox, this.WorldData.TileDimensions);
                            return;
                    }
                }

                this.OnUnexpectedOperationError(response);
            }
            catch (Exception e)
            {
                this.listener.LogError(e);
            }
        }
Exemplo n.º 6
0
        public void OnOperationResponse(OperationResponse response)
        {
            try
            {
                if (this.listener.IsDebugLogEnabled)
                {
                    this.listener.LogDebug(string.Format("{0}: received return {1}", this.avatar.Id, response.ReturnCode));
                }

                if (response.ReturnCode == 0)
                {
                    string itemId;
                    switch ((OperationCode)response.OperationCode)
                    {
                    case OperationCode.CreateWorld:
                        this.EnterWorld();
                        return;

                    case OperationCode.EnterWorld:
                        var worldData = new WorldData
                        {
                            Name           = (string)response.Parameters[(byte)ParameterCode.WorldName],
                            BoundingBox    = (BoundingBox)response.Parameters[(byte)ParameterCode.BoundingBox],
                            TileDimensions = (Vector)response.Parameters[(byte)ParameterCode.TileDimensions]
                        };
                        this.SetStateWorldEntered(worldData);
                        return;

                    case OperationCode.RemoveInterestArea:
                    case OperationCode.AddInterestArea:
                        return;

                    case OperationCode.AttachInterestArea:
                        itemId = (string)response[(byte)ParameterCode.ItemId];
                        this.OnCameraAttached(itemId);
                        return;

                    case OperationCode.DetachInterestArea:
                        this.OnCameraDetached();
                        return;

                    case OperationCode.SpawnItem:
                        itemId = (string)response[(byte)ParameterCode.ItemId];
                        this.OnItemSpawned(itemId);
                        return;

                    case OperationCode.RadarSubscribe:
                        return;
                    }
                }
                else
                {
                    switch ((OperationCode)response.OperationCode)
                    {
                    case OperationCode.EnterWorld:
                        Operations.CreateWorld(
                            this, this.WorldData.Name, this.WorldData.BoundingBox, this.WorldData.TileDimensions);
                        return;
                    }
                }

                this.OnUnexpectedOperationError(response);
            }
            catch (Exception e)
            {
                this.listener.LogError(e);
            }
        }