示例#1
0
 public void ChangePressure(int change)
 {
     pressure += change;
     if (pressure > maxPressure)
     {
         pressure = maxPressure;
     }
     else if (pressure < minPressure)
     {
         pressure = minPressure;
     }
     if (pressure > highBorder)
     {
         curPressureState = PressureState.High;
         speed            = 4;
         jumpForce        = 550;
     }
     else if (pressure < lowBorder)
     {
         curPressureState = PressureState.Low;
         speed            = 2;
         jumpForce        = 300;
     }
     else
     {
         curPressureState = PressureState.Medium;
         speed            = 3;
         jumpForce        = 400;
     }
     pressUIScript.SetPressure(curPressureState);
 }
        void HighRangeIndicatorLeave(object sender, IndicatorLeaveEventArgs e)
        {
            ArcScaleRange range = sender as ArcScaleRange;

            if (range != null)
            {
                pressure = e.NewValue < range.StartValueAbsolute ? PressureState.Normal : PressureState.Undefined;
                UpdateWeatherState();
            }
        }
        void NormalRangeIndicatorLeave(object sender, IndicatorLeaveEventArgs e)
        {
            LinearScaleRange range = sender as LinearScaleRange;

            if (range != null)
            {
                pressure = e.NewValue < range.StartValueAbsolute ? PressureState.Low : PressureState.High;
                UpdateWeatherState();
            }
        }
        void LowRangeIndicatorLeave(object sender, IndicatorLeaveEventArgs e)
        {
            LinearScaleRange range = sender as LinearScaleRange;

            if (range != null && e.NewValue < range.StartValueAbsolute)
            {
                pressure = PressureState.Undefined;
                UpdateWeatherState();
            }
        }
示例#5
0
        //  Every child of this base class must implement Shot() method, which shots projectile or missile.
        //  Method returns true if something was shot. False if not (because interval between two shots didn't pass)
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeStarted) < MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
                return false;

            if (!base.Shot(usedAmmo))
                return false;

            m_state = PressureState.Init;

            return true;
        }
        //  Every child of this base class must implement Shot() method, which shots projectile or missile.
        //  Method returns true if something was shot. False if not (because interval between two shots didn't pass)
        public override bool Shot(MyMwcObjectBuilder_SmallShip_Ammo usedAmmo)
        {
            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeStarted) < MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                return(false);
            }

            if (!base.Shot(usedAmmo))
            {
                return(false);
            }

            m_state = PressureState.Init;

            return(true);
        }
示例#7
0
        void checkPressureState(PressureState pressureState)
        {
            if (pressureState == PressureState.OK)
            {
                tbShowPressure.Text = "Давление в норме.";
                if (this.autoRepairPressureTimer.Enabled)
                {
                    this.autoRepairPressureTimer.Stop();
                }

                this.brokePressureBtn.Enabled  = true;
                this.repairPressureBtn.Enabled = false;

                if (!this.fuelFillTimer.Enabled && !this.simulationState.IsStorageFull && this.simulationState.IsOk)
                {
                    this.fuelFillTimer.Start();
                }
            }
            else
            {
                tbShowPressure.Text = "Нарушение давления в системе.";
                if (!this.autoRepairPressureTimer.Enabled)
                {
                    this.autoRepairPressureTimer.Start();
                }

                this.brokePressureBtn.Enabled  = false;
                this.repairPressureBtn.Enabled = true;

                if (this.fuelFillTimer.Enabled)
                {
                    this.fuelFillTimer.Stop();
                }
            }
            ShowPressure(simulationState.CurrentPressure);
        }
 void HighRangeIndicatorEnter(object sender, IndicatorEnterEventArgs e)
 {
     pressure = PressureState.High;
     UpdateWeatherState();
 }
 void NormalRangeIndicatorEnter(object sender, IndicatorEnterEventArgs e)
 {
     pressure = PressureState.Normal;
     UpdateWeatherState();
 }
