示例#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 override void OnInitializeScene(GameFramework g)
        {
            Size DisplaySize = g.CANVAS.Size;

            BindGameController();

            this.Fonts.Add("Medium", g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 12)));
            this.Fonts.Add("Small", g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 8)));
            this.Fonts.Add("Arial10B", g.CANVAS.CreateFont(new System.Drawing.Font("Arial", 10, FontStyle.Bold)));
            this.Fonts.Add("Arial8B", g.CANVAS.CreateFont(new System.Drawing.Font("Arial", 8, FontStyle.Bold)));
            this.Fonts.Add("RangeRing", g.CANVAS.CreateFont(new System.Drawing.Font("Times New Roman", 8)));

            _current_unit_sprite = g.CANVAS.CreateSprite();

            background.X = 0;
            background.Y = 0;
            background.Height = DisplaySize.Height;
            background.Width = DisplaySize.Width;
            SetRootWindow(background);


            foreach (string str in g.Textures.Keys)
            {
                if (str.CompareTo("MAP") != 0)
                {
                    Obj_Sprite s = CreateSprite(str, SpriteFlags.AlphaBlend);
                    s.Initialize(g.CANVAS);
                    s.Texture(g.Textures[str]);
                }
            }
                
            Map = CreateSprite("MAP", SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
            _mini_map.Width = 150;
            Map.Initialize(g.CANVAS);
            Map.Texture(g.GetTexture("MAP"));
            //Map.Diffuse = Color.Gray;
            MapTextureHeight = Map.TextureHeight;
            MapTextureWidth = Map.TextureWidth;



            _playfield = new MapPlayfield(g.CANVAS, Map, background, _commands);
            _playfield.WinForm_Mode = true;

            MinScale = _playfield.GetMinimumScale();
            Map.SetPosition(background.X, background.Y, 0);
            SetMapScale(MinScale);
            _playfield.OnInitializeScene(g);
            _playfield.SendMapPosition(true); //attempt to resolve bug 4539, send an initial screen map position

            _playfield.DrawUnmanagedAssetLabels = DefaultUnmanagedUnitLabelValue;

            if (!DDD_Global.Instance.IsConnected)
            {
                ViewProMotionUpdate update = new ViewProMotionUpdate();

                update.ObjectId = "object1";
                update.Throttle = 1;
                update.StartX = 10;
                update.StartY = 10;
                update.StartZ = 0;
                update.PlayerColor = Color.White.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.BTTR.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);

                update.ObjectId = "object2";
                update.Throttle = 1;
                update.StartX = 30;
                update.StartY = 30;
                update.StartZ = 0;
                update.PlayerColor = Color.Green.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CA.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);

                update.ObjectId = "object3";
                update.Throttle = 1;
                update.StartX = 60;
                update.StartY = 60;
                update.StartZ = 0;
                update.PlayerColor = Color.Yellow.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CH47.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);

                update.ObjectId = "object4";
                update.Throttle = 1;
                update.StartX = 90;
                update.StartY = 10;
                update.StartZ = 0;
                update.PlayerColor = Color.Blue.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CMBT-ENGR-CO.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);

                update.ObjectId = "object5";
                update.Throttle = 1;
                update.StartX = 10;
                update.StartY = 60;
                update.StartZ = 0;
                update.PlayerColor = Color.Black.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.DSM-TRP.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);

                update.ObjectId = "object1e";
                update.Throttle = 1;
                update.StartX = 10;
                update.StartY = 30;
                update.StartZ = 0;
                update.PlayerColor = Color.Red.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.FA-BTTR.png";
                ((IController)_game_control).ViewProInitializeUpdate(update);
            }

            AnimationTimer = GameFramework.QueryPerformanceTimer();
            _commands.HandshakeInitializeGUIDone(DDD_Global.Instance.PlayerID);


        }
