public void PlayDeathAnimation(ProjectileProperties proj)
    {
        ProjectileType bulletType = proj.type;

        if (bulletType == ProjectileType.Bullet)
        {
            //TODO raycast to see if there is other world collider beneath
            if (transform.position.y > minHeightToFall)
            {
                anim.SetBool("fall_death", true);
            }
            else
            {
                string deathTrigger = GetRandomDeathTrigger();
                anim.SetTrigger(deathTrigger);
            }

            blood.Play("1");
        }
        else if (bulletType == ProjectileType.Grenade)
        {
            anim.SetBool("hit_by_grenade", true);
        }
        else if (bulletType == ProjectileType.Knife)
        {
            anim.SetTrigger("slashed");
        }
    }
    void spawnProjectileDualBullets(BulletTypes type, float facingFloat, float verticalOffset)
    {
        bulletCost++;
        if (bulletCost >= 2)
        {
            bulletCost = 0;
            LoseKinergy(1);
        }
        BoxCollider box = this.GetComponent <BoxCollider> ();
        Vector3     spawnPosition;

        if (facingFloat == 1f)
        {
            spawnPosition = new Vector3(box.bounds.max.x + 0.35f, box.bounds.center.y + verticalOffset, box.bounds.max.z + 0.01f);
        }
        else
        {
            spawnPosition = new Vector3(box.bounds.min.x - 0.35f, box.bounds.center.y + verticalOffset, box.bounds.max.z + 0.01f);
        }
        var                  bullet   = (GameObject)Instantiate(projectileDualBullets, spawnPosition, Quaternion.identity, this.transform);
        SpriteRenderer       sr       = bullet.GetComponent <SpriteRenderer> ();
        ProjectileProperties projProp = bullet.GetComponent <ProjectileProperties> ();

        if (facingFloat != 1f)
        {
            sr.flipX = true;
        }
        projProp.Fire(facingFloat, 3, 1f, type);
    }
Exemple #3
0
    // Append an item to the current projectile
    public void appendItem(Collider other)
    {
        if (player.name == "human1")
        {
            hoardP1 += 1;
        }
        if (player.name == "human2")
        {
            hoardP2 += 1;
        }

        if (currentProjectile == null)
        {
            currentProjectile = buildNewProjectile();
        }

        GameObject           otherObject    = other.gameObject;
        Transform            thisTransform  = currentProjectile.transform;
        ProjectileProperties thisProjectile = currentProjectile.GetComponent <ProjectileProperties>();

        currentProjectile.GetComponent <ProjectileProperties>().appendItem(otherObject);

        float amount = currentProjectile.GetComponent <ProjectileProperties>().getRadius() + GetComponent <BoxCollider>().size.y / 2;

        currentProjectile.transform.localPosition = new Vector3(0f, amount, 0f);
    }
        public ProjectileProperties Build()
        {
            ProjectileProperties result = this.properties;

            properties = new ProjectileProperties();
            return(result);
        }
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (newHP > 0)
     {
         flashRed.FlashSlugStyle();
         audioManager.PlaySound(0);
         EventManager.TriggerEvent(GlobalEvents.PointsEarned, 100);
         return;
     }
     else if (!dead)
     {
         dead           = true;
         gameObject.tag = "World";
         animator.SetTrigger("explode");
         CancelInvoke();
         audioManager.PlaySound(3);
         float  startTime           = Time.time;
         float  duration            = 0.7f;
         Bounds boundsForExplosions = collider.bounds;
         timeUtils.RepeatEvery(0.045f, () => {
             // Visual
             Animator anim           = SimpleAnimatorPool.GetPooledAnimator(explosion);
             anim.transform.position = RandomPosWithin(boundsForExplosions);
             anim.Play("1");
             if (Time.time > startTime + duration)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         });
     }
 }
