コード例 #1
0
 internal EquipmentBlockBase(BinaryReader binaryReader) : base(binaryReader)
 {
     this.powerupType        = (PowerupType)binaryReader.ReadInt16();
     this.grenadeType        = (GrenadeType)binaryReader.ReadInt16();
     this.powerupTimeSeconds = binaryReader.ReadSingle();
     this.pickupSound        = binaryReader.ReadTagReference();
 }
コード例 #2
0
 public LaunchedGrenade(Island World, Entity Source, GrenadeType grenadeType)
 {
     this.World       = World;
     this.Source      = Source;
     this.grenadeType = grenadeType;
     this.Countdown   = grenadeType.fuseTime;
 }
コード例 #3
0
 internal ActorStartingLocationsBlockBase(BinaryReader binaryReader)
 {
     this.name                    = binaryReader.ReadStringID();
     this.position                = binaryReader.ReadVector3();
     this.referenceFrame          = binaryReader.ReadInt16();
     this.invalidName_            = binaryReader.ReadBytes(2);
     this.facingYawPitchDegrees   = binaryReader.ReadVector2();
     this.flags                   = (Flags)binaryReader.ReadInt32();
     this.characterType           = binaryReader.ReadShortBlockIndex1();
     this.initialWeapon           = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon  = binaryReader.ReadShortBlockIndex1();
     this.invalidName_0           = binaryReader.ReadBytes(2);
     this.vehicleType             = binaryReader.ReadShortBlockIndex1();
     this.seatType                = (SeatType)binaryReader.ReadInt16();
     this.grenadeType             = (GrenadeType)binaryReader.ReadInt16();
     this.swarmCount              = binaryReader.ReadInt16();
     this.actorVariantName        = binaryReader.ReadStringID();
     this.vehicleVariantName      = binaryReader.ReadStringID();
     this.initialMovementDistance = binaryReader.ReadSingle();
     this.emitterVehicle          = binaryReader.ReadShortBlockIndex1();
     this.initialMovementMode     = (InitialMovementMode)binaryReader.ReadInt16();
     this.placementScript         = binaryReader.ReadString32();
     this.invalidName_1           = binaryReader.ReadBytes(2);
     this.invalidName_2           = binaryReader.ReadBytes(2);
 }
コード例 #4
0
 internal SquadsBlockBase(BinaryReader binaryReader)
 {
     this.name   = binaryReader.ReadString32();
     this.flags  = (Flags)binaryReader.ReadInt32();
     this.team   = (Team)binaryReader.ReadInt16();
     this.parent = binaryReader.ReadShortBlockIndex1();
     this.squadDelayTimeSeconds  = binaryReader.ReadSingle();
     this.normalDiffCount        = binaryReader.ReadInt16();
     this.insaneDiffCount        = binaryReader.ReadInt16();
     this.majorUpgrade           = (MajorUpgrade)binaryReader.ReadInt16();
     this.invalidName_           = binaryReader.ReadBytes(2);
     this.vehicleType            = binaryReader.ReadShortBlockIndex1();
     this.characterType          = binaryReader.ReadShortBlockIndex1();
     this.initialZone            = binaryReader.ReadShortBlockIndex1();
     this.invalidName_0          = binaryReader.ReadBytes(2);
     this.initialWeapon          = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon = binaryReader.ReadShortBlockIndex1();
     this.grenadeType            = (GrenadeType)binaryReader.ReadInt16();
     this.initialOrder           = binaryReader.ReadShortBlockIndex1();
     this.vehicleVariant         = binaryReader.ReadStringID();
     this.startingLocations      = ReadActorStartingLocationsBlockArray(binaryReader);
     this.placementScript        = binaryReader.ReadString32();
     this.invalidName_1          = binaryReader.ReadBytes(2);
     this.invalidName_2          = binaryReader.ReadBytes(2);
 }