示例#3
0
 public void ViewProInitializeUpdate(ViewProMotionUpdate update)
 {
     Scene s = GameFramework.Instance().GetCurrentScene();
     if (s is DDD_HeadsUpDisplay)
     {
         ((DDD_HeadsUpDisplay)s).InitializeObjects(update);
     }
 }
示例#4
0
        public void MoveUpdateObjects(ViewProMotionUpdate update)
        {
            
            lock (this)
            {
                if (_playfield != null)
                {
                    if (_playfield.ContainsMapObject(update.ObjectId))
                    {
                        DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(update.ObjectId);

                        obj.Hide = update.HideObject;

                        if (!DDD_Global.Instance.IsConnected)
                        {
                            obj.Throttle = update.Throttle;
                            obj.MaxSpeed = 24;
                            _playfield.MoveMapObject(update.ObjectId, update.DestinationX, update.DestinationY, update.DestinationZ, ((float)(update.Throttle * obj.MaxSpeed * DDD_Global.Instance.GameSpeed)));
                        }
                        else
                        {
                            
                            obj.MaxSpeed = update.MaxSpeed;
                            obj.Throttle = update.Throttle;

                            _playfield.MoveMapObject(
                                update.ObjectId,
                                update.StartX,
                                update.StartY,
                                UTM_Mapping.VelocityToPixels(update.StartZ),
                                update.DestinationX,
                                update.DestinationY,
                                UTM_Mapping.VelocityToPixels(update.DestinationZ),
                                UTM_Mapping.VelocityToPixels((float)(update.Throttle * update.MaxSpeed * DDD_Global.Instance.GameSpeed)));

                        }
                    }
                }
            }
        }
示例#5
0
 public void ViewProInitializeUpdate(ViewProMotionUpdate update)
 {
     try
     {
         if (!IsDisposed)
         {
             if (_map_scene != null)
             {
                 lock (this)
                 {
                     if (DDD_Global.Instance.PlayerID == update.OwnerID)
                     {
                         if (!_ManagedUnits.Contains(update.ObjectId) && !update.IsWeapon)
                         {
                             _ManagedUnits.Add(update.ObjectId);
                             Console.WriteLine(String.Format("Owned asset initialized: {0}", update.ObjectId));
                         }
                     }
                     else
                     {
                         if (!_UnmanagedUnits.Contains(update.ObjectId) && !update.IsWeapon)
                         {
                             _UnmanagedUnits.Add(update.ObjectId);
                             Console.WriteLine(String.Format("Un-owned asset initialized: {0}", update.ObjectId));
                         }
                     }
                 }
                 _map_scene.InitializeObjects(update);
             }
         }
     }
     catch (Exception exc)
     {
         throw new Exception(exc.Message + ":" + exc.StackTrace);
     }
 }
示例#6
0
 public void ViewProMotionUpdate(ViewProMotionUpdate update)
 {
     try
     {
         if (!IsDisposed)
         {
             if (_map_scene != null)
             {
                 _map_scene.MoveUpdateObjects(update);
                 DDDObjects selected = _map_scene.GetSelectedObject();
                 if (selected != null)
                 {
                     if (selected.ObjectID == update.ObjectId)
                     {
                         selected.ThrottleStr = string.Format("{0} %", selected.Throttle * 100);
                         
                     }
                 }
             }
         }
     }
     catch (Exception exc)
     {
         throw new Exception(exc.Message);
     }
 }
示例#7
0
        public void MoveUpdateObjects(ViewProMotionUpdate update)
        {
            
            lock (this)
            {
                if (MapScene.ContainsMapObject(update.ObjectId))
                {
                    DDDObjects obj = (DDDObjects)MapScene.GetMappableObject(update.ObjectId);

                    obj.Hide = update.HideObject;

                    if (!DDD_Global.Instance.nc.IsConnected())
                    {
                        obj.Throttle = update.Throttle;
                        obj.MaxSpeed = 24;
                        MapScene.MoveMapObject(update.ObjectId, update.DestinationX, update.DestinationY, update.DestinationZ, ((float)(update.Throttle * obj.MaxSpeed * DDD_Global.Instance.GameSpeed)));
                    }
                    else
                    {
                        // Don't update throttle here, since it will always be 0.
                        obj.MaxSpeed = update.MaxSpeed;

                        MapScene.MoveMapObject(
                            update.ObjectId,
                            update.StartX,
                            update.StartY,
                            update.StartZ,
                            update.DestinationX,
                            update.DestinationY,
                            update.DestinationZ,
                            UTM_Mapping.VelocityToPixels((float)(update.Throttle * update.MaxSpeed * DDD_Global.Instance.GameSpeed)));
                        
                    }
                }
            }
        }
