Beispiel #1
0
        public void AttributeUpdateObjects(ViewProAttributeUpdate update)
        {
            lock (this)
            {
                if (_playfield != null)
                {
                    if (_playfield.ContainsMapObject(update.ObjectId))
                    {
                        DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(update.ObjectId);
                        if (obj != null)
                        {
                            obj.CurrentIcon = update.IconName;
                            if (update.IconName.Length > 0)
                            {
                                if (Sprites.ContainsKey(update.IconName))
                                {
                                    obj.SetSprite(Sprites[update.IconName]);
                                    obj.DrawWithRotation = GameFramework.Instance().GetTexture(update.IconName).rotate;
                                }
                                else
                                {
                                    string unknown = string.Format("{0}.Unknown.png", DDD_Global.Instance.ImageLibrary);
                                    obj.SetSprite(Sprites[unknown]);
                                    obj.DrawWithRotation = GameFramework.Instance().GetTexture(unknown).rotate;
                                }

                            }
                            if (update.Throttle > 0)
                            {
                                obj.Throttle = update.Throttle;
                            }
                            if (update.CapabilityAndWeapons != null)
                            {
                                obj.CapabilityAndWeapons = update.CapabilityAndWeapons;
                            }
                            if (update.SubPlatforms != null)
                            {
                                obj.SubPlatforms = update.SubPlatforms;
                            }
                            if (update.Vulnerabilities != null)
                            {
                                obj.Vulnerabilities = update.Vulnerabilities;
                            }
                            if (update.FuelAmount >= 0)
                            {
                                obj.FuelAmount = (float)update.FuelAmount;
                            }
                            if (update.FuelCapacity >= 0)
                            {
                                obj.FuelCapacity = (float)update.FuelCapacity;
                            }
                            obj.PlayerID = update.PlayerId;
                            obj.MaxSpeed = update.MaxSpeed;

                            if (update.ClassName != null)
                            {
                                if (update.ClassName.Length > 0)
                                {
                                    obj.ClassName = update.ClassName;
                                }
                            }
                            if (update.Classification != null)
                            {
                                //if (update.Classification.Length > 0)
                                //{
                                    obj.Classification = update.Classification;
                                //}
                            }
                            if (update.State.Length > 0)
                            {
                                obj.State = update.State;
                            }
                            if (update.ParentId != null)
                            {
                                obj.ParentID = update.ParentId;
                            }
                            else
                            {
                                obj.ParentID = string.Empty;
                            }

                            if (obj.OwnerID != update.OwnerId)
                            {
                                obj.OwnerID = update.OwnerId;
                                _playfield.SwitchOwnership(obj.ObjectID);
                            }

                            if (update.CustomAttributes != null)
                            {
                                obj.UpdateCustomAttributes(update.CustomAttributes);
                            }

                            if (update.LocationX != 0 && update.LocationY != 0 && update.LocationZ != 0)
                            {
                                //obj.SetPosition(float.Parse(update.LocationX.ToString()), float.Parse(update.LocationY.ToString()), float.Parse(update.LocationZ.ToString()));
                                obj.Altitude = (float)update.LocationZ;
                                obj.SetPosition(obj.Position.X, obj.Position.Y, (float)update.LocationZ);//Might be issues with setting position > 0
                            }

                            if (update.Tag != null)
                            {
                                obj.Tag = update.Tag;
                            }

                            if (update.Sensors != null)
                            {
                                obj.Sensors = update.Sensors;
                            }

                            bool hasAnyRings = false;
                            if (update.SensorRangeRings != null)
                            {
                                hasAnyRings = true;
                                try
                                {
                                    obj.SetSensorRangeRings(update.SensorRangeRings);
                                }
                                catch (Exception ex)
                                { }
                            }
                            if (update.CapabilityRangeRings != null)
                            {
                                hasAnyRings = true;
                                try
                                {
                                    obj.SetCapabilityRangeRings(update.CapabilityRangeRings);
                                }
                                catch (Exception ex)
                                { }
                                
                            }
                            if (update.VulnerabilityRangeRings != null)
                            {
                                hasAnyRings = true;
                                try
                                {
                                    obj.SetVulnerabilityRangeRings(update.VulnerabilityRangeRings);
                                    Console.WriteLine("Vulnerability rings received: {0}", update.VulnerabilityRangeRings.ToString());
                                }
                                catch (Exception ex)
                                { }
                               
                            }
                            else
                            {
                                Console.WriteLine("No vulnerability rings received");
                            }                            
                        }
                    }
                }
            }
        }
 public void ViewProAttributeUpdate(ViewProAttributeUpdate update)
 {
     try
     {
         if (!IsDisposed)
         {
             if (_map_scene != null)
             {
                 _map_scene.AttributeUpdateObjects(update);
                 DDDObjects selected = _map_scene.GetSelectedObject();
                 if (selected != null)
                 {
                     if (selected.ObjectID == update.ObjectId)
                     {
                         if (!selected.IsWeapon)
                         {
                             PopulateObjectAttributes(selected);
                         }
                         else
                         {
                             PopulateObjectAttributes(null);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception exc)
     {
         throw new Exception(exc.Message);
     }
 }
Beispiel #3
0
 public void ViewProAttributeUpdate(ViewProAttributeUpdate update)
 {
     Scene s = GameFramework.Instance().GetCurrentScene();
     if (s is DDD_HeadsUpDisplay)
     {
         ((DDD_HeadsUpDisplay)s).AttributeUpdateObjects(update);
     }
 }
Beispiel #4
0
        public void AttributeUpdateObjects(ViewProAttributeUpdate update)
        {
            lock (this)
            {
                if (MapScene.ContainsMapObject(update.ObjectId))
                {
                    DDDObjects obj = (DDDObjects)MapScene.GetMappableObject(update.ObjectId);
                    if (obj != null)
                    {
                        if (update.IconName.Length > 0)
                        {
                            if (Sprites.ContainsKey(update.IconName))
                            {
                                obj.SetSprite(Sprites[update.IconName]);
                            }
                            else
                            {
                                obj.SetSprite(Sprites["ImageLib.Unknown.png"]);
                            }

                        }
                        if (update.CapabilityAndWeapons != null)
                        {
                            obj.CapabilityAndWeapons = update.CapabilityAndWeapons;
                        }
                        if (update.SubPlatforms != null)
                        {
                            obj.SubPlatforms = update.SubPlatforms;
                        }
                        if (update.Vulnerabilities != null)
                        {
                            obj.Vulnerabilities = update.Vulnerabilities;
                        }
                        if (update.FuelAmount > 0)
                        {
                            obj.FuelAmount = (float)update.FuelAmount;
                        }
                        if (update.FuelCapacity > 0)
                        {
                            obj.FuelCapacity = (float)update.FuelCapacity;
                        }
                        obj.PlayerID = update.PlayerId;

                        if (update.ClassName != null)
                        {
                            if (update.ClassName.Length > 0)
                            {
                                obj.ClassName = update.ClassName;
                            }
                        }
                        if (update.State.Length > 0)
                        {
                            obj.State = update.State;
                        }

                        if (obj.OwnerID != update.OwnerId)
                        {
                            obj.OwnerID = update.OwnerId;
                            MapScene.SwitchOwnership(obj.ObjectID);
                        }
                    }
                }
            }
        }