Exemple #6
0
 public static void PostfixStoppingPower(ProjectileProperties __instance, ref float __result)
 {
     if (__result == 0.5f)
     {
         __result = __instance.GetDamageAmount(null) * StoppingPowerPerDamageAmount;
     }
 }
Exemple #7
0
        private static float GetAccuracy(Thing weapon, VerbProperties verb, ProjectileProperties projectile, float dist, Pawn pawn = null)
        {
            float forcedMissRadius = CalculateAdjustedForcedMissDist(verb.ForcedMissRadius, dist);
            float baseAimOn        = verb.GetHitChanceFactor(weapon, dist);

            if (pawn != null)
            {
                baseAimOn *= ShotReport.HitFactorFromShooter(pawn, dist);
            }
            int affectedCellCount = (verb.CausesExplosion) ? GenRadial.NumCellsInRadius(projectile.explosionRadius) : 1;

            float accuracy;

            if (forcedMissRadius > 0.5f)
            {
                int affectableCellCount = GenRadial.NumCellsInRadius(forcedMissRadius);
                accuracy = (float)affectedCellCount / affectableCellCount;
            }
            else
            {
                float medianToWildRadius = ShootTuning.MissDistanceFromAimOnChanceCurves.Evaluate(baseAimOn, 0.5f);
                float indirectHitChance  = (float)(affectedCellCount - 1) / GenRadial.NumCellsInRadius(medianToWildRadius);
                accuracy = baseAimOn + (1f - baseAimOn) * indirectHitChance;
            }
            return(Mathf.Clamp01(accuracy));
        }
 protected override bool TryCastShot()
 {
     if (base.TryCastShot())
     {
         ThingDef             projectile   = this.GetProjectile();
         ProjectileProperties projectile2  = projectile.projectile;
         ThingDef             equipmentDef = EquipmentSource?.def;
         if (equipmentDef is null)
         {
             Log.Error($"Unable to retrieve weapon def from <color=teal>{GetType()}</color>. Please report to Oskar or Smash Phil.");
             return(true);
         }
         MoteProperties moteProps = equipmentDef.GetModExtension <MoteProperties>();
         if (moteProps is null)
         {
             Log.ErrorOnce($"<color=teal>{GetType()}</color> cannot be used without <color=teal>MoteProperties</color> DefModExtension. Motes will not be thrown.",
                           Gen.HashCombine(projectile.GetHashCode(), "MoteProperties".GetHashCode()));
             return(true);
         }
         float size = moteProps.Size(projectile2.GetDamageAmount(caster, null));
         for (int i = 0; i < moteProps.numTimesThrown; i++)
         {
             float relAngle = Quaternion.LookRotation(CurrentTarget.CenterVector3 - Caster.Position.ToVector3Shifted()).eulerAngles.y;
             SmokeMaker.ThrowMoteDef(moteProps.moteDef, caster.PositionHeld.ToVector3Shifted(), caster.MapHeld, size, moteProps.Velocity, relAngle + moteProps.Angle, moteProps.Rotation);
         }
         return(true);
     }
     return(false);
 }
Exemple #9
0
 private void NotifyDamageWasTaken(ProjectileProperties proj)
 {
     for (int i = 0; i < componInterestedInDamages.Length; i++)
     {
         componInterestedInDamages[i].OnDamageReceived(proj, currentHP);
     }
 }
 protected override bool TryCastShot()
 {
     if (base.TryCastShot())
     {
         Vector3  loc        = this.caster.PositionHeld.ToVector3();
         Map      mapHeld    = this.caster.MapHeld;
         ThingDef projectile = this.GetProjectile();
         int?     num;
         if (projectile == null)
         {
             num = null;
         }
         else
         {
             ProjectileProperties projectile2 = projectile.projectile;
             num = ((projectile2 != null) ? new int?(projectile2.GetDamageAmount(this.caster, null)) : null);
         }
         int?  num2 = num;
         float size = Mathf.Clamp01(((num2 != null) ? new float?((float)num2.GetValueOrDefault() / MEHNI_DECIDED_ON_MAGIC_NUMBER) : null) ?? 1f);
         MoteMaker2.ThrowFlintLockSmoke(loc, mapHeld, size);
         MoteMaker2.ThrowFlintLockSmoke(loc, mapHeld, size);
         return(true);
     }
     return(false);
 }
