Пример #1
0
        public void InitializeObjects(ViewProMotionUpdate update)
        {
            try
            {
                if (update.Icon == null)
                {
                    update.Icon = string.Format("{0}.Unknown.png", DDD_Global.Instance.ImageLibrary);
                }
                if (!Sprites.ContainsKey(update.Icon))
                {
                    update.Icon = string.Format("{0}.Unknown.png", DDD_Global.Instance.ImageLibrary); 
                }
                DDDObjects obj = new DDDObjects(this);
                obj.ObjectID = update.ObjectId;
                obj.PlayerID = update.PlayerId;
                obj.OwnerID = update.OwnerID;
                obj.CapabilityAndWeapons = null;
                obj.TextBoxColor = Color.FromArgb(update.PlayerColor);
                obj.SetPosition(update.StartX, update.StartY, update.StartZ);
                obj.Throttle = update.Throttle;
                obj.MaxSpeed = update.MaxSpeed;
                obj.FuelAmount = 0;
                obj.FuelCapacity = 0;
                obj.IsAttacking = update.IsWeapon;
                obj.Altitude = update.StartZ;
                obj.CurrentIcon = update.Icon;
                obj.IsWeapon = update.IsWeapon;

                // Saved the DM Color for use on the mini map
                if (!DMColorMap.ContainsKey(update.OwnerID))
                {
                    DMColorMap.Add(update.OwnerID, update.PlayerColor);
                }

                if (!DDD_Global.Instance.IsConnected)
                {
                    switch (update.ObjectId)
                    {
                        case "object1":
                            obj.PlayerID = "Demo Player";
                            obj.OwnerID = "Demo Player";
                            obj.CapabilityAndWeapons = new string[] { "Null Capability - object1", "Null Weapon1", "Null Weapon2", "Null Weapon3" };
                            obj.SubPlatforms = new string[] { "Pilot 1", "Navigator 1", "Black Box" };
                            obj.Vulnerabilities = new string[] { "Superman", "Batman", "The Flash" };
                            obj.Sensors = new string[] { "Sensor1", "Sensor2" };
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 100;
                            obj.FuelCapacity = 200;
                            obj.Altitude = 12;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;

                        case "object2":
                            obj.PlayerID = "Demo Player";
                            obj.OwnerID = "Demo Player";
                            obj.CapabilityAndWeapons = new string[] { "Null Capability - object2", "Null Weapon" };
                            obj.Vulnerabilities = new string[] { "Aquaman", "Green Lantern", "Robin" };
                            obj.Sensors = new string[] { "Sensor3", "Sensor4" };
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 275;
                            obj.FuelCapacity = 300;
                            obj.Altitude = 0;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;

                        case "object3":
                            obj.PlayerID = "Red";
                            obj.OwnerID = "Red";
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 48;
                            obj.FuelCapacity = 50;
                            obj.Altitude = 0;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;

                        case "object4":
                            obj.PlayerID = "Red";
                            obj.OwnerID = "Red";
                            obj.CapabilityAndWeapons = new string[] { "Null Capability - object4", "Null Weapon" };
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 49;
                            obj.FuelCapacity = 50;
                            obj.Altitude = 0;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;

                        case "object5":
                            obj.PlayerID = "Red";
                            obj.OwnerID = "Red";
                            obj.CapabilityAndWeapons = new string[] { "Null Capability - object5", "Null Weapon" };
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 50;
                            obj.FuelCapacity = 50;
                            obj.Altitude = 0;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;

                        default:
                            obj.PlayerID = "Demo Player";
                            obj.OwnerID = "Demo Player";
                            obj.CapabilityAndWeapons = new string[] { "Null Capability - Default", "Null Weapon1", "Null Weapon2", "Null Weapon3" };
                            obj.MaxSpeed = 24;
                            obj.FuelAmount = 100;
                            obj.FuelCapacity = 200;
                            obj.Altitude = 12;
                            obj.SetSprite(Sprites[update.Icon]);
                            obj.DrawWithRotation = false;
                            _playfield.AddMappableObject(update.ObjectId, obj);
                            break;
                    }
                }
                else
                {
                    if (!_playfield.ContainsMapObject(update.ObjectId))
                    {
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = GameFramework.Instance().GetTexture(update.Icon).rotate;
                        _playfield.AddMappableObject(update.ObjectId, obj);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Initialize: " + e.Message + ":" + e.StackTrace);
                return;
            }      

        }
Пример #2
0
        public void InitializeObjects(ViewProMotionUpdate update)
        {
            if (!Sprites.ContainsKey(update.Icon))
            {
                update.Icon = "ImageLib.Unknown.png";
            }
            DDDObjects obj = new DDDObjects();
            obj.ObjectID = update.ObjectId;
            obj.PlayerID = update.PlayerId;
            obj.OwnerID = update.OwnerID;
            obj.CapabilityAndWeapons = null;
            obj.TextBoxColor = Color.FromArgb(update.PlayerColor);
            obj.SetPosition(update.StartX, update.StartY, 0);
            obj.Throttle = 1;
            obj.MaxSpeed = update.MaxSpeed;
            obj.FuelAmount = 0;
            obj.FuelCapacity = 0;
            obj.IsAttacking = update.IsWeapon;
            obj.Altitude = update.StartZ;

            if (!DDD_Global.Instance.nc.IsConnected())
            {
                switch (update.ObjectId)
                {
                    case "object1":
                        obj.PlayerID = "Demo Player";
                        obj.OwnerID = DDD_Global.Instance.PlayerID;
                        obj.CapabilityAndWeapons = new string[] { "Null Capability", "Null Weapon1", "Null Weapon2", "Null Weapon3" };
                        obj.SubPlatforms = new string[] { "Pilot 1", "Navigator 1", "Black Box" };
                        obj.Vulnerabilities = new string[] { "Superman", "Batman", "The Flash" };
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 100;
                        obj.FuelCapacity = 200;
                        obj.Altitude = 12;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;


                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;
                    case "object2":
                        obj.PlayerID = "Demo Player";
                        obj.OwnerID = DDD_Global.Instance.PlayerID;
                        obj.CapabilityAndWeapons = new string[] { "Null Capability", "Null Weapon" };
                        obj.Vulnerabilities = new string[] { "Aquaman", "Green Lantern", "Robin" };
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 275;
                        obj.FuelCapacity = 300;
                        obj.Altitude = 0;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;


                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;
                    case "object3":
                        obj.PlayerID = "Red";
                        obj.OwnerID = DDD_Global.Instance.PlayerID;
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 48;
                        obj.FuelCapacity = 50;
                        obj.Altitude = 0;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;


                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;
                    case "object4":
                        obj.PlayerID = "Red";
                        obj.OwnerID = DDD_Global.Instance.PlayerID;
                        obj.CapabilityAndWeapons = new string[] { "Null Capability", "Null Weapon" };
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 49;
                        obj.FuelCapacity = 50;
                        obj.Altitude = 0;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;


                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;
                    case "object5":
                        obj.PlayerID = "Red";
                        obj.OwnerID = DDD_Global.Instance.PlayerID;
                        obj.CapabilityAndWeapons = new string[] { "Null Capability", "Null Weapon" };
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 50;
                        obj.FuelCapacity = 50;
                        obj.Altitude = 0;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;

                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;
                    default:
                        obj.PlayerID = "Demo Player";
                        obj.OwnerID = "Demo Player";
                        obj.CapabilityAndWeapons = new string[] { "Null Capability", "Null Weapon1", "Null Weapon2", "Null Weapon3" };
                        obj.MaxSpeed = 24;
                        obj.FuelAmount = 100;
                        obj.FuelCapacity = 200;
                        obj.Altitude = 12;
                        obj.SetSprite(Sprites[update.Icon]);
                        obj.DrawWithRotation = false;


                        MapScene.AddMappableObject(update.ObjectId, obj);
                        break;

                }
            }
            else
            {
                if (!MapScene.ContainsMapObject(update.ObjectId))
                {
                    obj.DrawWithRotation = false;
                    obj.SetSprite(Sprites[update.Icon]);
                    MapScene.AddMappableObject(update.ObjectId, obj);
                    //obj.CanSelect = false;
                    //MapScene.AddMappableObject(update.ObjectId, obj);
                    //((DDDObjects)MapScene.GetMappableObject(update.ObjectId)).Throttle = update.Throttle;
                    //MapScene.MoveMapObject(
                    //        update.ObjectId,
                    //        update.StartX,
                    //        update.StartY,
                    //        update.StartZ,
                    //        update.DestinationX,
                    //        update.DestinationY,
                    //        update.DestinationZ,
                    //        UTM_Mapping.VelocityToPixels((float)(update.Throttle * update.MaxSpeed)));

                    //break;
                }                    
            }
            
            AssetMenu.Reset();
            MiscAssetMenu.Reset();

        }