示例#8
0
        public override void OnInitializeScene(GameFramework g)
        {
            Size DisplaySize = g.CANVAS.Size;

            BindGameController();

            this.Fonts.Add("Large", g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 14)));
            this.Fonts.Add("Medium", g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 12)));
            this.Fonts.Add("Small", g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 8)));

            int bottom = 130;

            background.X = 0;
            background.Y = 0;
            background.Height = DisplaySize.Height;
            background.Width = DisplaySize.Width;
            SetRootWindow(background);

            score.X = 0;
            score.Y = 0;
            score.Width = background.Width;
            score.Height = 40;

            time_rect.X = score.Width - 100;
            time_rect.Y = 0;
            time_rect.Width = 100;
            time_rect.Height = 40;

            information_rect.X = background.Right - 200;
            information_rect.Y = score.Bottom + 1;
            information_rect.Width = 200;
            information_rect.Height = background.Height - (score.Height + bottom);

            button_panel.X = 0;
            button_panel.Y = 41;
            button_panel.Height = 20;
            button_panel.Width = background.Width - information_rect.Width;
            
            frame.X = 0;
            frame.Y = button_panel.Bottom + 1;
            frame.Height = background.Height - (score.Height + bottom + button_panel.Height);
            frame.Width = background.Width - information_rect.Width;

            playfield_panel.X = frame.X + 20;
            playfield_panel.Y = frame.Y + 20;
            playfield_panel.Width = frame.Width - 40;
            playfield_panel.Height = frame.Height - 40;


            #region StatusPanel
            StatusPanel = new Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel(
                                                information_rect.X + 1,
                                                information_rect.Y,
                                                information_rect.Right - 1,
                                                information_rect.Y + information_rect.Height);
            StatusPanel.Layout = PanelLayout.VerticalFree;
            StatusPanel.Background = Window.BackgroundColor;
            StatusPanel.Hide = true;

            ObjectIDLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Object Name", 0, 0, StatusPanel.ClientArea.Width, 50));
            ObjectIDLbl.BackgroundColor = Color.Black;
            ObjectIDLbl.ForegroundColor = Color.Yellow;
            ObjectIDLbl.Font = Fonts["Large"];

            PanelLabel b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 12));
            b.BackgroundColor = StatusPanel.Background;
            b.Font = Fonts["Medium"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Class Name", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            ObjectClassLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            ObjectClassLbl.BackgroundColor = StatusPanel.Background;
            ObjectClassLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("State", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            ObjectStateLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            ObjectStateLbl.BackgroundColor = StatusPanel.Background;
            ObjectStateLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Location", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            LocationLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            LocationLbl.ForegroundColor = Color.Lime;
            LocationLbl.BackgroundColor = StatusPanel.Background;
            LocationLbl.Font = Fonts["Small"];

            AltitudeLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            AltitudeLbl.BackgroundColor = StatusPanel.Background;
            AltitudeLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Destination", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            DestinationLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            DestinationLbl.ForegroundColor = Color.Lime;
            DestinationLbl.BackgroundColor = StatusPanel.Background;
            DestinationLbl.Font = Fonts["Small"];

            TtdLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            TtdLbl.ForegroundColor = Color.Lime;
            TtdLbl.BackgroundColor = StatusPanel.Background;
            TtdLbl.Font = Fonts["Medium"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Speed", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            SpeedLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            SpeedLbl.BackgroundColor = StatusPanel.Background;
            SpeedLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Maximum Speed", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            MaxSpeedLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            MaxSpeedLbl.BackgroundColor = StatusPanel.Background;
            MaxSpeedLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Throttle", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];

            Throttle = (PanelSlider)StatusPanel.BindPanelControl(new PanelSlider(0, 0, StatusPanel.ClientArea.Width,30));
            Throttle.BackgroundColor = StatusPanel.Background;
            Throttle.Font = Fonts["Small"];
            Throttle.Handler = new PanelSliderChangeHandler(SliderHandler);

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Fuel Amount", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            FuelAmountLbl = (PanelProgressLabel)StatusPanel.BindPanelControl(new PanelProgressLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            FuelAmountLbl.BackgroundColor = StatusPanel.Background;
            FuelAmountLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Fuel Capacity", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            FuelCapacityLbl = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 25));
            FuelCapacityLbl.BackgroundColor = StatusPanel.Background;
            FuelCapacityLbl.Font = Fonts["Small"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel("Vulnerabilities", 0, 0, StatusPanel.ClientArea.Width, 25));
            b.BackgroundColor = Color.Black;
            b.Font = Fonts["Medium"];
            VulnerabilityMenu = (PanelMenu)StatusPanel.BindPanelControl(new PanelMenu(Fonts["Medium"], string.Empty, 0, 0, StatusPanel.ClientArea.Width, 75, null));
            VulnerabilityMenu.BackgroundColor = Color.Black;
            VulnerabilityMenu.ForegroundColor = Window.CaptionColor;
            VulnerabilityMenu.Font = Fonts["Medium"];

            b = (PanelLabel)StatusPanel.BindPanelControl(new PanelLabel(0, 0, StatusPanel.ClientArea.Width, 12));
            b.BackgroundColor = StatusPanel.Background;
            b.Font = Fonts["Medium"];

            DeSelectBtn = new PanelStaticButton(0, 0, StatusPanel.ClientArea.Width, 25);
            DeSelectBtn.Text = "Cancel / DeSelect";
            DeSelectBtn.MouseClick = new MouseEventHandler(this.DeSelectBtnHandler);
            DeSelectBtn.Vertical = true;
            DeSelectBtn.Font = Fonts["Medium"];

            StatusPanel.BindPanelControl(DeSelectBtn);


            #endregion

            #region AssetPanel
            AssetPanel = new Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel(
                                    information_rect.X + 1,
                                    information_rect.Y,
                                    information_rect.Right - 1,
                                    information_rect.Y + information_rect.Height);
            AssetPanel.Layout = PanelLayout.VerticalFree;
            AssetPanel.Background = Window.BackgroundColor;

            AssetPanel.Hide = true;

            AssetModeLbl = (PanelLabel)AssetPanel.BindPanelControl(new PanelLabel("Asset Menu", 0, 0, AssetPanel.ClientArea.Width, 50));
            AssetModeLbl.BackgroundColor = Color.Black;
            AssetModeLbl.ForegroundColor = Color.Yellow;
            AssetModeLbl.Font = Fonts["Large"];

            AssetHeaderLbl = (PanelLabel)AssetPanel.BindPanelControl(new PanelLabel("Managed Assets ...", 0, 0, AssetPanel.ClientArea.Width, 25));
            AssetHeaderLbl.BackgroundColor = Color.Black;
            AssetHeaderLbl.Font = Fonts["Medium"];

            AssetMenu = new PanelMenu(Fonts["Medium"], string.Empty, 0, 0, AssetPanel.ClientArea.Width, AssetHeaderLbl.ClientArea.Bottom,
                new PanelMenuSelectHandler(AssetHandler));
            AssetMenu.SetHeight(information_rect.Height / 3);
            AssetMenu.BackgroundColor = AssetPanel.Background;
            AssetPanel.BindPanelControl(AssetMenu);

            MiscAssetHeaderLbl = (PanelLabel)AssetPanel.BindPanelControl(new PanelLabel("UnManaged Assets ...", 0, 0, AssetPanel.ClientArea.Width, 25));
            MiscAssetHeaderLbl.BackgroundColor = Color.Black;
            MiscAssetHeaderLbl.Font = Fonts["Medium"];

            MiscAssetMenu = new PanelMenu(Fonts["Medium"], string.Empty, 0, 0, AssetPanel.ClientArea.Width, MiscAssetHeaderLbl.ClientArea.Bottom,
                new PanelMenuSelectHandler(AssetHandler));
            MiscAssetMenu.SetHeight(information_rect.Height / 3);
            MiscAssetMenu.BackgroundColor = AssetPanel.Background;
            AssetPanel.BindPanelControl(MiscAssetMenu);

            #endregion
            
            #region AttackPanel
            AttackPanel = new Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel(
                                                information_rect.X + 1,
                                                information_rect.Y,
                                                information_rect.Right - 1,
                                                information_rect.Y + information_rect.Height);
            AttackPanel.Layout = PanelLayout.VerticalFree;
            AttackPanel.Background = Window.BackgroundColor;
            AttackPanel.Hide = true;

            AttackModeLbl = (PanelLabel) AttackPanel.BindPanelControl(new PanelLabel("Object Name", 0, 0, AttackPanel.ClientArea.Width, 50));
            AttackModeLbl.BackgroundColor = Color.Black;
            AttackModeLbl.ForegroundColor = Color.Yellow;
            AttackModeLbl.Font = Fonts["Large"];

            AttackHeaderLbl = (PanelLabel)AttackPanel.BindPanelControl(new PanelLabel("Choose Weapon ...", 0, 0, AttackPanel.ClientArea.Width, 25));
            AttackHeaderLbl.BackgroundColor = Color.Black;
            AttackHeaderLbl.Font = Fonts["Medium"];


            AttackMenu = new PanelMenu(Fonts["Medium"], string.Empty, 0, 0, AttackPanel.ClientArea.Width, AttackModeLbl.ClientArea.Bottom,  
                new PanelMenuSelectHandler(AttackHandler));
            AttackMenu.SetHeight(information_rect.Height / 2);
            AttackMenu.BackgroundColor = AttackPanel.Background;
            AttackPanel.BindPanelControl(AttackMenu);


            CancelAttackBtn = new PanelStaticButton(0, 0, AttackMenu.ClientArea.Width, 25);
            CancelAttackBtn.Text = "Cancel";
            CancelAttackBtn.MouseClick = new MouseEventHandler(this.CancelAttackBtnHandler);
            CancelAttackBtn.Vertical = true;
            CancelAttackBtn.Font = Fonts["Medium"];

            AttackPanel.BindPanelControl(CancelAttackBtn);
            #endregion AttackPanel
            
            #region SubPPanel
            SubPlatformPanel = new Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel(
                                                information_rect.X + 1,
                                                information_rect.Y,
                                                information_rect.Right - 1,
                                                information_rect.Y + information_rect.Height);
            SubPlatformPanel.Layout = PanelLayout.VerticalFree;
            SubPlatformPanel.Background = Window.BackgroundColor;
            SubPlatformPanel.Hide = true;

            SubPModeLbl = (PanelLabel)SubPlatformPanel.BindPanelControl(new PanelLabel("Object Name", 0, 0, SubPlatformPanel.ClientArea.Width, 50));
            SubPModeLbl.BackgroundColor = Color.Black;
            SubPModeLbl.ForegroundColor = Color.Yellow;
            SubPModeLbl.Font = Fonts["Large"];

            SubPHeaderLbl = (PanelLabel)SubPlatformPanel.BindPanelControl(new PanelLabel("Choose Sub-Platform ...", 0, 0, SubPlatformPanel.ClientArea.Width, 25));
            SubPHeaderLbl.BackgroundColor = Color.Black;
            SubPHeaderLbl.Font = Fonts["Medium"];


            SubPlatformMenu = new PanelMenu(Fonts["Medium"], string.Empty, 0, 0, AttackPanel.ClientArea.Width, AttackModeLbl.ClientArea.Bottom,
                new PanelMenuSelectHandler(SubPHandler));
            SubPlatformMenu.SetHeight(information_rect.Height / 2);
            SubPlatformMenu.BackgroundColor = SubPlatformPanel.Background;
            SubPlatformPanel.BindPanelControl(SubPlatformMenu);


            CancelSubPBtn = new PanelStaticButton(0, 0, SubPlatformMenu.ClientArea.Width, 25);
            CancelSubPBtn.Text = "Cancel SubP";
            CancelSubPBtn.MouseClick = new MouseEventHandler(this.CancelSubPBtnHandler);
            CancelSubPBtn.Vertical = true;
            CancelSubPBtn.Font = Fonts["Medium"];

            SubPlatformPanel.BindPanelControl(CancelSubPBtn);
            #endregion AttackPanel
            
            #region Misc UI

            PlayfieldPanel = CreatePanel(playfield_panel.X, playfield_panel.Y, playfield_panel.Right, playfield_panel.Bottom);
            ButtonPanel = CreatePanel(button_panel.X, button_panel.Y, button_panel.Right, button_panel.Bottom);
            ButtonPanel.Background = StatusPanel.Background;
            ButtonPanel.Layout = PanelLayout.HorizontalFree;

            MapNameLbl = (PanelLabel)ButtonPanel.BindPanelControl(
                new PanelLabel("Map: " + DDD_Global.Instance.MapName.Substring(0, DDD_Global.Instance.MapName.Length - 4)
                , 0, 0, ButtonPanel.ClientArea.Width, ButtonPanel.ClientArea.Height));
            MapNameLbl.BackgroundColor = ButtonPanel.Background;
            MapNameLbl.Font = Fonts["Medium"];

            

            MsgWindow = CreateWindow(g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 12)),
                "Messages", 0, frame.Bottom + 2, (int)(background.Width / 2), background.Bottom);

            MsgWindowPanel = (PanelTextRegion)MsgWindow.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelTextRegion(g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 10))
               , 0, frame.Bottom + 2, (int)(background.Width / 2), background.Bottom));

            MsgWindowPanel.Sticky = true;


            ChatWindow = CreateWindow(g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 12)), "Chat",
                MsgWindowPanel.ClientArea.Right + 2,
                frame.Bottom + 2,
                background.Right - 2,
                background.Bottom);

            ChatWindowPanel = (PanelTextRegion)ChatWindow.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelTextRegion(g.CANVAS.CreateFont(new System.Drawing.Font("MS Sans Serif", 10)),
                MsgWindowPanel.ClientArea.Right + 2,
                frame.Bottom + 2,
                background.Right - 2,
                background.Bottom));

            ChatWindowPanel.HasInput = true;
            ChatWindowPanel.Sticky = true;
            ChatWindowPanel.OnTextChat = new TextChatEventHandler(this.TextChatHandler);


            LeftScrollPanel = CreatePanel(frame.X, playfield_panel.Y, playfield_panel.X - 1, playfield_panel.Bottom);
            LeftScrollBtn = (PanelDynamicButton)LeftScrollPanel.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelDynamicButton(frame.X, playfield_panel.Y, playfield_panel.X - 1, playfield_panel.Bottom));
            LeftScrollBtn.MouseDown = new MouseEventHandler(this.LeftScroll);
            LeftScrollBtn.MouseUp = new MouseEventHandler(this.StopScroll);
            left_arrow.X = LeftScrollPanel.ClientArea.X + (LeftScrollPanel.ClientArea.Width / 2) - 6;
            left_arrow.Y = LeftScrollPanel.ClientArea.Top + (LeftScrollPanel.ClientArea.Height / 2) - 6;
            left_arrow.Width = 12;
            left_arrow.Height = 12;


            RightScrollPanel = CreatePanel(playfield_panel.Right + 1, playfield_panel.Y, frame.Right, playfield_panel.Bottom);
            RightScrollBtn = (PanelDynamicButton)RightScrollPanel.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelDynamicButton(playfield_panel.Right + 1, playfield_panel.Y, frame.Right, playfield_panel.Bottom));
            RightScrollBtn.MouseDown = new MouseEventHandler(this.RightScroll);
            RightScrollBtn.MouseUp = new MouseEventHandler(this.StopScroll);
            right_arrow.X = RightScrollPanel.ClientArea.X + (RightScrollPanel.ClientArea.Width / 2) - 6;
            right_arrow.Y = RightScrollPanel.ClientArea.Top + (RightScrollPanel.ClientArea.Height / 2) - 6;
            right_arrow.Width = 12;
            right_arrow.Height = 12;


            DownScrollPanel = CreatePanel(playfield_panel.X, playfield_panel.Bottom + 1, playfield_panel.Right, frame.Bottom);
            DownScrollBtn = (PanelDynamicButton)DownScrollPanel.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelDynamicButton(playfield_panel.X, playfield_panel.Bottom + 1, playfield_panel.Right, frame.Bottom));
            DownScrollBtn.MouseDown = new MouseEventHandler(this.DownScroll);
            DownScrollBtn.MouseUp = new MouseEventHandler(this.StopScroll);
            down_arrow.X = DownScrollPanel.ClientArea.X + (DownScrollPanel.ClientArea.Width / 2) - 6;
            down_arrow.Y = DownScrollPanel.ClientArea.Top + (DownScrollPanel.ClientArea.Height / 2) - 6;
            down_arrow.Width = 12;
            down_arrow.Height = 12;


            UpScrollPanel = CreatePanel(playfield_panel.X, frame.Top, playfield_panel.Right, playfield_panel.Top - 1);
            UpScrollBtn = (PanelDynamicButton)UpScrollPanel.BindPanelControl(new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelDynamicButton(playfield_panel.X, frame.Top, playfield_panel.Right, playfield_panel.Top - 1));
            UpScrollBtn.MouseDown = new MouseEventHandler(this.UpScroll);
            UpScrollBtn.MouseUp = new MouseEventHandler(this.StopScroll);
            up_arrow.X = UpScrollPanel.ClientArea.X + (UpScrollPanel.ClientArea.Width / 2) - 6;
            up_arrow.Y = UpScrollPanel.ClientArea.Top + (UpScrollPanel.ClientArea.Height / 2) - 6;
            up_arrow.Width = 12;
            up_arrow.Height = 12;
            #endregion


            foreach (string str in g.Textures.Keys)
            {
                if (str.CompareTo("MAP") != 0)
                {
                    Obj_Sprite s = CreateSprite(str, SpriteFlags.AlphaBlend);
                    s.Initialize(g.CANVAS);
                    s.Texture(g.Textures[str]);
                }
            }
                
            Map = CreateSprite("MAP", SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
            Map.Initialize(g.CANVAS);
            Map.Texture(g.GetTexture("MAP"));
            Map.Diffuse = Color.Gray; 



            MapScene = new MapPlayfield(g.CANVAS, Map, PlayfieldPanel.ClientArea, _commands);
            Playfield = (PanelSceneRegion)PlayfieldPanel.BindPanelControl(
                new Aptima.Asim.DDD.Client.Common.GLCore.Controls.PanelSceneRegion(playfield_panel.X, playfield_panel.Y, playfield_panel.Right, playfield_panel.Bottom, MapScene)
                );
            Playfield.Sticky = false;
            Playfield.MouseClick = new MouseEventHandler(MapScene.OnMouseClick);
            Playfield.MouseWheel = new MouseEventHandler(MapScene.OnMouseWheel);
            Playfield.MouseDown = new MouseEventHandler(MapScene.OnMouseDown);
            Playfield.MouseUp = new MouseEventHandler(MapScene.OnMouseUp);
            Playfield.MouseMove = new MouseEventHandler(MapScene.OnMouseMove);


            Map.SetPosition(PlayfieldPanel.ClientArea.X, PlayfieldPanel.ClientArea.Y, 0);
            MapScene.OnInitializeScene(g);


            if (!DDD_Global.Instance.nc.IsConnected())
            {
                ViewProMotionUpdate update = new ViewProMotionUpdate();

                update.ObjectId = "object1";
                update.Throttle = 1;
                update.StartX = 600;
                update.StartY = 600;
                update.StartZ = 0;
                update.PlayerColor = Color.White.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.BTTR.png";
                InitializeObjects(update);

                update.ObjectId = "object2";
                update.Throttle = 1;
                update.StartX = 630;
                update.StartY = 630;
                update.StartZ = 0;
                update.PlayerColor = Color.Green.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CA.png";
                InitializeObjects(update);

                update.ObjectId = "object1b";
                update.Throttle = 1;
                update.StartX = 660;
                update.StartY = 660;
                update.StartZ = 0;
                update.PlayerColor = Color.Yellow.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CH47.png";
                InitializeObjects(update);

                update.ObjectId = "object1c";
                update.Throttle = 1;
                update.StartX = 690;
                update.StartY = 690;
                update.StartZ = 0;
                update.PlayerColor = Color.Blue.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.CMBT-ENGR-CO.png";
                InitializeObjects(update);

                update.ObjectId = "object1d";
                update.Throttle = 1;
                update.StartX = 720;
                update.StartY = 720;
                update.StartZ = 0;
                update.PlayerColor = Color.Black.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.DSM-TRP.png";
                InitializeObjects(update);

                update.ObjectId = "object1e";
                update.Throttle = 1;
                update.StartX = 750;
                update.StartY = 750;
                update.StartZ = 0;
                update.PlayerColor = Color.Red.ToArgb();
                update.Icon = "ImageLib.Persuade.Blue.FA-BTTR.png";
                InitializeObjects(update);

                //update.ObjectId = update.OwnerID = update.PlayerId = "object2";
                //update.Throttle = 1;
                //update.StartX = 30;
                //update.StartY = 30;
                //update.StartZ = 0;
                //InitializeObjects(update);

                //update.ObjectId = update.OwnerID = update.PlayerId = "object3";
                //update.Throttle = 1;
                //update.StartX = 50;
                //update.StartY = 50;
                //update.StartZ = 0;
                //InitializeObjects(update);

                //update.ObjectId = update.OwnerID = update.PlayerId = "object4";
                //update.Throttle = 1;
                //update.StartX = 70;
                //update.StartY = 70;
                //update.StartZ = 0;
                //InitializeObjects(update);

                //update.ObjectId = update.OwnerID = update.PlayerId = "object5";
                //update.Throttle = 1;
                //update.StartX = 90;
                //update.StartY = 90;
                //update.StartZ = 0;
                //InitializeObjects(update);

              
                //MsgWindowPanel.AddText("UTM Northing units: " + UTM_Mapping.VerticalMetersPerPixel);
                //MsgWindowPanel.AddText("UTM Easting units: " + UTM_Mapping.HorizonalMetersPerPixel);
                MsgWindowPanel.AddText(DDD_Global.Instance.ScenarioDescription);
                //MsgWindowPanel.AddText("Demo Mode...");
            }
            else
            {
                //MsgWindowPanel.AddText("UTM Northing units: " + UTM_Mapping.VerticalMetersPerPixel);
                //MsgWindowPanel.AddText("UTM Easting units: " + UTM_Mapping.HorizonalMetersPerPixel);
                MsgWindowPanel.AddText(DDD_Global.Instance.ScenarioDescription);
                //MsgWindowPanel.AddText("Connected to server...");
            }

            ScoreHeader = string.Format("Scenario: {0}             Player: {1}", DDD_Global.Instance.ScenarioName, DDD_Global.Instance.PlayerID);
            _commands.HandshakeInitializeGUIDone(DDD_Global.Instance.PlayerID);

        }
示例#9
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();

        }