コード例 #5
0
 public PlayerThrowGrenadeEvent(Player player, GrenadeType grenadeType, Vector direction, bool slowThrow, bool removeItem, bool allow) : base(player)
 {
     this.GrenadeType = grenadeType;
     this.Direction   = direction;
     this.SlowThrow   = slowThrow;
     this.Allow       = allow;
     this.RemoveItem  = removeItem;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThrowingGrenadeEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="grenadeManager"><inheritdoc cref="GrenadeManager"/></param>
 /// <param name="type"><inheritdoc cref="Type"/></param>
 /// <param name="isSlow"><inheritdoc cref="IsSlow"/></param>
 /// <param name="fuseTime"><inheritdoc cref="FuseTime"/></param>
 /// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
 public ThrowingGrenadeEventArgs(Player player, GrenadeManager grenadeManager, GrenadeType type, bool isSlow, double fuseTime, bool isAllowed = true)
 {
     Player         = player;
     GrenadeManager = grenadeManager;
     Type           = type;
     IsSlow         = isSlow;
     FuseTime       = fuseTime;
     IsAllowed      = isAllowed;
 }
コード例 #7
0
        public Player(PlayerIndex playerIndex)
        {
            PlayerIndex    = playerIndex;
            Position       = new Vector2(500 + (150 * (int)PlayerIndex), 500);
            MaxSpeed       = new Vector2(3.5f, 6);
            Gravity        = 0.6f;
            Size           = new Vector2(59, 98);
            CurrentGun     = GunType.Shotgun;
            CurrentGrenade = GrenadeType.Cluster;
            IsKinematic    = true;

            PlayerColor = Color.White;

            switch (PlayerIndex)
            {
            case PlayerIndex.One:
            {
                PlayerColor = Color.LimeGreen;
            }
            break;

            case PlayerIndex.Two:
            {
                PlayerColor = Color.RoyalBlue;
            }
            break;

            case PlayerIndex.Three:
            {
                PlayerColor = Color.Gold;
            }
            break;

            case PlayerIndex.Four:
            {
                PlayerColor = Color.Red;
            }
            break;
            }

            HealthBar = new HealthBar()
            {
                Position   = new Vector2(40 + (480 * (int)PlayerIndex), 40),
                Size       = new Vector2(440, 25),
                Player     = this,
                BackColor  = Color.Gray,
                FrontColor = PlayerColor
            };

            SpecialBar = new HealthBar(Color.DeepSkyBlue, Color.White)
            {
                Position = new Vector2(40 + (480 * (int)PlayerIndex), 40 + 25),
                Size     = new Vector2(440, 10),
                Player   = this,
            };
        }
コード例 #8
0
 public void UpdateGrenade(GrenadeType type, int amount)
 {
     if (type == GrenadeType.Frag)
     {
         fragGrenade += amount;
     }
     else if (type == GrenadeType.Smoke)
     {
         smokeGrenade += amount;
     }
 }
コード例 #9
0
 public void SetGrenadeAmount(GrenadeType type, int amount)
 {
     if (type == GrenadeType.Frag)
     {
         explosiveGrenade.text = amount + "";
     }
     else if (type == GrenadeType.Smoke)
     {
         smokeGrenade.text = amount + "";
     }
 }
コード例 #10
0
ファイル: GrenadeSystem.cs プロジェクト: YeeB3Warned/OSFPS
    public void ShowGrenadeExplosion(Vector3 position, GrenadeType grenadeType)
    {
        var        explosionPrefab        = GetGrenadeDefinitionByType(grenadeType).ExplosionPrefab;
        GameObject grenadeExplosionObject = Object.Instantiate(
            explosionPrefab, position, Quaternion.identity
            );

        var audioSource = grenadeExplosionObject.GetComponent <AudioSource>();

        audioSource?.Play();

        Object.Destroy(grenadeExplosionObject, OsFps.GrenadeExplosionDuration);
    }
コード例 #11
0
 // Start is called before the first frame update
 void Start()
 {
     //pState = GetComponent<PlayerController>().playerState();
     camstate = CamState.Main;
     for (int i = 0; i < cur_ammo.Length; i++)
     {
         cur_ammo[i] = max_ammo[i];
         Debug.Log("Cur_ammo is " + cur_ammo[i] + " / " + max_ammo[i]);
     }
     grenadeType = GrenadeType.exp;
     setWeapon();
     fireTimer = fireRate[cur_weaponType];
 }
コード例 #12
0
ファイル: Grenade.cs プロジェクト: GryffDavid/ArenaPlatformer
        //TODO: Maybe have a mechanic that allows players to either throw or drop a grenade.
        //Allowing them to drop it on a bounce pad OR throw it at another player

        public Grenade(Vector2 position, Vector2 velocity, object source, GrenadeType?grenadeType = GrenadeType.Regular)
        {
            GrenadeType = grenadeType.Value;
            Position    = position;
            Velocity    = velocity;
            Source      = source;

            Rotation          = MathHelper.ToRadians(Random.Next(0, 360));
            RotationIncrement = MathHelper.ToRadians(3);

            Time.Y = 1000f;

            Size = new Vector2(20, 26);
        }
コード例 #13
0
 internal UnitBlockBase(BinaryReader binaryReader) : base(binaryReader)
 {
     this.flags                                             = (Flags)binaryReader.ReadInt32();
     this.defaultTeam                                       = (DefaultTeam)binaryReader.ReadInt16();
     this.constantSoundVolume                               = (ConstantSoundVolume)binaryReader.ReadInt16();
     this.integratedLightToggle                             = binaryReader.ReadTagReference();
     this.cameraFieldOfViewDegrees                          = binaryReader.ReadSingle();
     this.cameraStiffness                                   = binaryReader.ReadSingle();
     this.unitCamera                                        = new UnitCameraStructBlock(binaryReader);
     this.acceleration                                      = new UnitSeatAccelerationStructBlock(binaryReader);
     this.softPingThreshold01                               = binaryReader.ReadSingle();
     this.softPingInterruptTimeSeconds                      = binaryReader.ReadSingle();
     this.hardPingThreshold01                               = binaryReader.ReadSingle();
     this.hardPingInterruptTimeSeconds                      = binaryReader.ReadSingle();
     this.hardDeathThreshold01                              = binaryReader.ReadSingle();
     this.feignDeathThreshold01                             = binaryReader.ReadSingle();
     this.feignDeathTimeSeconds                             = binaryReader.ReadSingle();
     this.distanceOfEvadeAnimWorldUnits                     = binaryReader.ReadSingle();
     this.distanceOfDiveAnimWorldUnits                      = binaryReader.ReadSingle();
     this.stunnedMovementThreshold01                        = binaryReader.ReadSingle();
     this.feignDeathChance01                                = binaryReader.ReadSingle();
     this.feignRepeatChance01                               = binaryReader.ReadSingle();
     this.spawnedTurretCharacter                            = binaryReader.ReadTagReference();
     this.spawnedActorCount                                 = binaryReader.ReadInt32();
     this.spawnedVelocity                                   = binaryReader.ReadSingle();
     this.aimingVelocityMaximumDegreesPerSecond             = binaryReader.ReadSingle();
     this.aimingAccelerationMaximumDegreesPerSecondSquared  = binaryReader.ReadSingle();
     this.casualAimingModifier01                            = binaryReader.ReadSingle();
     this.lookingVelocityMaximumDegreesPerSecond            = binaryReader.ReadSingle();
     this.lookingAccelerationMaximumDegreesPerSecondSquared = binaryReader.ReadSingle();
     this.rightHandNode                                     = binaryReader.ReadStringID();
     this.leftHandNode                                      = binaryReader.ReadStringID();
     this.moreDamnNodes                                     = new UnitAdditionalNodeNamesStructBlock(binaryReader);
     this.meleeDamage                                       = binaryReader.ReadTagReference();
     this.yourMomma                                         = new UnitBoardingMeleeStructBlock(binaryReader);
     this.motionSensorBlipSize                              = (MotionSensorBlipSize)binaryReader.ReadInt16();
     this.invalidName_                                      = binaryReader.ReadBytes(2);
     this.postures                                          = ReadUnitPosturesBlockArray(binaryReader);
     this.nEWHUDINTERFACES                                  = ReadUnitHudReferenceBlockArray(binaryReader);
     this.dialogueVariants                                  = ReadDialogueVariantBlockArray(binaryReader);
     this.grenadeVelocityWorldUnitsPerSecond                = binaryReader.ReadSingle();
     this.grenadeType                                       = (GrenadeType)binaryReader.ReadInt16();
     this.grenadeCount                                      = binaryReader.ReadInt16();
     this.poweredSeats                                      = ReadPoweredSeatBlockArray(binaryReader);
     this.weapons                                           = ReadUnitWeaponBlockArray(binaryReader);
     this.seats                                             = ReadUnitSeatBlockArray(binaryReader);
     this.boost                                             = new UnitBoostStructBlock(binaryReader);
     this.lipsync                                           = new UnitLipsyncScalesStructBlock(binaryReader);
 }
コード例 #14
0
        /// <inheritdoc/>
        protected override void OnReloading(ReloadingWeaponEventArgs ev)
        {
            if (UseGrenades)
            {
                ev.IsAllowed = false;

                if (!(ev.Player.CurrentItem is Firearm firearm) || firearm.Ammo >= ClipSize)
                {
                    return;
                }

                Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} is reloading!", CustomItems.Instance.Config.IsDebugEnabled);

                foreach (Item item in ev.Player.Items.ToList())
                {
                    Log.Debug($"{Name}.{nameof(OnReloading)}: Found item: {item.Type} - {item.Serial}", CustomItems.Instance.Config.IsDebugEnabled);
                    if (item.Type != ItemType.GrenadeHE && item.Type != ItemType.GrenadeFlash && item.Type != ItemType.SCP018)
                    {
                        continue;
                    }
                    if (TryGet(item, out CustomItem cItem))
                    {
                        if (IgnoreModdedGrenades)
                        {
                            continue;
                        }

                        if (cItem is CustomGrenade customGrenade)
                        {
                            loadedCustomGrenade = customGrenade;
                        }
                    }

                    ev.Player.DisableEffect(EffectType.Invisible);
                    ev.Player.Connection.Send(new RequestMessage(ev.Firearm.Serial, RequestType.Reload));

                    Timing.CallDelayed(3f, () => firearm.Ammo = ClipSize);

                    loadedGrenade = item.Type == ItemType.GrenadeFlash ? GrenadeType.Flashbang :
                                    item.Type == ItemType.GrenadeHE ? GrenadeType.FragGrenade : GrenadeType.Scp018;
                    Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} successfully reloaded. Grenade type: {loadedGrenade} IsCustom: {loadedCustomGrenade != null}", CustomItems.Instance.Config.IsDebugEnabled);
                    ev.Player.RemoveItem(item);

                    return;
                }

                Log.Debug($"{Name}.{nameof(OnReloading)}: {ev.Player.Nickname} was unable to reload - No grenades in inventory.", CustomItems.Instance.Config.IsDebugEnabled);
            }
        }