示例#10
0
	public void  ReleasePressureFromTrigger (){
		pressure_on_trigger = PressureState.NONE;
		trigger_pressed = 0.0f;
	}
示例#11
0
	public bool ApplyPressureToTrigger (){
		 if(pressure_on_trigger == PressureState.NONE){
			pressure_on_trigger = PressureState.INITIAL;
			fired_once_this_pull = false;
		} else {
			pressure_on_trigger = PressureState.CONTINUING;
		}
		if(yolk_stage != YolkStage.CLOSED){
			return false;
		}
		if((pressure_on_trigger == PressureState.INITIAL || action_type == ActionType.DOUBLE) && !slide_lock && thumb_on_hammer == Thumb.OFF_HAMMER && hammer_cocked == 1.0f && safety_off == 1.0f && (auto_mod_stage == AutoModStage.ENABLED || !fired_once_this_pull)){
			trigger_pressed = 1.0f;
			if(gun_type == GunType.AUTOMATIC && slide_amount == 0.0f){
				hammer_cocked = 0.0f;
				if(round_in_chamber && round_in_chamber_state == RoundState.READY){
					fired_once_this_pull = true;
					PlaySoundFromGroup(sound_gunshot_smallroom, 1.0f);
					round_in_chamber_state = RoundState.FIRED;
					GameObject.Destroy(round_in_chamber);
					round_in_chamber = Instantiate(shell_casing, transform.FindChild("point_chambered_round").position, transform.rotation) as GameObject;
					round_in_chamber.transform.parent = transform;
					var renderers= round_in_chamber.GetComponentsInChildren<Renderer>();
					foreach(Renderer renderer in renderers){
						renderer.shadowCastingMode = ShadowCastingMode.Off;
					}
					
					Instantiate(muzzle_flash, transform.FindChild("point_muzzleflash").position, transform.FindChild("point_muzzleflash").rotation);
					var bullet= Instantiate(bullet_obj, transform.FindChild("point_muzzle").position, transform.FindChild("point_muzzle").rotation) as GameObject;
					bullet.GetComponent<BulletScript>().SetVelocity(transform.forward * 251.0f);
					PullSlideBack();
					rotation_transfer_y += Random.Range(1.0f,2.0f);
					rotation_transfer_x += Random.Range(-1.0f,1.0f);
					recoil_transfer_x -= Random.Range(150.0f,300.0f);
					recoil_transfer_y += Random.Range(-200.0f,200.0f);
					add_head_recoil = true;
					return true;
				} else {
					PlaySoundFromGroup(sound_mag_eject_button, 0.5f);
				}
			} else if(gun_type == GunType.REVOLVER){
				hammer_cocked = 0.0f;
				var which_chamber= active_cylinder % cylinder_capacity;
				if(which_chamber < 0){
					which_chamber += cylinder_capacity;
				}
				var round= cylinders[which_chamber]._object;
				if(round && cylinders[which_chamber].can_fire){
					PlaySoundFromGroup(sound_gunshot_smallroom, 1.0f);
					round_in_chamber_state = RoundState.FIRED;
					cylinders[which_chamber].can_fire = false;
					cylinders[which_chamber].seated += Random.Range(0.0f,0.5f);
					cylinders[which_chamber]._object = Instantiate(shell_casing, round.transform.position, round.transform.rotation) as GameObject;
					GameObject.Destroy(round);
					var renderers = cylinders[which_chamber]._object.GetComponentsInChildren<Renderer>();
					foreach(Renderer renderer in renderers){
						renderer.shadowCastingMode = ShadowCastingMode.Off;
					}				
					Instantiate(muzzle_flash, transform.FindChild("point_muzzleflash").position, transform.FindChild("point_muzzleflash").rotation);
					var bullet = Instantiate(bullet_obj, transform.FindChild("point_muzzle").position, transform.FindChild("point_muzzle").rotation) as GameObject;
					bullet.GetComponent<BulletScript>().SetVelocity(transform.forward * 251.0f);
					rotation_transfer_y += Random.Range(1.0f,2.0f);
					rotation_transfer_x += Random.Range(-1.0f,1.0f);
					recoil_transfer_x -= Random.Range(150.0f,300.0f);
					recoil_transfer_y += Random.Range(-200.0f,200.0f);
					add_head_recoil = true;
					return true;
				} else {
					PlaySoundFromGroup(sound_mag_eject_button, 0.5f);
				}
			}
		}
		
		if(action_type == ActionType.DOUBLE && trigger_pressed < 1.0f && thumb_on_hammer == Thumb.OFF_HAMMER){
			CockHammer();
			CockHammer();
		}
		
		return false;
	}
