Exemplo n.º 1
0
        public MySmallShipConfig(MySmallShip ship)
        {
            Engine = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.EngineShutdown), 0.25f, 0f, 1f, true, delegate()
                {
                    ship.SetEngineSound(this.Engine.On);
                    RaiseConfigChanged();
                }, null, MyMinerShipConstants.MINER_SHIP_ENGINE_SWITCH_MIN_REPEAT_TRESHOLD, null); //later it will be good to have repeat threshold changing with engine type for example

            ReflectorLight = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.ToggleHeadlights), 0.25f, 0f, 1f, true, delegate()
                {
                    MyAudio.AddCue2D(this.ReflectorLight.On ? MySoundCuesEnum.VehShipaLightsOn : MySoundCuesEnum.VehShipaLightsOff);
                    RaiseConfigChanged();
                }, null, 0, MyGameControlEnums.HEADLIGHTS);

            ReflectorLongRange = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRange),
                MyReflectorConstants.CHANGE_RANGE_INTERVAL_IN_MILISECONDS / 1000, 0f, 1f,
                MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRangeLong), MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRangeClose), false, delegate()
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.SfxHudReflectorRange);
                    RaiseConfigChanged();
                }, null, 0, MyGameControlEnums.HEADLIGTHS_DISTANCE);

            RadarType = new MyPhysObjectSmallShipConfigItemHudRadar();

            if (!(ship is MySmallShipBot))
            {
                AutoLeveling = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.AutoLevel), false, delegate()
                    {
                        MyAudio.AddCue2D(this.AutoLeveling.On ? MySoundCuesEnum.SfxHudAutolevelingOn : MySoundCuesEnum.SfxHudAutolevelingOff);
                    }, null, 0, MyGameControlEnums.AUTO_LEVEL);
            }
            else
            {
                AutoLeveling = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.AutoLevel), false, delegate()
                {
                    ;
                }, null, 0, MyGameControlEnums.AUTO_LEVEL);
            }


            MovementSlowdown = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.MovementSlowdown), true, delegate()
                {
                    MyAudio.AddCue2D(this.MovementSlowdown.On ? MySoundCuesEnum.SfxHudSlowMovementOn : MySoundCuesEnum.SfxHudSlowMovementOff);
                    RaiseConfigChanged();
                }, null, 0, MyGameControlEnums.MOVEMENT_SLOWDOWN);

            BackCamera = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.RearCam), false, delegate()
                {
                    MyAudio.AddCue2D(this.BackCamera.On ? MySoundCuesEnum.SfxHudBackcameraOn : MySoundCuesEnum.SfxHudBackcameraOff);
                    RaiseConfigChanged();
                }, null, 0, MyGameControlEnums.REAR_CAM);

            HarvestingTool = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.Harvest), m_noText, m_noText, false, delegate()
                {
                    MySession.PlayerShip.Weapons.FireHarvester();
                    RaiseConfigChanged();
                }, delegate()
                {
                    if (ship.Weapons.GetWeaponsObjectBuilders(false) == null) return false;
                    if (!ship.Config.Engine.Enable || ship.Fuel == 0) return false;
                    foreach (var item in ship.Weapons.GetWeaponsObjectBuilders(false))
                    {
                        if (item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device) return true;
                    }
                    return false;
                }, 0, MyGameControlEnums.HARVEST);

            DrillingTool = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.UseDrill), m_noText, m_noText, false, delegate()
                {
                    //This should be implemented somehow different
                    MySession.PlayerShip.Weapons.FireDrill();
                    RaiseConfigChanged();
                }, delegate()
                {
                    if (ship.Weapons.GetWeaponsObjectBuilders(false) == null) return false;
                    if (!ship.Config.Engine.Enable || ship.Fuel == 0) return false;
                    foreach (var item in ship.Weapons.GetWeaponsObjectBuilders(false))
                    {
                        if (item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher ||
                            item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Laser ||
                            item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Nuclear ||
                            item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Saw ||
                            item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Thermal ||
                            item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Pressure)
                            return true;
                    }
                    return false;
                }, 0, MyGameControlEnums.DRILL);

            HealthEnhancingMedicine = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ActivateHealthEnhancingMedicine), m_noText, m_noText, false, delegate()
            {
                if (!MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.HEALTH_ENHANCING_MEDICINE].IsActive())
                    MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.HEALTH_ENHANCING_MEDICINE].ActivateIfInInventory(MySession.PlayerShip.Inventory);
                RaiseConfigChanged();
            }, delegate()
            {
                var item = MySession.PlayerShip.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int?)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.HEALTH_ENHANCING_MEDICINE);
                return item != null;
            }, 0, null);

            PerformanceEnhancingMedicine = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ActivatePerformanceEnhancingMedicine), m_noText, m_noText, false, delegate()
            {
                if (!MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.PERFORMANCE_ENHANCING_MEDICINE].IsActive())
                    MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.PERFORMANCE_ENHANCING_MEDICINE].ActivateIfInInventory(MySession.PlayerShip.Inventory);
                RaiseConfigChanged();
            }, delegate()
            {
                var item = MySession.PlayerShip.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int?)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.PERFORMANCE_ENHANCING_MEDICINE);
                return item != null;
            }, 0, null);

            ViewMode = new MyPhysObjectSmallShipConfigItemViewMode();

            TimeBombTimer = new MyPhysObjectSmallShipConfigItemIntArray(
                MyTimeBombConstants.TIMEOUT_ARRAY, 1, MyTextsWrapper.Get(MyTextsWrapperEnum.TimeBombTimer),
                delegate()
                {
                    RaiseConfigChanged();
                }, null, null);

            RadarJammer = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ToolRadarJammerName), true,
                delegate()
                {
                    RaiseConfigChanged();
                },
                delegate()
                {
                    return MySession.PlayerShip.Inventory.Contains(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.RADAR_JAMMER);
                }, 0, null);

            m_items = new MyPhysObjectSmallShipConfigItem[] 
            { 
                Engine, 
                ReflectorLight, 
                ReflectorLongRange, 
                //RadarType, 
                AutoLeveling, 
                MovementSlowdown, 
                BackCamera,
                HarvestingTool,
                DrillingTool,
                ViewMode,
                HealthEnhancingMedicine,
                PerformanceEnhancingMedicine,
                TimeBombTimer,
                RadarJammer,
            };

        }