コード例 #15
0
 public int Grenade(GrenadeType type)
 {
     if (type == GrenadeType.Frag)
     {
         return(fragGrenade);
     }
     else if (type == GrenadeType.Smoke)
     {
         return(smokeGrenade);
     }
     else
     {
         return(0);
     }
 }
コード例 #16
0
        /// <summary>
        /// Converts a <see cref="GrenadeType"/> into the corresponding <see cref="ItemType"/>.
        /// </summary>
        /// <param name="type"><inheritdoc cref="GrenadeType"/></param>
        /// <returns><inheritdoc cref="ItemType"/></returns>
        public static ItemType GetItemType(this GrenadeType type)
        {
            switch (type)
            {
            case GrenadeType.Flashbang:
                return(ItemType.GrenadeFlash);

            case GrenadeType.Scp018:
                return(ItemType.SCP018);

            case GrenadeType.FragGrenade:
                return(ItemType.GrenadeHE);

            default:
                return(ItemType.None);
            }
        }
コード例 #17
0
        // Returns GlobalIndex
        private int FindGrenade(GrenadeType type)
        {
            for (int i = 0; i < _itemInventory.Length; i++)
            {
                if (_itemInventory[i] is Grenade)
                {
                    Grenade grenade = _itemInventory[i] as Grenade;

                    if (grenade.Type == type)
                    {
                        return(i + 20);
                    }
                }
            }

            return(-1);
        }