示例#12
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            var muzzlePosition = m_positionMuzzleInWorldSpace;
            muzzlePosition += NearFlag
                                     ? MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE * WorldMatrix.Forward
                                     : .5f * WorldMatrix.Forward;
            if (m_state == PressureState.Pushed && CurrentState == MyDrillStateEnum.Activated)
            {
                StartPressureIdleCue();
            }
            else
            {
                StopPressureIdleCue();
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeStarted) >= MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                StopDrillingCue();
                StopMovingCue();
                m_state = PressureState.Pushed;

                return;
            }

            if (m_pressureFireEffect != null && !m_pressureFireEffect.IsStopped)
            {
                m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(
                    muzzlePosition + 1.5f * WorldMatrix.Forward,
                    WorldMatrix.Forward,
                    WorldMatrix.Up);
            }

            switch (m_state)
            {
                case PressureState.Init:
                    StartDrillChargingCue();
                    m_state = PressureState.Charging;

                    m_chargingPressureEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Charge);
                    m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                    break;

                case PressureState.Charging:
                    {
                        ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                        if (m_chargingPressureEffect != null)
                        {
                            m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                        }

                        if (m_drillChargingCue == null || !m_drillChargingCue.Value.IsPlaying)
                            m_state = PressureState.Ready;
                    }
                    break;

                case PressureState.Ready:
                    {
                        
                        m_chargingPressureEffect.Stop();
                        m_chargingPressureEffect = null;

                        m_pressureFireEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Fire);
                        m_pressureFireEffect.OnDelete += OnPressureFireEffectDelete;
                        m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);

                        //  Check for collision with drill and world
                        MyLine line = new MyLine(GetPosition(), GetPosition() + 2 * m_radius * WorldMatrix.Forward, true);

                        MyIntersectionResultLineTriangleEx? intersection = MyEntities.GetIntersectionWithLine(ref line, Parent, null);

                        if (intersection != null && intersection.Value.Entity.Physics != null)
                        {
                            var voxelMap = intersection.Value.Entity as MyVoxelMap;

                            StartDrillingCue(voxelMap != null);

                            if (voxelMap != null)
                            {

                                ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_IN_VOXELS);

                                //  We found voxel so lets make tunel into it
                                BoundingSphere bigSphereForTunnel = new BoundingSphere(GetPosition() + 20 * WorldMatrix.Forward, m_radius);

                                for (int i = 1; i < (int)m_radius; i++)
                                {
                                    bigSphereForTunnel.Center = GetPosition() + (20 + i) * WorldMatrix.Forward;
                                    bigSphereForTunnel.Radius = i * 2;

                                    CutOutFromVoxel(voxelMap, ref bigSphereForTunnel);
                                }

                                CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact);
                                StartDrillBlastRockCue();
                            }
                            //  Display particles when we are in contact with voxel
                            else
                            {
                                ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                                CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact_Metal);

                                intersection.Value.Entity.DoDamage(0, m_damage, 0, MyDamageType.Drill, MyAmmoType.Explosive, Parent);

                                StartDrillBlastOtherCue();
                            }

                        }
                        else
                        {
                            StartDrillBlastCue();
                        }
                        m_state = PressureState.Pushed;
                    }
                    break;

                case PressureState.Pushed:
                    {
                        StopDrillingBlastCue();
                        StopMovingCue();
                    }
                    break;
            }
        }
