示例#1
0
        public void WinForm_LaunchSubPlatform(float xpos, float ypos)
        {
            if (!_pause)
            {
                DDDObjects obj = GetSelectedObject();
                if (obj != null)
                {
                    xpos = (xpos - Map.Position.X) / Scale;
                    ypos = (ypos - Map.Position.Y) / Scale;

                    if (obj.SubPlatforms != null)
                    {
                        if (obj.SubPlatforms.Length > 0)
                        {
                            if ((obj.CurrentSubplatform >= 0) && (obj.CurrentSubplatform < obj.SubPlatforms.Length))
                            {
                                if (!obj.IsWeapon)
                                {
                                    if (!DDD_Global.Instance.IsObserver && !DDD_Global.Instance.IsForkReplay)
                                    {
                                        double parentAltitude = 0.0;
                                        parentAltitude = obj.Altitude;
                                        Command.SubPlatformLaunch(obj.SubPlatforms[obj.CurrentSubplatform], obj.ObjectID, xpos, ypos, parentAltitude);
                                    }
                                }
                            }
                        }
                    }
                }


                Mode = MapModes.MOVE;
                Command.SelectionUpdate();
            }
        }
示例#2
0
        public void MoveSelected(float xpos, float ypos)
        {
            if (!_pause)
            {
                DDDObjects obj = GetSelectedObject();

                if (obj != null)
                {
                    xpos = (xpos - Map.Position.X) / Scale;
                    ypos = (ypos - Map.Position.Y) / Scale;

                    try
                    {
                        if (!obj.IsWeapon)
                        {
                            double altitude = obj.Altitude;
                            if (!DDD_Global.Instance.IsObserver && !DDD_Global.Instance.IsForkReplay)
                            {
                                Command.DoMove(DDD_Global.Instance.PlayerID, obj.ObjectID, obj.ThrottleSlider, xpos, ypos, altitude);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
        }
示例#3
0
        public void WinForm_DockToSelected()
        {
            if (!_pause)
            {
                DDDObjects obj    = GetSelectedObject();
                DDDObjects target = GetSelectedTarget();

                if (obj != null && target != null)
                {
                    if (!DDD_Global.Instance.IsObserver && !DDD_Global.Instance.IsForkReplay)
                    {
                        Command.SubPlatformDock(obj.ObjectID, target.ObjectID);
                    }
                    //if (obj.CapabilityAndWeapons.Length > 0)
                    //{
                    //    if ((obj.CurrentCapabilityAndWeapon >= 0) &&
                    //        (obj.CurrentCapabilityAndWeapon < obj.CapabilityAndWeapons.Length))
                    //    {
                    //        if (!obj.IsWeapon)
                    //        {
                    //            Command.DoAttack(DDD_Global.Instance.PlayerID,
                    //                obj.ObjectID,
                    //                target.ObjectID,
                    //                obj.CapabilityAndWeapons[obj.CurrentCapabilityAndWeapon]);
                    //        }
                    //    }

                    //    _select_buffer.Remove(target.ObjectID);
                    //}
                }

                EnterMoveMode();
                Command.SelectionUpdate();
            }
        }
示例#4
0
        public void WinForm_AttackSelected()
        {
            if (!_pause)
            {
                DDDObjects obj        = GetSelectedObject();
                DDDObjects target     = GetSelectedTarget();
                bool       attackSent = false;

                if (obj != null && target != null)
                {
                    if (obj.CapabilityAndWeapons.Length > 0)
                    {
                        if ((obj.CurrentCapabilityAndWeapon >= 0) &&
                            (obj.CurrentCapabilityAndWeapon < obj.CapabilityAndWeapons.Length))
                        {
                            if (!obj.IsWeapon)
                            {
                                if (!DDD_Global.Instance.IsObserver && !DDD_Global.Instance.IsForkReplay)
                                {
                                    Command.DoAttack(DDD_Global.Instance.PlayerID,
                                                     obj.ObjectID,
                                                     target.ObjectID,
                                                     obj.CapabilityAndWeapons[obj.CurrentCapabilityAndWeapon]);
                                    attackSent = true;
                                }
                            }
                        }

                        _select_buffer.Remove(target.ObjectID);
                    }
                }
                if (!attackSent)
                {
                    EnterMoveMode();
                }
                Command.SelectionUpdate();
            }
        }
示例#5
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;
            }      

        }
示例#6
0
 void IMapUpdate.PositionChange(DDDObjects obj)
 {
     DDDObjects selected = GetSelectedObject();
     if (selected != null)
     {
         if (selected == obj)
         {
             _commands.SelectionUpdate();
         }
     }
 }
示例#7
0
        public override void OnRender(Canvas canvas)
        {
            if (Map != null)
            {
                Map.Draw(canvas);
            }

            DrawActiveZones(canvas);

            DDDObjects.Scale = Scale;
            if (!ScaleUnitWithMap)
            {
                DDDObjects.MinScale = 1;
            }
            else
            {
                DDDObjects.MinScale = .5f;
            }

            DDDObjects.MapPosition(Map.Position.X, Map.Position.Y);


            lock (this)
            {
                DDDObjects selected_target = GetSelectedTarget();
                DDDObjects selected_asset  = GetSelectedObject();

                //draw range rings
                foreach (string obj_name in OrderedPlayfieldObjects)
                {
                    DDDObjects obj = (DDDObjects)GetMappableObject(obj_name);
                    if (obj != null)
                    {
                        obj.DrawRangeRings(canvas);
                    }
                }

                foreach (string obj_name in OrderedPlayfieldObjects)
                {
                    DDDObjects obj = (DDDObjects)GetMappableObject(obj_name);
                    if (obj != null)
                    {
                        if (obj == selected_asset)
                        { //display mouseover info
                            float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X - Map.Position.X) / Scale);
                            float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y - Map.Position.Y) / Scale);
                            //float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X + (obj.SpriteArea.Width / 2)) - Map.Position.X);
                            //float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y + (obj.SpriteArea.Height / 2) - (Scale * 50)) - Map.Position.Y);

                            //Console.WriteLine("x: {0}; y: {1}", xpos, ypos);
                            // Console.WriteLine("x: {0}; y: {1}", xpos, ypos + (obj.SpriteArea.Height / 2) / Scale);

                            DDD_Global.Instance.SetRangeFinderDistance(xpos, ypos);
                            //get distance string
                            string distanceFromSelected = DDD_Global.Instance.RangeFinderDistanceString;
                            int    distance             = -1;
                            int    intensity            = -1;
                            if (distanceFromSelected.Trim() != "")
                            {
                                distance  = (int)Math.Round(Convert.ToDouble(distanceFromSelected));
                                intensity = obj.GetCapabilityRangeRingIntensity(obj.CurrentlySelectedCapability, true, distance);
                                if (intensity > 0)
                                {
                                    DDD_Global.Instance.RangeFinderIntensityString = String.Format("{0}", intensity);
                                }
                                else
                                {
                                    DDD_Global.Instance.RangeFinderIntensityString = string.Empty;
                                }
                            }
                            //check if a capability is selected, if so get ranges, and then use disance to calculate intensity.
                        }

                        // obj.DrawRangeRings(canvas); //moved above
                        obj.DrawUnmanagedAssetLabel = DrawUnmanagedAssetLabels;
                        obj.SetDiffuseColor();
                        if (obj.IsPathCalculatorRunning())
                        {
                            if (!obj.IsWeapon)
                            {
                                obj.HeadingColor = Color.DodgerBlue;
                            }
                            else
                            {
                                obj.HeadingColor = Color.Red;
                            }
                            obj.DrawHeading(canvas);
                        }
                        if ((obj != selected_asset) && (obj != selected_target))
                        {
                            obj.TextColor   = Color.White;
                            obj.BorderColor = Color.Black;
                            obj.Draw(canvas, Fonts["Small"]);
                            obj.DrawSpecial(canvas, Fonts["Small"]);
                        }
                    }
                }


                //Render selected objects last.
                if (selected_target != null)
                {
                    //selected_asset.DiffuseColor = Color.Yellow;
                    selected_target.TextColor   = Color.Yellow;
                    selected_target.BorderColor = Color.Yellow;
                    selected_target.Draw(canvas, Fonts["Small"]);
                    selected_target.DrawSpecial(canvas, Fonts["Small"]);
                }
                if (selected_asset != null)
                {
                    //selected_asset.DiffuseColor = Color.Yellow;
                    selected_asset.TextColor   = Color.Yellow;
                    selected_asset.BorderColor = Color.Yellow;
                    selected_asset.Draw(canvas, Fonts["Small"]);
                    selected_asset.DrawSpecial(canvas, Fonts["Small"]);
                }
            }



            if (DrawDistanceLine)
            {
                canvas.DrawLine(Color.Lime, 1, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y);
                double distance = Math.Sqrt(Math.Pow((LineEndLocation.X - LineStartLocation.X), 2) + Math.Pow((LineEndLocation.Y - LineStartLocation.Y), 2));
                Fonts["Small"].DrawText(null,
                                        string.Format("{0} m", Math.Round(UTM_Mapping.HorizontalPixelsToMeters((float)(distance / Scale)))),
                                        LineEndLocation.X + 12, LineEndLocation.Y - 12, Color.Lime);
            }
        }