Exemple #11
0
 public void Fire(float intensity, float liveTime, ProjectileProperties properties)
 {
     projectileProperties = properties;
     intensity            = Mathf.Clamp(intensity, 0f, 1f);
     transform.localScale = initialScale * intensity;
     myParticleSystem.Play();
     Timing.RunCoroutine(WaitForParticleSystem(liveTime), CoroutineName);
 }
Exemple #12
0
    public static Animator GetImpactAnimator(Transform proj, ProjectileProperties projProp)
    {
        Animator anim = SimpleAnimatorPool.GetPooledAnimator();

        anim.transform.right           = Vector2.right;
        anim.runtimeAnimatorController = projProp.explosionAnimator;
        anim.transform.position        = (Vector2)proj.transform.position + UnityEngine.Random.insideUnitCircle * 0.05f;
        return(anim);
    }
Exemple #13
0
    public void SpawnAt(Transform projectileTransform)
    {
        ProjectileProperties properties = new ProjectileProperties
        {
            position = projectileTransform.position, rotation = projectileTransform.rotation
        };

        spawner.SpawnProjectileWithProperties(properties);
    }
Exemple #14
0
    public static void NotifyCollider(Collider2D col, ProjectileProperties projProp)
    {
        HealthManager healthManager = col.GetComponentInChildren <HealthManager>();

        if (healthManager != null)
        {
            healthManager.OnHitByProjectile(projProp);
        }
    }
Exemple #15
0
 public ProjectileProperties(ProjectileProperties other)
 {
     projectileSpeed        = other.projectileSpeed;
     projectileHitDamage    = other.projectileHitDamage;
     homingAngle            = other.homingAngle;
     homingRadius           = other.homingRadius;
     maxChainableEnemies    = other.maxChainableEnemies;
     maxDistance            = other.maxDistance;
     maxDistancePerSubChain = other.maxDistancePerSubChain;
 }
Exemple #16
0
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (newHP < 1)
     {
         Explode();
     }
     else
     {
         flash.FlashSlugStyle();
     }
 }
Exemple #17
0
 void RevertSpeed()
 {
     GameObject[] projectiles = GameObject.FindGameObjectsWithTag("Projectile");
     foreach (GameObject projectile in projectiles)
     {
         ProjectileProperties projProps = projectile.GetComponent <ProjectileProperties>();
         if (projProps != null)
         {
             projProps.movementSpeed = tempSpeed;
         }
     }
 }
    void OnTriggerEnter(Collider other)
    {
        ProjectileProperties projectile = other.gameObject.GetComponent <ProjectileProperties>();

        if (projectile != null)
        {
            if (projectile.inMotion && canParry)
            {
                parry(other);
            }
        }
    }
