public idPhysics_Player()
			: base()
		{
			_current = new PlayerPhysicsState();
			_saved = _current;

			_command = new idUserCommand();
			_groundTrace = new TraceResult();
			_waterLevel = WaterLevel.None;
		}
Beispiel #2
0
    /// <summary>
    /// Provides initialization.
    /// </summary>
    private void Start()
    {
        if(target == null)
            target = gameObject;

        forces = new List<Vector3[]>(); // For drawing force gizmos

        // Store original rotation and position
        var originalRotation = transform.rotation;
        var originalPosition = transform.position;
        transform.rotation = Quaternion.identity;
        transform.position = Vector3.zero;

        // The object must have a collider
        if (collider == null)
        {
            gameObject.AddComponent<MeshCollider>();
            Debug.LogWarning(string.Format("[Buoyancy.cs] Object \"{0}\" had no collider. MeshCollider has been added.", name));
        }
        isMeshCollider = GetComponent<MeshCollider>() != null;

        var bounds = buoyantCollider.bounds;
        if (bounds.size.x < bounds.size.y)
        {
            voxelHalfHeight = bounds.size.x + 2 * bounds.size.x / slicesPerAxis * (0.5f + 1);

        }
        else
        {
            voxelHalfHeight = bounds.size.y + 2 * bounds.size.y / slicesPerAxis * (0.5f + 1);
        }
        if (bounds.size.z < voxelHalfHeight)
        {
            voxelHalfHeight = bounds.size.z + 2 * bounds.size.z / slicesPerAxis * (0.5f + 1);;
        }
        voxelHalfHeight /= 2 * slicesPerAxis;

        // The object must have a RidigBody
        if (target.rigidbody == null)
        {
            target.AddComponent<Rigidbody>();
            Debug.LogWarning(string.Format("[Buoyancy.cs] Object \"{0}\" had no Rigidbody. Rigidbody has been added.", name));
        }
        target.rigidbody.centerOfMass = new Vector3(0, -bounds.extents.y * 0f, 0) + transform.InverseTransformPoint(bounds.center);

        voxels = SliceIntoVoxels(isMeshCollider && isConcave);

        // Restore original rotation and position
        transform.rotation = originalRotation;
        transform.position = originalPosition;

        float volume = target.rigidbody.mass / density;

        //WeldPoints(voxels, voxelsLimit);

        float archimedesForceMagnitude = WATER_DENSITY * Mathf.Abs(Physics.gravity.y) * volume;
        localArchimedesForce = new Vector3(0, archimedesForceMagnitude, 0) / voxels.Count;

        //Debug.Log(string.Format("[Buoyancy.cs] Name=\"{0}\" volume={1:0.0}, mass={2:0.0}, density={3:0.0}", name, volume, target.rigidbody.mass, density));

        waterLevel = WaterLevel.Instance;
    }
Beispiel #3
0
        public WaterLevel Update(WaterLevel updateWaterLevel)
        {
            WaterLevel waterLevel = _waterLevelRepository.Update(updateWaterLevel);

            return(waterLevel);
        }
Beispiel #4
0
 void Awake()
 {
     HealthPoints = maxHealthPoints;
     tentaculeAnim = gameObject.GetComponent<Animator>() as Animator;
     kraken = gameObject.GetComponentInParent<Kraken>() as Kraken;
     harpoonImpact = GetComponent<AudioSource>();
     Dead = false;
     waterLevel = WaterLevel.Instance;
     material = gameObject.GetComponentInChildren<SkinnedMeshRenderer>().material;
     initialColor = material.color;
     rangeDetector = GetComponent<SphereCollider>() as SphereCollider;
     animationSpeedMod = ((float)Utils.Instance.Rng.NextDouble() - 0.5f)*0.75f + 1f;
     tentaculeAnim.speed = animationSpeedMod;
 }
Beispiel #5
0
 public void Remove(WaterLevel removeWaterLevel)
 {
     _waterLevelRepository.Remove(removeWaterLevel);
 }
Beispiel #6
0
 public WaterLevel Add(WaterLevel addWaterLevel)
 {
     return(_waterLevelRepository.Add(addWaterLevel));
 }
Beispiel #7
0
 public bool IsAcceptableWaterDepth(Vector3 pos)
 {
     return(WaterLevel.GetOverallWaterDepth(pos) <= MaxWaterDepth);
 }