示例#8
0
        public override void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (!ClientArea.Contains(e.X, e.Y))
            {
                return;
            }
            switch (e.Button)
            {
            case MouseButtons.Left:
                if (!DrawDistanceLine)
                {
                    Mode = MapModes.MOVE;
                    DDDObjects previous = this.GetSelectedObject();
                    if (!SelectSingle(e.X, e.Y))
                    {
                        DeselectAll();
                        DDD_Global.Instance.RangeFinderDistanceString = "";
                    }
                    DDDObjects current = GetSelectedObject();

                    if ((current == null) && (previous == null))
                    {
                        return;
                    }
                    if ((current != null) && (previous != null))
                    {
                        if (previous.ObjectID.CompareTo(current.ObjectID) == 0)
                        {
                            return;
                        }
                    }
                    DDD_Global.Instance.RangeFinderDistanceString = " ";
                    Command.SelectionUpdate();
                }
                break;

            case MouseButtons.Right:
                switch (Mode)
                {
                case MapModes.MOVE:
                    MoveSelected(e.X, e.Y);
                    break;

                case MapModes.ATTACK:
                    if (RightClickSelect(e.X, e.Y))
                    {
                        WinForm_AttackSelected();
                    }
                    break;

                case MapModes.SUBPLATFORM:
                    if (!RightClickSelect(e.X, e.Y))
                    {
                        WinForm_LaunchSubPlatform(e.X, e.Y);
                    }
                    else
                    {
                        // Dock to selected subplatform
                        WinForm_DockToSelected();
                    }
                    break;
                }

                break;
            }
        }