コード例 #18
0
ファイル: EventHandlers.cs プロジェクト: Parkeymon/LuckyPills
        private static void SpawnGrenadeOnPlayer(Player ply,
                                                 GrenadeType grenadeType,
                                                 float timer,
                                                 float velocity = 1f)
        {
            var             plyGrenadeManager = ply.GrenadeManager;
            GrenadeSettings grenadeSettings;

            switch (grenadeType)
            {
            case GrenadeType.FragGrenade:
                grenadeSettings = plyGrenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFrag);
                break;

            case GrenadeType.Flashbang:
                grenadeSettings = plyGrenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFlash);
                break;

            case GrenadeType.Scp018:
                grenadeSettings = plyGrenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.SCP018);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(grenadeType), grenadeType, null);
            }
            Grenade grenade;

            if (grenadeType != GrenadeType.Scp018)
            {
                grenade = UnityEngine.Object.Instantiate(grenadeSettings?.grenadeInstance).GetComponent <Grenade>();
                grenade.fuseDuration = timer;
                grenade.InitData(plyGrenadeManager, Vector3.zero, plyGrenadeManager.hub.PlayerCameraReference.forward, velocity);
            }
            else
            {
                var relativeVelocity = new Vector3(UnityEngine.Random.Range(0.0f, 2f), UnityEngine.Random.Range(0.0f, 2f), UnityEngine.Random.Range(0.0f, 2f));
                grenade = UnityEngine.Object.Instantiate(grenadeSettings?.grenadeInstance).GetComponent <Scp018Grenade>();
                grenade.fuseDuration = timer;
                grenade.InitData(plyGrenadeManager, relativeVelocity, ply.ReferenceHub.PlayerCameraReference.forward, velocity);
            }
            NetworkServer.Spawn(grenade.gameObject);
        }
コード例 #19
0
    private void ThrowGrenade()
    {
        GrenadeType type = grenade[grenadeType].transform.GetComponent <Grenade>().Type;

        GameObject currentGrenade = Instantiate(grenade[grenadeType], transform.position, transform.rotation);
        Rigidbody  rb             = currentGrenade.GetComponent <Rigidbody>();

        rb.AddForce(fpsCam.transform.up * (throwForce / 3), ForceMode.VelocityChange);
        rb.AddForce(fpsCam.transform.forward * throwForce, ForceMode.VelocityChange);

        /*if (weaponManager.Ammo.Grenade(type) > 0)
         * {
         *  GameObject currentGrenade = Instantiate(grenade[grenadeType], transform.position, transform.rotation);
         *  Rigidbody rb = currentGrenade.GetComponent<Rigidbody>();
         *  rb.AddForce(transform.up * (throwForce / 3), ForceMode.VelocityChange);
         *  rb.AddForce(transform.forward * throwForce, ForceMode.VelocityChange);
         *  weaponManager.Ammo.UpdateGrenade(type, -1);
         *  weaponManager.GetPlayerUI().Weapon.SetGrenadeAmount(type, weaponManager.Ammo.Grenade(type));
         * }*/
    }
コード例 #20
0
 public void switchGrenade()
 {
     if (!gSpawned)
     {
         if (Input.GetKeyDown(KeyCode.F))
         {
             if (grenadeType == GrenadeType.exp)
             {
                 grenadeType = GrenadeType.rev;
             }
             else if (grenadeType == GrenadeType.rev)
             {
                 grenadeType = GrenadeType.slow;
             }
             else if (grenadeType == GrenadeType.slow)
             {
                 grenadeType = GrenadeType.exp;
             }
         }
     }
 }
コード例 #21
0
 public PlayerGrenadeHitPlayer(Player thrower, Player victim, GrenadeType type) : base(thrower)
 {
     GrenadeType = type;
     Victim      = victim;
 }
コード例 #22
0
 public PlayerGrenadeExplosion(Player thrower, GrenadeType grenadetype, Vector position, bool allow = true) : base(thrower)
 {
     this.Allow       = allow;
     this.GrenadeType = grenadetype;
     this.Position    = position;
 }
コード例 #23
0
ファイル: BattleItem.cs プロジェクト: jmfb/XComGenerations
		private static BattleItemMetadata MetadataOf(GrenadeType grenadeType) => grenadeType.Metadata();
コード例 #24
0
ファイル: TopicView.cs プロジェクト: jmfb/XComGenerations
		private void AddTopicControls(GrenadeType grenade)
		{
			var metadata = grenade.Metadata();
			AddControl(new Item(4 + 8 * (3 - metadata.Height), 158 + 8 * (2 - metadata.Width), metadata.Image));
			AddControl(new WrappedLabel(24, 5, 150, metadata.Name, Font.Large, ColorScheme.White));

			AddControl(new Label(24, Label.CenterOf(195, 90), metadata.DamageType.Metadata().Name, Font.Normal, ColorScheme.White));
			AddControl(new Label(40, Label.CenterOf(195, 90), metadata.Damage.FormatNumber(), Font.Large, ColorScheme.Red));

			var nextTop = 67;
			foreach (var descriptionLine in metadata.DescriptionLines)
			{
				var top = nextTop;
				nextTop += 8;
				AddControl(new Label(top, 8, descriptionLine, Font.Normal, ColorScheme.White));
			}
		}
コード例 #25
0
        public Grenades.Grenade SpawnGrenade(Vector3 position, Vector3 velocity, float fusetime = 3f, GrenadeType grenadeType = GrenadeType.FragGrenade, Player player = null)
        {
            if (player == null)
            {
                player = Server.Host;
            }

            GrenadeManager component  = player.GrenadeManager;
            Grenade        component2 = GameObject.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent <Grenades.Grenade>();

            component2.FullInitData(component, position, Quaternion.Euler(component2.throwStartAngle), velocity, component2.throwAngularVelocity, player == Server.Host ? Team.RIP : player.Team);
            component2.NetworkfuseTime = NetworkTime.time + (double)fusetime;
            NetworkServer.Spawn(component2.gameObject);

            return(component2);
        }