Exemple #19
0
 public void OnHitByProjectile(ProjectileProperties projectile)
 {
     if (ignoreDamages || currentHP < 1)
     {
         return;
     }
     else
     {
         currentHP -= projectile.strength;
         NotifyDamageWasTaken(projectile);
     }
 }
 public void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Hurtbox")
     {
         if (true)
         {
             if (!general)
             {
                 other.gameObject.GetComponent <DamageReceiver> ().receiveDamage(damage, stunTime, dmgType, this.transform.root.tag, finisher, this.transform);
             }
             else
             {
                 other.gameObject.GetComponent <DamageReceiver> ().receiveDamage(damage, stunTime, dmgType, "General", finisher, this.transform);
             }
             if (this.transform.root.gameObject.tag == "Player")
             {
                 if (this.transform.root.gameObject.GetComponent <PlayerController> ().characterName == "Ronin")
                 {
                     RoninController rC = this.transform.root.gameObject.GetComponent <RoninController> ();
                     rC.successfulHit = true;
                 }
             }
         }
         if (hitCondition && this.gameObject.tag != "Projectile")
         {
             if (am != null)
             {
                 if (this.transform.root.GetComponent <PlayerController> ().characterName == "X-42")
                 {
                     this.transform.root.GetComponent <X42Controller> ().InstantDeath(other.transform.root.gameObject);
                 }
                 am.HitSomething(1);
             }
             else
             {
                 this.transform.root.GetComponent <Animator> ().SetTrigger("hitCondition");
             }
         }
         if (this.gameObject.tag == "Projectile")
         {
             if (other.transform.root.gameObject.tag == "Enemy")
             {
                 ProjectileProperties pp = this.GetComponent <ProjectileProperties> ();
                 pp.Explode(hitCondition);
             }
         }
         if (!continuous)
         {
             StartCoroutine(maintainColliders());
         }
     }
 }
Exemple #21
0
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (newHP > 1)
     {
         flashRed.FlashSlugStyle();
         EventManager.TriggerEvent(GlobalEvents.PointsEarned, 100);
         audioManager.PlaySound(0);
     }
     else
     {
         Die();
     }
 }
Exemple #22
0
    protected override void DoWeaponActions()
    {
        //Get Projectile
        GameObject hookObject = ObjectPool.Instance.GetObject(PoolObjectType.LightningProjectile);

        if (hookObject)
        {
            //Initialize
            LightningProjectile  currentHook   = hookObject.GetComponent <LightningProjectile>();
            ProjectileProperties newProperties = new ProjectileProperties(projectileProperties);
            currentHook.Init(projectileProperties, muzzleTransform);
            currentHook.CheckForTargets();
            animator.SetTrigger("Shoot");
        }
    }
Exemple #23
0
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (!enabled)
     {
         return;
     }
     if (newHP < 1)
     {
         gameObject.SetActive(false);
         bloodSplash.SetActive(true);
         bloodSplash.transform.position = topBody.transform.position;
         limbs.transform.position       = topBody.transform.position;
         limbs.SetActiveRecursively(true);
     }
 }
Exemple #24
0
    public static void ImpactAnimationAndSound(Transform proj, Collider2D col, ProjectileProperties projProp)
    {
        Animator anim = SimpleAnimatorPool.GetPooledAnimator();

        anim.transform.right           = Vector2.right;
        anim.runtimeAnimatorController = projProp.explosionAnimator;
        anim.transform.position        = (Vector2)proj.transform.position + UnityEngine.Random.insideUnitCircle * 0.05f;
        anim.Play("1");

        if (projProp.explosionSound != null)
        {
            AudioSource audio = anim.GetComponent <AudioSource>();
            audio.clip = projProp.explosionSound;
            audio.Play();
        }
    }
Exemple #25
0
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (newHP > 0)
     {
         enemyEvents.OnHit(projectileProp);
         return;
     }
     else
     {
         enemyEvents.OnDead(projectileProp);
         //To ignore collision with projectiles during death anim but still be 'physic'
         gameObject.layer = 2;
         EventManager.TriggerEvent(GlobalEvents.PointsEarned, pointsValue);
         EventManager.TriggerEvent(GlobalEvents.SoldierDead);
     }
 }