示例#9
0
        private void PopulateObjectAttributes(DDDObjects object_data)
        {
            try
            {
                if (object_data != null)
                {
                    //SetUnitControlIndex(0);
                    ChangeControlState(UnitControls, true);
                    UpdateLabel(ObjectAltitude, object_data.AltitudeStr);
                    UpdateLabel(ObjectClass, object_data.ClassName);
                    UpdateLabel(ObjectFuelAmount, object_data.FuelAmountStr);
                    UpdateLabel(ObjectFuelCapacity, object_data.FuelCapacityStr);
                    UpdateLabel(ObjectMaxSpeed, object_data.MaxSpeedStr);
                    UpdateLabel(ObjectName, object_data.ObjectID);
                    UpdateLabel(ObjectStatus, object_data.State);
                    UpdateLabel(ObjectThrottle, object_data.ThrottleStr);
                    UpdateLabel(ObjectLocation, object_data.PositionStr);
                    //UpdateLabel(ThrottleLabel, string.Format("{0} %", object_data.Throttle * 100));
                    //if (!textBoxUnitTag.Focused)
                    //{
                    UpdateLabel(textBoxUnitTag, object_data.Tag);
                    UpdateLabel(textBoxClassification, object_data.Classification);

                    //}
                  //  SetTextboxReadStatus(textBoxUnitTag, false);

                    FuelGaugeUpdate((int)object_data.FuelAmount, (int)object_data.FuelCapacity);
                    //ThrottleUpdate((int)(object_data.Throttle * ThrottleControl.Maximum));
                    VulnerabilitiesUpdate(object_data);
                    SensorsUpdate(object_data);
                    WeaponsUpdate(object_data);
                    SubplatformUpdate(object_data);

                    _customAttributesDialog.SetDataGridView(object_data.ObjectID, object_data.CustomAttributes);
                    EnableButtonsForOwnedObjects(object_data.OwnerID == DDD_Global.Instance.PlayerID);
                }
                else
                {

                    UpdateLabel(ObjectAltitude, string.Empty);
                    UpdateLabel(ObjectClass, string.Empty);
                    UpdateLabel(ObjectFuelAmount, string.Empty);
                    UpdateLabel(ObjectFuelCapacity, string.Empty);
                    UpdateLabel(ObjectLocation, string.Empty);
                    UpdateLabel(ObjectMaxSpeed, string.Empty);
                    UpdateLabel(ObjectName, string.Empty);
                    UpdateLabel(ObjectStatus, string.Empty);
                    UpdateLabel(ObjectThrottle, string.Empty);
                    UpdateLabel(textBoxUnitTag, string.Empty);
                    UpdateLabel(textBoxClassification, string.Empty);
                    //SetTextboxReadStatus(textBoxUnitTag, true);

                    FuelGaugeUpdate(0, 0);
                    ThrottleUpdate(0);
                    VulnerabilitiesUpdate(null);
                    SensorsUpdate(null);
                    WeaponsUpdate(null);
                    SubplatformUpdate(null);
                    ChangeControlState(UnitControls, false);

                    _customAttributesDialog.SetDataGridView(string.Empty, new Dictionary<string, DataValue>());
                    EnableButtonsForOwnedObjects(false);
                }
            }
            catch (Exception exc)
            {
                throw new Exception(exc.Message);

            }
        }