Beispiel #8
0
    public List <WaterLevel> getWaterLevels(String boreholeNo, int intakeNo)
    {
        List <WaterLevel> waterLevels  = null;
        SelectResult      selectResult = null;

        try
        {
            String sql = "SELECT TIMEOFMEAS, WATERLEVEL, REFPOINT FROM WATLEVEL WHERE BOREHOLENO = '" + boreholeNo + "' AND INTAKENO =" + intakeNo;
            Debug.Log("Jupiter Vand Måling SQL: " + sql);
            selectResult = jupiterClient.select(sql);
        }
        catch (System.ServiceModel.CommunicationException e)
        {
            Debug.Log("Too many results");
        }

        if (selectResult != null)
        {
            if (selectResult.DataSetResult != null)
            {
                foreach (DataTable table in selectResult.DataSetResult.Tables)
                {
                    String[] columnNames = new String[table.Columns.Count];
                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        columnNames[i] = table.Columns[i].ColumnName;
                    }
                    waterLevels = new List <WaterLevel>();

                    foreach (System.Data.DataRow row in table.Rows)
                    {
                        object[]   itemArray  = row.ItemArray;
                        WaterLevel waterLevel = new WaterLevel();
                        for (int i = 0; i < itemArray.Length; i++)
                        {
                            switch (columnNames[i])
                            {
                            case "TIMEOFMEAS":
                                waterLevel.MeasurementDate = Convert.ToDateTime(itemArray[i]);
                                break;

                            case "WATERLEVEL":
                                waterLevel.Measurement = Convert.ToSingle(itemArray[i], new CultureInfo("da-DK"));
                                break;

                            case "REFPOINT":
                                //waterLevel.ReferencePoint = this.MediatorDatabase.getReferencePoint(Convert.ToString(itemArray[i]));
                                break;

                            default:
                                Debug.Log("Unidentified Column!");
                                break;
                            }
                        }
                        waterLevels.Add(waterLevel);
                    }
                }
            }
            else
            {
                Debug.Log("SelectResult's DataSetResult is null");
            }

            if (selectResult.Error != null)
            {
                string error = selectResult.Error;
                Debug.Log("Error getting Water Level: " + error);
            }
        }
        else
        {
            Debug.Log("SelectResult is null");
        }
        return(waterLevels);
    }
Beispiel #9
0
        public static void ImpactEffect(HitInfo info)
        {
            if (!info.DoHitEffects)
            {
                return;
            }
            string materialName = StringPool.Get(info.HitMaterial);

            if (Object.op_Inequality((Object)TerrainMeta.WaterMap, (Object)null) && (int)info.HitMaterial != (int)Projectile.WaterMaterialID() && ((int)info.HitMaterial != (int)Projectile.FleshMaterialID() && info.HitPositionWorld.y < (double)WaterLevel.GetWaterDepth(info.HitPositionWorld)))
            {
                return;
            }
            string strName = EffectDictionary.GetParticle(info.damageTypes.GetMajorityDamageType(), materialName);
            string decal   = EffectDictionary.GetDecal(info.damageTypes.GetMajorityDamageType(), materialName);

            if (info.HitEntity.IsValid())
            {
                GameObjectRef impactEffect = info.HitEntity.GetImpactEffect(info);
                if (impactEffect.isValid)
                {
                    strName = impactEffect.resourcePath;
                }
                Effect.server.Run(strName, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false);
                Effect.server.Run(decal, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false);
            }
            else
            {
                Effect.server.Run(strName, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false);
                Effect.server.Run(decal, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false);
            }
            if (Object.op_Implicit((Object)info.WeaponPrefab))
            {
                BaseMelee weaponPrefab = info.WeaponPrefab as BaseMelee;
                if (Object.op_Inequality((Object)weaponPrefab, (Object)null))
                {
                    string strikeEffectPath = weaponPrefab.GetStrikeEffectPath(materialName);
                    if (info.HitEntity.IsValid())
                    {
                        Effect.server.Run(strikeEffectPath, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false);
                    }
                    else
                    {
                        Effect.server.Run(strikeEffectPath, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false);
                    }
                }
            }
            if (info.damageTypes.Has(DamageType.Explosion))
            {
                Effect.server.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/explosion.prefab");
            }
            if (!info.damageTypes.Has(DamageType.Heat))
            {
                return;
            }
            Effect.server.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/fire.prefab");
        }