Exemplo n.º 1
0
        public override GameObject FireAmmo(IDamager damager, Ray damageRay, LayerMask layerMask, float damageMultiplier)
        {
            Shrapnel spear = Shrapnel.pool.GetPrefabInstance(prefab);

            System.Action <PhysicsHit> onHitReach = (physicsHit) => {
                if (physicsHit != null)
                {
                    Damageable damageable = physicsHit.mainCollider.GetComponent <Damageable>();
                    if (damageable)
                    {
                        damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier, 0));
                    }
                }
            };

            PhysicsHit hit = spear.Launch(velocity, damageRay, maxDistance, radiusCheck, layerMask, lifeTime, hitObjectVelocityMultiplier, simulateArc, onHitReach);

            // if (hit != null) {
            //     Damageable damageable = hit.mainCollider.GetComponent<Damageable>();
            //     if (damageable) {
            //         damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier));
            //     }
            // }

            return(spear.gameObject);
        }
Exemplo n.º 2
0
    // explosive shot spawns shrapnel and deletes the bullet
    private void explosiveShot()
    {
        // spawn two bullets, each with a different set rotation relative to the initial bullet
        for (int i = 0; i < shrapcount; i++)
        {
            // calculate the offset z rotation of the multishot projectiles
            float tempZ = Random.Range(-halfShrapCone, halfShrapCone);

            // create a new bullet that continues on with a 15 Degree positive offset
            GameObject nb1    = Instantiate(shrapnel, transform.position, Quaternion.Euler(0, 0, tempZ));
            Shrapnel   sShrap = nb1.GetComponent <Shrapnel>();

            // set the shrapnels properties
            sShrap.owner    = owner;
            sShrap.mRange   = Random.Range(0, shrapRange);
            sShrap.maxSpeed = Random.Range(0, maxSpeed * 2);
        }

        Destroy(gameObject);
    }
Exemplo n.º 3
0
        public override void Quack(float volume, float pitch)
        {
            if (ModSettings.enableDevEggs)
            {
                Level.Add(new ToBeContinued(x, y));
            }
            if (pitch > 0.95f)
            {
                if (equippedDuck == null)
                {
                    return;
                }
                //immobilize duck
                //equippedDuck.ragdoll = new Ragdoll(equippedDuck.x, equippedDuck.y, equippedDuck, false, 0, 0, new Vec2(0,0));
                equippedDuck.GoRagdoll();

                for (int i = 0; i < 200; i++)
                {
                    Shrapnel magnumShell = new Shrapnel(x + Rando.Float(-4, 4), y);

                    float ang   = Rando.Float(0f, 2f * (float)Math.PI);
                    float speed = Rando.Float(0f, 5f);

                    magnumShell.vSpeed = -speed * (float)Math.Sin(ang);
                    magnumShell.hSpeed = speed * (float)Math.Cos(ang);

                    magnumShell.depth = depth - 1;
                    Level.Add((Thing)magnumShell);
                }
                base.Quack(volume, pitch);
                Level.Remove(this);
            }
            else
            {
                base.Quack(volume, pitch);
            }
        }