コード例 #26
0
 public void Initialize(GrenadeType grenadeType)
 {
     this.grenadeType = grenadeType;
 }
コード例 #27
0
ファイル: Client.cs プロジェクト: YeeB3Warned/OSFPS
 public void ClientOnDetonateGrenade(uint id, float3 position, GrenadeType type)
 {
     GrenadeSystem.Instance.ShowGrenadeExplosion(position, type);
 }
コード例 #28
0
 public SquadsBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadString32();
     this.flags = (Flags)binaryReader.ReadInt32();
     this.team = (Team)binaryReader.ReadInt16();
     this.parent = binaryReader.ReadShortBlockIndex1();
     this.squadDelayTimeSeconds = binaryReader.ReadSingle();
     this.normalDiffCountInitialNumberOfActorsOnNormalDifficulty = binaryReader.ReadInt16();
     this.insaneDiffCountInitialNumberOfActorsOnInsaneDifficultyHardDifficultyIsMidwayBetweenNormalAndInsane = binaryReader.ReadInt16();
     this.majorUpgrade = (MajorUpgrade)binaryReader.ReadInt16();
     this.padding = binaryReader.ReadBytes(2);
     this.vehicleType = binaryReader.ReadShortBlockIndex1();
     this.characterType = binaryReader.ReadShortBlockIndex1();
     this.initialZone = binaryReader.ReadShortBlockIndex1();
     this.padding0 = binaryReader.ReadBytes(2);
     this.initialWeapon = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon = binaryReader.ReadShortBlockIndex1();
     this.grenadeType = (GrenadeType)binaryReader.ReadInt16();
     this.initialOrder = binaryReader.ReadShortBlockIndex1();
     this.vehicleVariant = binaryReader.ReadStringID();
     {
         var count = binaryReader.ReadInt32();
         var address = binaryReader.ReadInt32();
         var elementSize = Marshal.SizeOf(typeof(ActorStartingLocationsBlock));
         this.startingLocations = new ActorStartingLocationsBlock[count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < count; ++i)
             {
                 binaryReader.BaseStream.Position = address + i * elementSize;
                 this.startingLocations[i] = new ActorStartingLocationsBlock(binaryReader);
             }
         }
     }
     this.placementScript = binaryReader.ReadString32();
     this.skip1 = binaryReader.ReadBytes(2);
     this.padding2 = binaryReader.ReadBytes(2);
 }
コード例 #29
0
 public ActorStartingLocationsBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadStringID();
     this.position = binaryReader.ReadVector3();
     this.referenceFrame = binaryReader.ReadInt16();
     this.padding = binaryReader.ReadBytes(2);
     this.facingYawPitchDegrees = binaryReader.ReadVector2();
     this.flags = (Flags)binaryReader.ReadInt32();
     this.characterType = binaryReader.ReadShortBlockIndex1();
     this.initialWeapon = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon = binaryReader.ReadShortBlockIndex1();
     this.padding0 = binaryReader.ReadBytes(2);
     this.vehicleType = binaryReader.ReadShortBlockIndex1();
     this.seatType = (SeatType)binaryReader.ReadInt16();
     this.grenadeType = (GrenadeType)binaryReader.ReadInt16();
     this.swarmCountNumberOfCreturesInSwarmIfASwarmIsSpawnedAtThisLocation = binaryReader.ReadInt16();
     this.actorVariantName = binaryReader.ReadStringID();
     this.vehicleVariantName = binaryReader.ReadStringID();
     this.initialMovementDistanceBeforeDoingAnythingElseTheActorWillTravelTheGivenDistanceInItsForwardDirection = binaryReader.ReadSingle();
     this.emitterVehicle = binaryReader.ReadShortBlockIndex1();
     this.initialMovementMode = (InitialMovementMode)binaryReader.ReadInt16();
     this.placementScript = binaryReader.ReadString32();
     this.skip1 = binaryReader.ReadBytes(2);
     this.padding2 = binaryReader.ReadBytes(2);
 }
コード例 #30
0
 /// <summary>
 /// Returns an <see cref="IEnumerable{GrenadesNode}"/> with all grenades of the given type.
 /// </summary>
 /// <param name="type">The type of grenades that should be returned.</param>
 /// <returns>An <see cref="IEnumerable{GrenadeNode}"/> with all grenades of the given type.</returns>
 public IEnumerable <GrenadeNode> GetAllOfType(GrenadeType type)
 {
     return(Grenades.Where(grenade => grenade.Type == type));
 }
コード例 #31
0
ファイル: GrenadeSystem.cs プロジェクト: YeeB3Warned/OSFPS
 public GrenadeDefinition GetGrenadeDefinitionByType(GrenadeType type)
 {
     return(OsFps.Instance.GrenadeDefinitionComponents
            .FirstOrDefault(gdc => gdc.Definition.Type == type)
            ?.Definition);
 }
コード例 #32
0
 public Grenade(IItem item, GrenadeType type) : this(item) {
     this.type      = type;
     this.Countdown = type.fuseTime;
 }