Exemple #26
0
        public static float GetDPS(Thing weapon, float dist, Pawn pawn = null)
        {
            VerbProperties       verb       = weapon.def.Verbs[0];
            ProjectileProperties projectile = verb.defaultProjectile.projectile;
            bool singleUse = typeof(Verb_ShootOneUse).IsAssignableFrom(verb.verbClass);

            float damage               = GetDamage(projectile, weapon);
            float cooldown             = GetCooldown(weapon, singleUse);
            float warmup               = GetWarmup(verb, pawn);
            float accuracy             = GetAccuracy(weapon, verb, projectile, dist, pawn);
            int   burstCount           = GetBurstCount(verb);
            float burstShotDelay       = GetBurstShotDelay(verb);
            float projectileTravelTime = GetProjectileTravelTime(projectile, dist);
            float explosionDelay       = GetExplosionDelay(projectile);

            return(GetDPS(damage, cooldown, warmup, accuracy, burstCount, burstShotDelay, projectileTravelTime, explosionDelay));
        }
Exemple #27
0
        public void SpawnProjectileCreatesANewInstanceOfAGivenGameObjectAtAGivenLocation()
        {
            //expectedTransform.position;

            ProjectileProperties properties = new ProjectileProperties();

            properties.position = new Vector3(1.0f, 1.0f, 1.0f);
            properties.rotation = new Quaternion(0.6f, 0.6f, 0.6f, 0.0f);

            spawner.SpawnProjectileWithProperties(properties);

            GameObject actualProjectile = spawner.GetProjectiles().First();

            Assert.AreEqual(properties.position, actualProjectile.transform.position);
            Assert.AreEqual(properties.rotation.x, actualProjectile.transform.rotation.x, 0.1);
            Assert.AreEqual(properties.rotation.y, actualProjectile.transform.rotation.y, 0.1);
            Assert.AreEqual(properties.rotation.z, actualProjectile.transform.rotation.z, 0.1);
            Assert.AreEqual(properties.rotation.w, actualProjectile.transform.rotation.w, 0.1);
        }
Exemple #28
0
    void OnTriggerEnter(Collider other)
    {
        ProjectileProperties projectile = other.gameObject.GetComponent <ProjectileProperties>();

        if (projectile != null)
        {
            if (projectile.inMotion && canParry)
            {
                parry(other);
                if (player.name == "human1")
                {
                    parryp1 += 1;
                }
                if (player.name == "human2")
                {
                    parryp2 += 1;
                }
            }
        }
    }
Exemple #29
0
 public void OnDamageReceived(ProjectileProperties projectileProp, int newHP)
 {
     if (newHP > 0)
     {
         flashRed.FlashSlugStyle();
         return;
     }
     else if (!dead)
     {
         dead = true;
         flashRed.FlashSlugStyle();
         hideEnemy.enabled = false;
         animator.SetTrigger("destroyed");
         explosions.SetActive(true);
         debris.SetActive(true);
         colliderWhenDestroyed.enabled = true;
         gameObject.tag = "World";
         collectible.gameObject.SetActive(true);
         colliderRamp.enabled = false;
         enemySpawner.gameObject.SetActive(false);
     }
 }
Exemple #30
0
        private static void OutputStoppingPowerPatchesOnStartup()
        {
            string startupOutputMessageBase      = "Ranged Stagger Rebalanced has completed dynamic stopping power patching. Scroll down for details...";
            string outputWeaponsPatched          = "Weapons that have been patched:";
            string outputWeaponsNotPatched       = "Weapons that haven't been patched:";
            IEnumerable <ThingDef> rangedWeapons = DefDatabase <ThingDef> .AllDefs.Where(t => t.IsRangedWeapon);

            foreach (ThingDef weapon in rangedWeapons)
            {
                ProjectileProperties projectile = weapon.Verbs?[0]?.defaultProjectile?.projectile;
                string newLine = "\n- " + weapon.defName + " (" + weapon.label + ")";
                if (projectile?.stoppingPower == 0.5f || projectile?.damageDef.defaultStoppingPower == 0.5f)
                {
                    outputWeaponsPatched += newLine;
                }
                else
                {
                    outputWeaponsNotPatched += newLine;
                }
            }
            Log.Message(startupOutputMessageBase + "\n\n" + outputWeaponsPatched + "\n\n" + outputWeaponsNotPatched + "\n");
        }