Exemplo n.º 4
0
        public void Load(DocumentParser file)
        {
            int possibleSounds = file.ReadInt();

            for (int k = 0; k < possibleSounds; k++)
            {
                Sounds.Add(file.ReadInt());
            }

            int shrapnelCount = file.ReadInt();

            for (int k = 0; k < shrapnelCount; k++)
            {
                SmashDataShrapnel shrapnel = new SmashDataShrapnel
                {
                    ShrapnelType = file.ReadEnum <SmashDataShrapnel.SmashDataShrapnelType>()
                };

                shrapnel.InitialVelocity.TowardsYouSpeed        = file.ReadVector2();
                shrapnel.InitialVelocity.ImpacteeVelocityFactor = file.ReadSingle();
                shrapnel.InitialVelocity.MaxRandomVelocity      = file.ReadSingle();
                shrapnel.InitialVelocity.MaxUpVelocity          = file.ReadSingle();
                shrapnel.InitialVelocity.MaxNormalVelocity      = file.ReadSingle();
                shrapnel.InitialVelocity.MaxRandomSpinRate      = file.ReadSingle();

                if (shrapnel.ShrapnelType != SmashDataShrapnel.SmashDataShrapnelType.shards)
                {
                    shrapnel.InitialPositionType = file.ReadEnum <SmashDataShrapnel.SmashDataInitialPositionType>();

                    if (shrapnel.InitialPositionType == SmashDataShrapnel.SmashDataInitialPositionType.sphereclumped)
                    {
                        shrapnel.ClumpingRadius = file.ReadSingle();
                        shrapnel.ClumpingCentre = file.ReadEnum <SmashDataShrapnel.ClumpCentre>();
                    }
                }

                if (shrapnel.ShrapnelType != SmashDataShrapnel.SmashDataShrapnelType.noncars)
                {
                    shrapnel.Time = file.ReadVector2();
                }

                if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.shards)
                {
                    shrapnel.CutLength    = file.ReadSingle();
                    shrapnel.Flags        = file.ReadInt();
                    shrapnel.MaterialName = file.ReadLine();
                }
                else if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.ghostparts)
                {
                    int[] count = file.ReadInts();
                    shrapnel.MinCount = count[0];
                    shrapnel.MaxCount = count.Length == 2 ? count[1] : count[0];

                    int numActors = file.ReadInt();
                    if (numActors > 0)
                    {
                        for (int l = 0; l < numActors; l++)
                        {
                            shrapnel.GhostPartActors.Add(file.ReadLine());
                        }
                    }
                    else
                    {
                        shrapnel.GhostPartActors.Add(file.ReadLine());
                    }
                }
                else if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.noncars)
                {
                    int[] count = file.ReadInts();
                    shrapnel.MinCount     = count[0];
                    shrapnel.MaxCount     = count[1];
                    shrapnel.ChanceOfFire = file.ReadInt();

                    if (shrapnel.ChanceOfFire > 0)
                    {
                        shrapnel.NumFires   = file.ReadInt();
                        shrapnel.SmokeLevel = file.ReadInts();
                    }

                    shrapnel.Actor = file.ReadLine();
                    int numActors = file.ReadInt();

                    for (int l = 0; l < numActors; l++)
                    {
                        shrapnel.Actors.Add(new SmashDataShrapnelActor
                        {
                            Name     = file.ReadLine(),
                            FileName = file.ReadLine()
                        });
                    }
                }
                else
                {
                    shrapnel.MinCount = file.ReadInt();
                    shrapnel.MaxCount = file.ReadInt();
                    shrapnel.Actor    = file.ReadLine();
                }

                Shrapnel.Add(shrapnel);
            }

            int explosionCount = file.ReadInt();

            for (int k = 0; k < explosionCount; k++)
            {
                Explosions.Add(SmashDataExplosion.Load(file));
            }

            SlickMaterial = file.ReadLine();

            int noncarCuboidCount = file.ReadInt();

            for (int k = 0; k < noncarCuboidCount; k++)
            {
                NoncarCuboids.Add(SmashDataNoncarActivationCuboid.Load(file));
            }

            int smashCuboidCount = file.ReadInt();

            for (int k = 0; k < smashCuboidCount; k++)
            {
                SmashCuboids.Add(SmashDataSmashActivationCuboid.Load(file));
            }

            ExtensionFlags = file.ReadInt();
            RoomTurnOnCode = file.ReadInt();
            AwardCode      = file.ReadEnum <AwardCodeType>();

            if (AwardCode != AwardCodeType.none)
            {
                PointsAwarded = file.ReadInt();
                TimeAwarded   = file.ReadInt();
                HudIndex      = file.ReadInt();
                FancyHUDIndex = file.ReadInt();
            }

            int runtimeVariableChanges = file.ReadInt();

            for (int k = 0; k < runtimeVariableChanges; k++)
            {
                RuntimeVariableChanges.Add(file.ReadLine());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Találatkor hívódik meg.
        /// </summary>
        /// <param name="Score">Elvágó játékos pontszáma</param>
        public void Hit(ref int Score)
        {
            if (GotHit || !Body)
            {
                return;
            }
            GotHit = true; // Ha ez nincs, rengetegszer meghívódna a függvény
            if (name.StartsWith("Menu"))
            {
                Game.SelectedMenuItem = Convert.ToInt32(name.Substring(4)); // A kiválasztott menüelem száma a névben van
            }
            if (Game.Playing)                                               // Csak játék közben módosítson statisztikákat, mert a Game Over menüvel nem tűnnek el -> nem bug, feature
            {
                Dispenser.ObjectDespawned();
                Game.SinceLastCombo = 0;
                Game.ThisCombo++;
                Game.LastHit = transform.position;
                if (Type == Types.Grenade)
                {
                    ((GameObject)Instantiate(Game.Instance.Explosion, transform.position, transform.rotation)).transform.localScale *= Game.Instance.Scale * .1f; // Nagyobb robbanás effekt
                    foreach (Rigidbody EachBody in FindObjectsOfType(typeof(Rigidbody)))                                                                          // Lökjön el mindent magától
                    {
                        if (EachBody != Body)
                        {
                            Destroy(EachBody.gameObject.GetComponent <Target>());
                            EachBody.gameObject.AddComponent <DespawnTime>();
                            Dispenser.ObjectDespawned();
                        }
                        EachBody.AddExplosionForce(Game.Instance.Scale * 50, transform.position, Game.Instance.Scale + Game.Instance.Scale);
                    }
                    Game.LoseLife = true;
                    if (Game.GameMode == GameModes.Multiplayer) // Többjátékos módban pontlevonás is jár a gránátért
                    {
                        Score -= 25;
                    }
                    Game.ThisCombo = 0;
                }
                else
                {
                    Score++;
                }
                // Ha power up vágódott el, aktiválódjon
                if (PowerUp != PowerUps.None)
                {
                    switch (PowerUp)
                    {
                    case PowerUps.DoubleScore: PwrDoubleScore.Activate(); break;

                    case PowerUps.Itemstorm: PwrItemstorm.Activate(); break;

                    case PowerUps.SlowMotion: PwrSlowMotion.Activate(transform.position); break;
                    }
                }
            }
            Vector3 ParentVelocity = Body.velocity;

            foreach (GameObject Shrapnel in Shrapnels)   // Essen szét darabokra
            {
                Shrapnel.transform.parent = null;
                Shrapnel.AddComponent <Despawner>();
                Rigidbody ChildBody = Shrapnel.AddComponent <Rigidbody>();
                ChildBody.AddForce(ParentVelocity);
                ChildBody.AddTorque(new Vector3(Random.value * 100, Random.value * 100, Random.value * 100));
                ChildBody.AddExplosionForce(Game.Instance.Scale * 6, transform.position, 10);
            }
            ((GameObject)Instantiate(Game.Instance.Explosion, transform.position, transform.rotation)).transform.localScale *= Game.Instance.Scale * .02f; // Robbanás effekt
            SingleShotAudio.Play(Game.Instance.SliceSounds[Random.Range(0, Game.Instance.SliceSounds.Length)], transform.position);                        // Vágás hangja
            Destroy(gameObject);
        }