コード例 #33
0
    public void Initialize(TypeCollection collection, XElement e)
    {
        name = e.ExpectAtt("name");
        desc = e.ExpectAtt("desc");
        mass = e.TryAttDouble("mass", 0);
        var imageSource = e.TryAtt("image");

        if (imageSource.Length > 0)
        {
            image = ColorImage.FromFile(imageSource);
        }

        switch (e.Attribute("known")?.Value)
        {
        case "true":
            knownChance = 100;
            break;

        case "common":
            knownChance = 80;
            break;

        case "uncommon":
            knownChance = 60;
            break;

        case "rare":
            knownChance = 40;
            break;

        case "exotic":
            knownChance = 20;
            break;

        case "false":
            knownChance = 0;
            break;
        }
        string unknownType = e.TryAtt("unknownType");

        if (!string.IsNullOrWhiteSpace(unknownType))
        {
            if (collection.Lookup(unknownType, out DesignType d) && d is ItemType it)
            {
                this.unknownType = it;
            }
            else
            {
                throw new Exception($"Unknown DesignType: {unknownType}");
            }
        }
        if (e.HasElement(HeadDesc.Tag, out XElement xmlHead))
        {
            this.head = new HeadDesc(xmlHead);
        }
        if (e.HasElement(GrenadeType.Tag, out XElement xmlGrenade))
        {
            this.grenade = new GrenadeType(collection, xmlGrenade);
        }
        if (e.HasElement(GunDesc.Tag, out XElement xmlGun))
        {
            this.gun = new GunDesc(collection, xmlGun);
        }
        if (e.HasElement(AmmoDesc.Tag, out XElement xmlAmmo))
        {
            this.ammo = new AmmoDesc(xmlAmmo);
        }


        //Initialize our nested types now (they are not accessible to anyone else at bind time)
        foreach (var inner in e.Elements("ItemType"))
        {
            collection.ProcessElement(inner);
        }
    }
コード例 #34
0
ファイル: TopicType.cs プロジェクト: jmfb/XComGenerations
 private static TopicMetadata Grenade(GrenadeType grenade, params ResearchType[] requiredResearch)
 {
     return new TopicMetadata
     {
         Name = grenade.Metadata().Name,
         Category = TopicCategory.WeaponsAndEquipment,
         Background = Backgrounds.InfoItem,
         BackgroundPalette = 4,
         Scheme = ColorScheme.Yellow,
         RequiredResearch = requiredResearch,
         Subject = grenade
     };
 }