Exemplo n.º 2
0
        public MySmallShipConfig(MySmallShip ship)
        {
            Engine = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.EngineShutdown), 0.25f, 0f, 1f, true, delegate()
            {
                ship.SetEngineSound(this.Engine.On);
                RaiseConfigChanged();
            }, null, MyMinerShipConstants.MINER_SHIP_ENGINE_SWITCH_MIN_REPEAT_TRESHOLD, null);     //later it will be good to have repeat threshold changing with engine type for example

            ReflectorLight = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.ToggleHeadlights), 0.25f, 0f, 1f, true, delegate()
            {
                MyAudio.AddCue2D(this.ReflectorLight.On ? MySoundCuesEnum.VehShipaLightsOn : MySoundCuesEnum.VehShipaLightsOff);
                RaiseConfigChanged();
            }, null, 0, MyGameControlEnums.HEADLIGHTS);

            ReflectorLongRange = new MyPhysObjectSmallShipConfigItemBoolSwitchWithLevel(MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRange),
                                                                                        MyReflectorConstants.CHANGE_RANGE_INTERVAL_IN_MILISECONDS / 1000, 0f, 1f,
                                                                                        MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRangeLong), MyTextsWrapper.Get(MyTextsWrapperEnum.HeadlightsRangeClose), false, delegate()
            {
                MyAudio.AddCue2D(MySoundCuesEnum.SfxHudReflectorRange);
                RaiseConfigChanged();
            }, null, 0, MyGameControlEnums.HEADLIGTHS_DISTANCE);

            RadarType = new MyPhysObjectSmallShipConfigItemHudRadar();

            if (!(ship is MySmallShipBot))
            {
                AutoLeveling = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.AutoLevel), false, delegate()
                {
                    MyAudio.AddCue2D(this.AutoLeveling.On ? MySoundCuesEnum.SfxHudAutolevelingOn : MySoundCuesEnum.SfxHudAutolevelingOff);
                }, null, 0, MyGameControlEnums.AUTO_LEVEL);
            }
            else
            {
                AutoLeveling = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.AutoLevel), false, delegate()
                {
                    ;
                }, null, 0, MyGameControlEnums.AUTO_LEVEL);
            }


            MovementSlowdown = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.MovementSlowdown), true, delegate()
            {
                MyAudio.AddCue2D(this.MovementSlowdown.On ? MySoundCuesEnum.SfxHudSlowMovementOn : MySoundCuesEnum.SfxHudSlowMovementOff);
                RaiseConfigChanged();
            }, null, 0, MyGameControlEnums.MOVEMENT_SLOWDOWN);

            BackCamera = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.RearCam), false, delegate()
            {
                MyAudio.AddCue2D(this.BackCamera.On ? MySoundCuesEnum.SfxHudBackcameraOn : MySoundCuesEnum.SfxHudBackcameraOff);
                RaiseConfigChanged();
            }, null, 0, MyGameControlEnums.REAR_CAM);

            HarvestingTool = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.Harvest), m_noText, m_noText, false, delegate()
            {
                MySession.PlayerShip.Weapons.FireHarvester();
                RaiseConfigChanged();
            }, delegate()
            {
                if (ship.Weapons.GetWeaponsObjectBuilders(false) == null)
                {
                    return(false);
                }
                if (!ship.Config.Engine.Enable || ship.Fuel == 0)
                {
                    return(false);
                }
                foreach (var item in ship.Weapons.GetWeaponsObjectBuilders(false))
                {
                    if (item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device)
                    {
                        return(true);
                    }
                }
                return(false);
            }, 0, MyGameControlEnums.HARVEST);

            DrillingTool = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.UseDrill), m_noText, m_noText, false, delegate()
            {
                //This should be implemented somehow different
                MySession.PlayerShip.Weapons.FireDrill();
                RaiseConfigChanged();
            }, delegate()
            {
                if (ship.Weapons.GetWeaponsObjectBuilders(false) == null)
                {
                    return(false);
                }
                if (!ship.Config.Engine.Enable || ship.Fuel == 0)
                {
                    return(false);
                }
                foreach (var item in ship.Weapons.GetWeaponsObjectBuilders(false))
                {
                    if (item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher ||
                        item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Laser ||
                        item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Nuclear ||
                        item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Saw ||
                        item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Thermal ||
                        item.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Pressure)
                    {
                        return(true);
                    }
                }
                return(false);
            }, 0, MyGameControlEnums.DRILL);

            HealthEnhancingMedicine = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ActivateHealthEnhancingMedicine), m_noText, m_noText, false, delegate()
            {
                if (!MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.HEALTH_ENHANCING_MEDICINE].IsActive())
                {
                    MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.HEALTH_ENHANCING_MEDICINE].ActivateIfInInventory(MySession.PlayerShip.Inventory);
                }
                RaiseConfigChanged();
            }, delegate()
            {
                var item = MySession.PlayerShip.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int?)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.HEALTH_ENHANCING_MEDICINE);
                return(item != null);
            }, 0, null);

            PerformanceEnhancingMedicine = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ActivatePerformanceEnhancingMedicine), m_noText, m_noText, false, delegate()
            {
                if (!MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.PERFORMANCE_ENHANCING_MEDICINE].IsActive())
                {
                    MySession.Static.Player.Medicines[(int)MinerWars.AppCode.Game.Entities.Tools.MyMedicineType.PERFORMANCE_ENHANCING_MEDICINE].ActivateIfInInventory(MySession.PlayerShip.Inventory);
                }
                RaiseConfigChanged();
            }, delegate()
            {
                var item = MySession.PlayerShip.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int?)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.PERFORMANCE_ENHANCING_MEDICINE);
                return(item != null);
            }, 0, null);

            ViewMode = new MyPhysObjectSmallShipConfigItemViewMode();

            TimeBombTimer = new MyPhysObjectSmallShipConfigItemIntArray(
                MyTimeBombConstants.TIMEOUT_ARRAY, 1, MyTextsWrapper.Get(MyTextsWrapperEnum.TimeBombTimer),
                delegate()
            {
                RaiseConfigChanged();
            }, null, null);

            RadarJammer = new MyPhysObjectSmallShipConfigItemBoolSwitch(MyTextsWrapper.Get(MyTextsWrapperEnum.ToolRadarJammerName), true,
                                                                        delegate()
            {
                RaiseConfigChanged();
            },
                                                                        delegate()
            {
                return(MySession.PlayerShip.Inventory.Contains(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.RADAR_JAMMER));
            }, 0, null);

            m_items = new MyPhysObjectSmallShipConfigItem[]
            {
                Engine,
                ReflectorLight,
                ReflectorLongRange,
                //RadarType,
                AutoLeveling,
                MovementSlowdown,
                BackCamera,
                HarvestingTool,
                DrillingTool,
                ViewMode,
                HealthEnhancingMedicine,
                PerformanceEnhancingMedicine,
                TimeBombTimer,
                RadarJammer,
            };
        }