示例#10
0
        private void SubplatformUpdate(DDDObjects obj)
        {
            if (!InvokeRequired)
            {
                try
                {
                    //get previously selected.
                    String previouslySelected = string.Empty;
                    if (SubplatformList.Items.Count > 0)
                    {
                        previouslySelected = (String)SubplatformList.SelectedItem;
                    }

                    if (obj != null)
                    {
                    //clear the list
                        SubplatformList.Items.Clear();
                        SubplatformList.Items.Add("Dock this object");

                    //add new list
                        if (obj.SubPlatforms != null)
                        {
                            SubplatformList.Items.AddRange(obj.SubPlatforms);
                        }
                    //reset selected
                        if (previouslySelected != string.Empty)
                        { //find and select the previous item
                            int index = 0;
                            bool isDone = false;
                            while (!isDone && index < SubplatformList.Items.Count)
                            {
                                if (SubplatformList.Items[index].ToString().Equals(previouslySelected))
                                {
                                    SubplatformManuallyChanged = true;
                                    SubplatformList.SelectedIndex = index;
                                    SubplatformManuallyChanged = false;
                                    isDone = true;
                                }
                                index++;
                            }

                        }

                    }
                    else
                    {
                        SubplatformList.Items.Clear();
                        SubplatformList.Items.Add("Dock this object");
                    }
                }
                catch (Exception exc)
                {
                    throw new Exception(exc.Message);
                }
            }
            else
            {
                BeginInvoke(new SubplatformUpdateDelegate(SubplatformUpdate), obj);
            }
        }