コード例 #35
0
        public override void Update(GameTime gameTime)
        {
            PreviousPose          = CurrentPose;
            PreviousFacing        = CurrentFacing;
            PreviousGamePadState  = CurrentGamePadState;
            PreviousKeyboardState = CurrentKeyboardState;
            PreviousMouseState    = CurrentMouseState;
            WasShooting           = IsShooting;

            if (Active == true)
            {
                HealthBar.Update(Health);
                SpecialBar.Update(new Vector2(87, 100));

                foreach (Emitter emitter in FlashEmitterList)
                {
                    emitter.Position.X = BarrelEnd.X;
                    emitter.Update(gameTime);
                }
                FlashEmitterList.RemoveAll(Emitter => Emitter.Active == false);

                foreach (Emitter emitter in EmitterList)
                {
                    //emitter.Position = Position;
                    emitter.Update(gameTime);
                }
                EmitterList.RemoveAll(Emitter => Emitter.Active == false);

                #region Control States
                CurrentGamePadState  = GamePad.GetState(PlayerIndex);
                CurrentKeyboardState = Keyboard.GetState();
                CurrentMouseState    = Mouse.GetState();

                Sticks    = CurrentGamePadState.ThumbSticks;
                MoveStick = Sticks.Left;
                AimStick  = Sticks.Right;
                #endregion

                #region Jump
                if (CurrentGamePadState.IsButtonDown(CurrentJumpButton) &&
                    PreviousGamePadState.IsButtonUp(CurrentJumpButton) &&
                    DoubleJumped == false)
                {
                    NumJumps++;

                    if (InAir == true)
                    {
                        DoubleJumped = true;
                        Velocity.Y  -= 15f;
                    }
                    else
                    {
                        //NOT SURE ABOUT HAVING BOTH THIS AND THE SMOKE PUFF WHEN LANDING.
                        //I LIKE THE SMOKE MORE SO I'M LEAVING THIS OUT FOR NOW

                        //Emitter jumpEmitter1 = new Emitter(Game1.HitEffectParticle, new Vector2(Position.X + 5, Position.Y + DestinationRectangle.Height / 2),
                        //     new Vector2(90, 180), new Vector2(5, 8), new Vector2(500, 500), 1f, false, new Vector2(0, 0),
                        //     new Vector2(0, 0), new Vector2(0.1f, 0.1f), Color.White, Color.White, 0f, 0.1f, 100, 5, false,
                        //     Vector2.Zero, true, null, null, null, null, null, null, true, new Vector2(0.15f, 0.15f), null, null, null, null, null, true);


                        //Emitter jumpEmitter2 = new Emitter(Game1.HitEffectParticle, new Vector2(Position.X + 5, Position.Y + DestinationRectangle.Height / 2),
                        //    new Vector2(0, 90), new Vector2(5, 8), new Vector2(500, 500), 1f, false, new Vector2(0, 0),
                        //    new Vector2(0, 0), new Vector2(0.1f, 0.1f), Color.White, Color.White, 0f, 0.1f, 100, 5, false,
                        //    Vector2.Zero, true, null, null, null, null, null, null, true, new Vector2(0.15f, 0.15f), null, null, null, null, null, true);

                        //EmitterList.Add(jumpEmitter1);
                        //EmitterList.Add(jumpEmitter2);

                        Velocity.Y = -15f;
                    }
                }
                #endregion

                if (CurrentGamePadState.IsButtonDown(Buttons.LeftStick) &&
                    PreviousGamePadState.IsButtonUp(Buttons.LeftStick))
                {
                    Health.X = 0;
                }

                #region Move stick left
                if (MoveStick.X < -0.15f)
                {
                    AimDirection.X = -1f;
                    CurrentFacing  = Facing.Left;
                }
                #endregion

                #region Move stick right
                if (MoveStick.X > 0.15f)
                {
                    AimDirection.X = 1f;
                    CurrentFacing  = Facing.Right;
                }
                #endregion

                if (Math.Abs(MoveStick.X) > 0.15f)
                {
                    Velocity.X += (MoveStick.X * 3f);
                }

                if (CurrentPose == Pose.Standing)
                {
                    Size = new Vector2(59, 98);
                }
                else
                {
                    Size = new Vector2(59, 74);
                }

                Velocity.Y += Gravity * ((float)gameTime.ElapsedGameTime.TotalSeconds * 60f);

                base.Update(gameTime);

                #region Collision Reactions
                if (PushesBottomTile == true)
                {
                    if (InAir == true)
                    {
                        Emitter jumpEmitter1 = new Emitter(Game1.ToonSmoke1, new Vector2(Position.X - 2, Position.Y + DestinationRectangle.Height / 2),
                                                           new Vector2(110, 180), new Vector2(2, 5), new Vector2(300, 500), 1f, false, new Vector2(-7, 7),
                                                           new Vector2(0, 0), new Vector2(0.03f, 0.05f), Color.White, Color.White, 0f, 0.1f, 100, 9, false,
                                                           Vector2.Zero, true, null, null, null, null, null, null, false, new Vector2(0.08f, 0.08f), null, null, null, false, false, true);

                        Emitter jumpEmitter2 = new Emitter(Game1.ToonSmoke1, new Vector2(Position.X + 2, Position.Y + DestinationRectangle.Height / 2),
                                                           new Vector2(20, 90), new Vector2(2, 5), new Vector2(300, 500), 1f, false, new Vector2(-7, 7),
                                                           new Vector2(0, 0), new Vector2(0.03f, 0.05f), Color.White, Color.White, 0f, 0.1f, 100, 9, false,
                                                           Vector2.Zero, true, null, null, null, null, null, null, false, new Vector2(0.08f, 0.08f), null, null, null, false, false, true);


                        EmitterList.Add(jumpEmitter1);
                        EmitterList.Add(jumpEmitter2);
                    }

                    Velocity.Y   = 0;
                    InAir        = false;
                    DoubleJumped = false;
                }
                else
                {
                    InAir = true;
                }

                if (PushesTopTile == true)
                {
                    Velocity.Y = 0;
                }

                if (PushesLeftTile == true ||
                    PushesRightTile == true)
                {
                    Velocity.X = 0;
                }
                #endregion

                #region Stop Moving
                if (MoveStick.X == 0)
                {
                    if (InAir == false)
                    {
                        Velocity.X = 0f;
                    }
                    else
                    {
                        Velocity.X *= 0.98f;
                    }
                }
                #endregion

                #region Limit Speed
                if (Velocity.X > MaxSpeed.X)
                {
                    Velocity.X = MaxSpeed.X;
                }

                if (Velocity.X < -MaxSpeed.X)
                {
                    Velocity.X = -MaxSpeed.X;
                }

                //if (Velocity.Y < -25)
                //{
                //    Velocity.Y = -25;
                //}

                //if (Velocity.Y > 25)
                //{
                //    Velocity.Y = 25;
                //}
                #endregion

                Shoot(gameTime);

                #region Grenade
                if (GrenadeTiming.X >= GrenadeTiming.Y)
                {
                    if (CurrentGamePadState.IsButtonDown(CurrentGrenadeButton) &&
                        PreviousGamePadState.IsButtonUp(CurrentGrenadeButton))
                    {
                        CreatePlayerGrenade();
                        GrenadeTiming.X = 0;

                        if (CurrentGrenade != GrenadeType.Regular)
                        {
                            GrenadeAmmo--;

                            if (GrenadeAmmo == 0)
                            {
                                CurrentGrenade = GrenadeType.Regular;
                            }
                        }
                    }
                }
                else
                {
                    GrenadeTiming.X += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                }
                #endregion

                #region Trap
                if (CurrentGamePadState.IsButtonDown(CurrentTrapButton) &&
                    PreviousGamePadState.IsButtonUp(CurrentTrapButton))
                {
                    if (TrapAmmo > 0)
                    {
                        //CreatePlaceTrap(Position, TrapType.Mine);
                        CreatePlaceTrap();
                    }
                }
                #endregion

                #region Change Animation Direction
                switch (CurrentFacing)
                {
                    #region Left
                case Facing.Left:
                {
                    AimDirection = new Vector2(-1, 0);

                    if (InAir == false)
                    {
                        if (Velocity.X != 0)
                        {
                            CurrentAnimation = RunLeftAnimation;
                        }
                        else
                        {
                            if (CurrentPose == Pose.Standing)
                            {
                                CurrentAnimation = StandLeftAnimation;
                            }
                            else
                            {
                                CurrentAnimation = CrouchLeftAnimation;
                            }
                        }
                    }
                    else
                    {
                        if (Velocity.Y > 2)
                        {
                            CurrentAnimation = JumpLeftDownAnimation;
                        }
                        else
                        {
                            CurrentAnimation = JumpLeftAnimation;
                        }
                    }
                }
                break;
                    #endregion

                    #region Right
                case Facing.Right:
                {
                    AimDirection = new Vector2(1, 0);

                    if (InAir == false)
                    {
                        if (Velocity.X != 0)
                        {
                            CurrentAnimation = RunRightAnimation;
                        }
                        else
                        {
                            if (CurrentPose == Pose.Standing)
                            {
                                CurrentAnimation = StandRightAnimation;
                            }
                            else
                            {
                                CurrentAnimation = CrouchRightAnimation;
                            }
                        }
                    }
                    else
                    {
                        if (Velocity.Y > 2)
                        {
                            CurrentAnimation = JumpRightDownAnimation;
                        }
                        else
                        {
                            CurrentAnimation = JumpRightAnimation;
                        }
                    }
                }
                break;
                    #endregion
                }
                #endregion

                DestinationRectangle = new Rectangle((int)(Position.X - CurrentAnimation.FrameSize.X / 2),
                                                     (int)(Position.Y - CurrentAnimation.FrameSize.Y / 2),
                                                     (int)CurrentAnimation.FrameSize.X,
                                                     (int)CurrentAnimation.FrameSize.Y);

                BoundingBox = new BoundingBox(new Vector3(Position - (CurrentAnimation.FrameSize / 2), 0),
                                              new Vector3(Position + (CurrentAnimation.FrameSize / 2), 0));

                #region Update Animations
                if (CurrentAnimation != null)
                {
                    CurrentAnimation.Position = Position;
                    CurrentAnimation.Update(gameTime, DestinationRectangle);
                }
                #endregion

                #region Item Collisions
                if (ItemList != null)
                {
                    ItemList.ForEach(Item =>
                    {
                        bool removeItem = true;

                        if (Item.CollisionRectangle.Intersects(CollisionRectangle))
                        {
                            switch (Item.ItemType)
                            {
                            case ItemType.Shield:
                                {
                                    ShieldActive = true;
                                    removeItem   = true;
                                }
                                break;

                            case ItemType.Shotgun:
                                {
                                    CurrentGun = GunType.Shotgun;
                                    ShotTiming = new Vector2(0, 1000);
                                    removeItem = true;
                                }
                                break;

                            case ItemType.RocketLauncher:
                                {
                                    CurrentGun = GunType.RocketLauncher;
                                    ShotTiming = new Vector2(0, 2000);
                                    removeItem = true;
                                }
                                break;

                            case ItemType.MachineGun:
                                {
                                    ShotTiming = new Vector2(0, 200);
                                    CurrentGun = GunType.MachineGun;
                                    removeItem = true;
                                }
                                break;
                            }

                            if (removeItem == true)
                            {
                                ItemList.Remove(Item);
                            }
                        }
                    });
                }
                #endregion

                #region Trap Collisions
                if (TrapList != null)
                {
                    TrapList.ForEach(Trap =>
                    {
                        if (Trap.Active == true)
                        {
                            switch (Trap.TrapType)
                            {
                            case TrapType.TripMine:
                                {
                                    if ((Trap as TripMine).SourcePlayer != this && (Trap as TripMine).Laser.Ray.Intersects(BoundingBox) != null)
                                    {
                                        //Mine was triggered. Time to explode
                                        Health.X   -= 50;
                                        Trap.Active = false;
                                    }
                                }
                                break;
                            }
                        }

                        //if (Trap.Active == true && Trap.CollisionRectangle.Intersects(CollisionRectangle))
                        //{
                        //    //switch (Trap.TrapType)
                        //    //{
                        //    //#region Fire
                        //    //case TrapType.Fire:
                        //    //        {

                        //    //        }
                        //    //        break;
                        //    //    #endregion
                        //    //}

                        //    Health.X -= 20;
                        //    Trap.Reset();
                        //}
                    });
                }
                #endregion

                #region Projectile Collisions
                if (ProjectileList != null)
                {
                    ProjectileList.ForEach(Projectile =>
                    {
                        if (Projectile.PlayerIndex != PlayerIndex &&
                            Projectile.CollisionRectangle.Intersects(CollisionRectangle))
                        {
                            LastDamageSource = (int)Projectile.PlayerIndex;

                            Projectile.Active = false;

                            if (ShieldActive == true)
                            {
                                ShieldActive = false;
                            }
                            else
                            {
                                Health.X = 0;
                            }
                        }
                    });
                }
                #endregion

                #region Player Died
                if (Health.X <= 0)
                {
                    //#region Flag behaviour
                    //switch (CurrentFlagState)
                    //{
                    //    case FlagState.NoFlag:
                    //        break;

                    //    case FlagState.HasRed:
                    //        {
                    //            RedFlag replacementFlag = new RedFlag() { Position = Position };
                    //            replacementFlag.Initialize();

                    //            ItemList.Add(replacementFlag);
                    //            CurrentFlagState = FlagState.NoFlag;
                    //        }
                    //        break;

                    //    case FlagState.HasBlue:
                    //        {
                    //            BlueFlag replacementFlag = new BlueFlag() { Position = Position };
                    //            replacementFlag.Initialize();

                    //            ItemList.Add(replacementFlag);
                    //            CurrentFlagState = FlagState.NoFlag;
                    //        }
                    //        break;
                    //}
                    //#endregion

                    Deaths++;
                    IsShooting  = false;
                    WasShooting = false;
                    CreatePlayerDied();
                    UnscrambleButtons();
                }
                #endregion

                #region Debuffs
                if (_CurrentDebuff.Active == true)
                {
                    _CurrentDebuff.Update(gameTime);

                    //The debuff has expired based on the previous Update
                    if (_CurrentDebuff.Active == false)
                    {
                        switch (_CurrentDebuff.DebuffType)
                        {
                        case DebuffType.ScrambleButtons:
                        {
                            UnscrambleButtons();
                        }
                        break;
                        }
                    }
                }
                #endregion

                BarrelEnd = Position + new Vector2(AimDirection.X * 28, 10);
            }
        }