示例#13
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            var muzzlePosition = m_positionMuzzleInWorldSpace;

            muzzlePosition += NearFlag
                                     ? MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE * WorldMatrix.Forward
                                     : .5f * WorldMatrix.Forward;
            if (m_state == PressureState.Pushed && CurrentState == MyDrillStateEnum.Activated)
            {
                StartPressureIdleCue();
            }
            else
            {
                StopPressureIdleCue();
            }

            if ((MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeStarted) >= MyPressureDrillDeviceConstants.SHOT_INTERVAL_IN_MILISECONDS)
            {
                StopDrillingCue();
                StopMovingCue();
                m_state = PressureState.Pushed;

                return;
            }

            if (m_pressureFireEffect != null && !m_pressureFireEffect.IsStopped)
            {
                m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(
                    muzzlePosition + 1.5f * WorldMatrix.Forward,
                    WorldMatrix.Forward,
                    WorldMatrix.Up);
            }

            switch (m_state)
            {
            case PressureState.Init:
                StartDrillChargingCue();
                m_state = PressureState.Charging;

                m_chargingPressureEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Charge);
                m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                break;

            case PressureState.Charging:
            {
                ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                if (m_chargingPressureEffect != null)
                {
                    m_chargingPressureEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);
                }

                if (m_drillChargingCue == null || !m_drillChargingCue.Value.IsPlaying)
                {
                    m_state = PressureState.Ready;
                }
            }
            break;

            case PressureState.Ready:
            {
                m_chargingPressureEffect.Stop();
                m_chargingPressureEffect = null;

                m_pressureFireEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Drill_Pressure_Fire);
                m_pressureFireEffect.OnDelete   += OnPressureFireEffectDelete;
                m_pressureFireEffect.WorldMatrix = Matrix.CreateWorld(muzzlePosition, WorldMatrix.Forward, WorldMatrix.Up);

                //  Check for collision with drill and world
                MyLine line = new MyLine(GetPosition(), GetPosition() + 2 * m_radius * WorldMatrix.Forward, true);

                MyIntersectionResultLineTriangleEx?intersection = MyEntities.GetIntersectionWithLine(ref line, Parent, null);

                if (intersection != null && intersection.Value.Entity.Physics != null)
                {
                    var voxelMap = intersection.Value.Entity as MyVoxelMap;

                    StartDrillingCue(voxelMap != null);

                    if (voxelMap != null)
                    {
                        ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_IN_VOXELS);

                        //  We found voxel so lets make tunel into it
                        BoundingSphere bigSphereForTunnel = new BoundingSphere(GetPosition() + 20 * WorldMatrix.Forward, m_radius);

                        for (int i = 1; i < (int)m_radius; i++)
                        {
                            bigSphereForTunnel.Center = GetPosition() + (20 + i) * WorldMatrix.Forward;
                            bigSphereForTunnel.Radius = i * 2;

                            CutOutFromVoxel(voxelMap, ref bigSphereForTunnel);
                        }

                        CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact);
                        StartDrillBlastRockCue();
                    }
                    //  Display particles when we are in contact with voxel
                    else
                    {
                        ((MySmallShip)Parent).IncreaseHeadShake(MyDrillDeviceConstants.SHAKE_DURING_ROTATION);

                        CreateImpactEffect(intersection.Value.IntersectionPointInWorldSpace, intersection.Value.NormalInWorldSpace, MyParticleEffectsIDEnum.Drill_Pressure_Impact_Metal);

                        intersection.Value.Entity.DoDamage(0, m_damage, 0, MyDamageType.Drill, MyAmmoType.Explosive, Parent);

                        StartDrillBlastOtherCue();
                    }
                }
                else
                {
                    StartDrillBlastCue();
                }
                m_state = PressureState.Pushed;
            }
            break;

            case PressureState.Pushed:
            {
                StopDrillingBlastCue();
                StopMovingCue();
            }
            break;
            }
        }