示例#11
0
        private void WeaponsUpdate(DDDObjects obj)
        {
            if (!InvokeRequired)
            {
                CapabilityListUpdating = true;
                try
                {
                    if (obj != null)
                    {
                        if (obj.CapabilityAndWeapons != null)
                        {
                            if (obj.CapabilityAndWeapons.Length != CapabilitiesList.Items.Count)
                            {
                                string previouslySelected = string.Empty;
                                CapabilitiesList.SelectedIndex = -1;
                                //if (CapabilitiesList.SelectedItem != null)
                                //{
                                //    previouslySelected = CapabilitiesList.SelectedItem.ToString();
                                //    if (previouslySelected.LastIndexOf('(') > 0)
                                //    {
                                //        previouslySelected = previouslySelected.Remove(previouslySelected.LastIndexOf('(')); //weapons
                                //    }
                                //}
                                //else
                                //{
                                previouslySelected = obj.CurrentlySelectedCapability;
                                //}
                                CapabilitiesList.Items.Clear();
                                CapabilitiesList.Items.AddRange(obj.CapabilityAndWeapons);

                                if (previouslySelected != string.Empty)
                                { //find and select the previous item
                                    int index = 0;
                                    bool isDone = false;
                                    while (!isDone && index < CapabilitiesList.Items.Count)
                                    {
                                        if (CapabilitiesList.Items[index].ToString().StartsWith(previouslySelected))
                                        {
                                            CapabilitiesList.SelectedIndex = index;
                                            isDone = true;
                                        }
                                        index++;
                                    }

                                }
                                return;
                            }
                            else
                            {
                                int previousSelectedIndex = -1; // CapabilitiesList.SelectedIndex;
                                CapabilitiesList.SelectedIndex = -1;
                                string previouslySelectedValue = obj.CurrentlySelectedCapability;
                                /*string.Empty;
                            if (CapabilitiesList.SelectedItem != null)
                            {
                                previouslySelectedValue = CapabilitiesList.SelectedItem.ToString();
                            }
                                 */

                                for (int i = 0; i < obj.CapabilityAndWeapons.Length; i++)
                                {
                                    CapabilitiesList.Items[i] = obj.CapabilityAndWeapons[i];
                                    if (previouslySelectedValue == obj.CapabilityAndWeapons[i])
                                    {
                                        previousSelectedIndex = i;
                                    }
                                }

                                if (previousSelectedIndex >= 0)
                                {
                                    string str = CapabilitiesList.Items[previousSelectedIndex].ToString();

                                    if (previouslySelectedValue.Contains("(") && str.Contains("("))
                                    {

                                        if (str.Substring(0, (str.LastIndexOf('('))) ==
                                            previouslySelectedValue.Substring(0, (previouslySelectedValue.LastIndexOf('(')))) //weapons
                                        {
                                            CapabilitiesList.SelectedIndex = previousSelectedIndex;
                                        }

                                    }
                                    else
                                    {
                                        if (CapabilitiesList.Items[previousSelectedIndex].ToString() ==
                                            previouslySelectedValue)
                                        {
                                            CapabilitiesList.SelectedIndex = previousSelectedIndex;
                                        }
                                    }
                                }
                                return;
                            }
                        }
                        CapabilitiesList.Items.Add("No Weapons.");
                    }
                    else
                    {
                        CapabilitiesList.Items.Clear();
                    }
                }
                catch (Exception exc)
                {
                    CapabilityListUpdating = false;
                    throw new Exception(exc.Message);
                }
                CapabilityListUpdating = false;
            }
            else
            {
                BeginInvoke(new WeaponsUpdateDelegate(WeaponsUpdate), obj);
            }
        }
示例#12
0
        private void VulnerabilitiesUpdate(DDDObjects obj)
        {
            if (!InvokeRequired)
            {
                try
                {
                    if (obj == null)
                    {
                        return; //weird exception.
                    }
                    string current = obj.CurrentlySelectedVulnerability;
                    int count = 0;
                    int selectedIndex = -1;
                    VulnerabilitiesList.Items.Clear();

                    if (obj != null)
                    {
                        if (obj.Vulnerabilities != null)
                        {
                            if (obj.Vulnerabilities.Length > 0)
                            {
                                VulnerabilitiesList.Items.AddRange(obj.Vulnerabilities);
                                foreach (object ob in VulnerabilitiesList.Items)
                                {
                                    if (ob.ToString() == current)
                                    {
                                        selectedIndex = count;
                                    }
                                    count++;
                                }
                                //return;
                            }
                        }
                    }
                    if (VulnerabilitiesList.Items.Count == 0)
                    {
                        VulnerabilitiesList.Items.Add("No Detected Vulnerabilities.");
                    }
                    VulnerabilitiesList.SelectedIndex = selectedIndex;
                }
                catch (Exception exc)
                {
                    throw new Exception(exc.Message);
                }
            }
            else
            {
                BeginInvoke(new VulnerabilitiesUpdateDelegate(VulnerabilitiesUpdate), obj);
            }
        }
示例#13
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();

        }