Ejemplo n.º 1
0
            void IJobParallelForTransform.Execute(int i, TransformAccess t)
            {
                BulletData data = BulletData[i];

                data.PositionOld = data.Position;
                Vector3 delta = Vector3.zero;

                switch (BulletData[i].Type)
                {
                case BulletType.Dummy:
                    if (Time - data.StartTime > 2.0f)
                    {
                        data.ToBeKilled = true;
                        break;
                    }
                    data.Velocity += new Vector3(0, 0, 0) * DeltaTime;
                    delta          = data.Velocity * DeltaTime;
                    data.Position += delta;

                    break;
                }

                Vector3 direction = data.Velocity.normalized;

                t.position = data.Position;
                t.rotation = Quaternion.LookRotation(direction);

                BulletData[i] = data;


                RaycastCommands[i] = new RaycastCommand(data.PositionOld, direction, delta.magnitude, LayerMask);
            }
Ejemplo n.º 2
0
 /// <summary>
 /// 伤害计算
 /// </summary>
 /// <param name="armor">装甲数据</param>
 /// <param name="bullet">子弹数据</param>
 public static HP Damage(ArmorData armor, BulletData bullet)
 {
     if (armor.isShieldBroken)
     {
         return(new HP
                (
                    bullet.physicDamage * (1 - armor.ArmorStrength * (1 - bullet.ArmourPiercingRate)),
                    0
                ));
     }
     else
     {
         return(new HP
                (
                    bullet.physicDamage * bullet.ShieldPenetratingRate * (1 - armor.ArmorStrength * (1 - bullet.ArmourPiercingRate)),
                    bullet.shieldDamage + bullet.physicDamage * (1 - armor.ShieldDefence) * (1 - bullet.ShieldPenetratingRate)
                ));
     }
 }