Exemplo n.º 1
0
 public static void MouseOnWhichTrash(Cursor cursor, Camera gameCamera, List<Trash> trashes,ref Trash cursorOnTrash,ref Trash botOnTrash, HydroBot hydroBot)
 {
     bool foundBotOnTrash = false, foundCursorOnTrash = false;
     if (hydroBot == null) foundBotOnTrash = true;
     BoundingSphere botTrashBoundingSphere = new BoundingSphere();
     if (!foundBotOnTrash)
         botTrashBoundingSphere = new BoundingSphere(hydroBot.BoundingSphere.Center, 20);
     if (trashes == null) return;
     BoundingSphere trashRealSphere;
     Ray cursorRay = new Ray();
     if (cursor != null)
         cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (Trash trash in trashes)
     {
         trashRealSphere = trash.BoundingSphere;
         trashRealSphere.Center.Y = trash.Position.Y;
         trashRealSphere.Radius *= 5;
         if (!foundBotOnTrash)
         {
             if (trash.BoundingSphere.Intersects(botTrashBoundingSphere))
             {
                 foundBotOnTrash = true;
                 botOnTrash = trash;
             }
         }
         if (!foundCursorOnTrash)
         {
             if (RayIntersectsBoundingSphere(cursorRay, trashRealSphere))
             {
                 foundCursorOnTrash = true;
                 cursorOnTrash = trash;
             }
         }
         if (foundBotOnTrash && foundCursorOnTrash) return;
     }
 }
Exemplo n.º 2
0
        public static Vector3 createSinkingTrash(
            ref List<Trash> trashes, ContentManager Content, Random random, List<ShipWreck> shipWrecks, List<StaticObject> staticObjects, List<Factory> factories, ResearchFacility researchFacility, int minX, int maxX, int minZ, int maxZ, float floatHeight, HeightMapInfo heightMapInfo,ref Model bioTrash,ref Model plasticTrash,ref Model nukeTrash, ParticleManagement particleManager)
        {
            if (PoseidonGame.playTime.TotalSeconds - lastTrashDrop <= 10)
                return Vector3.Zero;
            else lastTrashDrop = PoseidonGame.playTime.TotalSeconds;

            Vector3 tempCenter;
            int numTries = 0, xVal, zVal, heightValue;
            float orientation = random.Next(100);
            int trash_type = random.Next(50);
            Trash sinkingTrash;
            if (trash_type < 30)
            {
                sinkingTrash = new Trash(TrashType.biodegradable, particleManager);
                sinkingTrash.Load(Content,ref bioTrash, orientation);
                sinkingTrash.sinkingRate = 0.25f;
                sinkingTrash.sinkingRotationRate = 0.015f;
            }
            else if (trash_type < 48)
            {
                sinkingTrash = new Trash(TrashType.plastic, particleManager);
                sinkingTrash.Load(Content,ref plasticTrash, orientation); //nuclear model
                sinkingTrash.sinkingRate = 0.35f;
                sinkingTrash.sinkingRotationRate = -0.015f;
            }
            else
            {
                sinkingTrash = new Trash(TrashType.radioactive, particleManager);
                sinkingTrash.Load(Content,ref nukeTrash, orientation); //nuclear model
                sinkingTrash.sinkingRate = 0.6f;
                sinkingTrash.sinkingRotationRate = 0.025f;
            }
            sinkingTrash.sinking = true;
            sinkingTrash.sinkableTrash = true;
            do
            {
                //positionSign = random.Next(4);
                xVal = random.Next(0, 2 * maxX) - maxX;
                zVal = random.Next(0, 2 * maxZ) - maxZ;
                //switch (positionSign)
                //{
                //    case 0:
                //        xVal *= -1;
                //        break;
                //    case 1:
                //        zVal *= -1;
                //        break;
                //    case 2:
                //        xVal *= -1;
                //        zVal *= -1;
                //        break;
                //}
                heightValue = (int)heightMapInfo.GetHeight(new Vector3(xVal, 0, zVal));
                numTries++;
            } while (IsSeaBedPlaceOccupied(xVal, GameConstants.MainGameFloatHeight, zVal, 30, shipWrecks, staticObjects, trashes, factories, researchFacility) && numTries < GameConstants.MaxNumTries);

            sinkingTrash.Position.X = xVal;
            sinkingTrash.Position.Z = zVal;
            sinkingTrash.Position.Y = floatHeight+100;
            sinkingTrash.seaFloorHeight = heightMapInfo.GetHeight(new Vector3(sinkingTrash.Position.X, 0, sinkingTrash.Position.Z));//GameConstants.TrashFloatHeight;
            tempCenter = sinkingTrash.BoundingSphere.Center;
            tempCenter.X = sinkingTrash.Position.X;
            tempCenter.Y = floatHeight;
            tempCenter.Z = sinkingTrash.Position.Z;
            sinkingTrash.BoundingSphere = new BoundingSphere(tempCenter,sinkingTrash.BoundingSphere.Radius);
            trashes.Add(sinkingTrash);

            //degrade environment
            HydroBot.currentEnvPoint -= (int)((float)GameConstants.envLossPerTrashAdd / 2);

            return sinkingTrash.Position;
        }