Ejemplo n.º 1
0
        public RGatheredBall(List <RBall> balls, City dockCity, List <City> path)
        {
            state      = State.WaitingGathering;
            subBalls   = balls;
            goPath     = path;
            sourceCity = dockCity;


            position = GetRGBallPosition(dockCity, dockCity.CurrentFacing);

            float lineCount = (float)Math.Sqrt(balls.Count);
            float span      = (MathEx.PIf * 2) / lineCount;

            ballOffsets = new List <Vector3>(balls.Count);
            for (int i = 0; i < balls.Count; i++)
            {
                float row = (float)i / lineCount;
                float col = (float)Math.IEEERemainder(i, lineCount);

                float radLng = col * span;
                float radLat = (2 * row - lineCount) * span;

                Vector3    positionInGBall = PlanetEarth.GetPosition(radLng, radLat, GBallRadius);
                Quaternion oriInGBall      = Quaternion.RotationMatrix(PlanetEarth.GetOrientation(radLng, radLat));
                ballOffsets.Add(positionInGBall);
                balls[i].Gather(this, positionInGBall + position, oriInGBall);
            }

            throwSound = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("throw", null, 1500);
            catchSound = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("catch", null, 1500);
        }
Ejemplo n.º 2
0
        public override void InitalizeGraphics(RenderSystem rs)
        {
            ForestInfo info;

            info.Latitude  = Latitude;
            info.Longitude = Longitude;
            info.Radius    = Radius;

            info.Amount = CurrentAmount;

            //info.Plants = TreeModelLibrary.Instance.Get(0);

            model = TreeBatchModelManager.Instance.CreateInstance(rs, info);

            model.Touch();

            Transformation = model.GetWeakResource().Transformation;
            BoundingSphere = model.GetWeakResource().BoundingVolume;

            sound          = SoundManager.Instance.MakeSoundObjcet("forest", null, BoundingSphere.Radius);
            sound.Position = BoundingSphere.Center;

            {
                float radLng = MathEx.Degree2Radian(Longitude);
                float radLat = MathEx.Degree2Radian(Latitude);

                float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

                stdPosition = PlanetEarth.GetPosition(radLng, radLat, alt * TerrainMeshManager.PostHeightScale + PlanetEarth.PlanetRadius);

                stdTransform = PlanetEarth.GetOrientation(radLng, radLat);
                stdTransform.TranslationValue = stdPosition;


                selectionSphere.Center = stdPosition;
                selectionSphere.Radius = 200;
            }

            FileLocation fl = FileSystem.Instance.Locate("wooden_board_green.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(0, 0, 25) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));
        }
Ejemplo n.º 3
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);

            modelName = sect["Model"];

            scale = sect.GetSingle("Radius", 1);

            rot = sect.GetSingle("Amount", 0);

            float radLng = MathEx.Degree2Radian(Longitude);
            float radLat = MathEx.Degree2Radian(Latitude);

            float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

            Position    = PlanetEarth.GetPosition(radLng, radLat, PlanetEarth.PlanetRadius + alt * TerrainMeshManager.PostHeightScale);
            Orientation = PlanetEarth.GetOrientation(radLng, radLat);
        }
Ejemplo n.º 4
0
        protected override void UpdateLocation()
        {
            float radLong = MathEx.Degree2Radian(this.Longitude);
            float radLat  = MathEx.Degree2Radian(this.Latitude);

            float altitude = TerrainData.Instance.QueryHeight(radLong, radLat);

            IsInOcean = false;
            if (altitude < 0)
            {
                altitude  = 0;
                IsInOcean = true;
            }

            this.Position = PlanetEarth.GetPosition(radLong, radLat, PlanetEarth.PlanetRadius + TerrainMeshManager.PostHeightScale * altitude);

            this.Transformation = PlanetEarth.GetOrientation(radLong, radLat);
            //this.InvTransformation = Matrix.Invert(Transformation);

            this.Transformation.TranslationValue = this.Position; // TranslationValue = pos;

            BoundingSphere.Radius = RulesTable.CityRadius;
            BoundingSphere.Center = this.Position;
        }
Ejemplo n.º 5
0
        public override void InitalizeGraphics(RenderSystem rs)
        {
            float radLng = MathEx.Degree2Radian(Longitude);
            float radLat = MathEx.Degree2Radian(Latitude);

            bool isOcean = false;

            float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

            if (alt < 0)
            {
                alt     = 0;
                isOcean = true;
            }

            frameIdx = Randomizer.GetRandomInt(FrameCount - 1);

            float scale = Game.ObjectScale * 3.7f;// 2.2f;

            if (isOcean)
            {
                model = new Model[FrameCount];
                for (int i = 0; i < FrameCount; i++)
                {
                    FileLocation fl = FileSystem.Instance.Locate("oilderricksea" + i.ToString("D2") + ".mesh", GameFileLocs.Model);

                    model[i] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                    model[i].CurrentAnimation.Clear();
                    model[i].CurrentAnimation.Add(new NoAnimaionPlayer(
                                                      Matrix.Scaling(scale, scale, scale) * Matrix.Translation(0, 18, 0) * Matrix.RotationY(-MathEx.PiOver4)));
                }
            }
            else
            {
                model = new Model[FrameCount];
                for (int i = 0; i < FrameCount; i++)
                {
                    FileLocation fl = FileSystem.Instance.Locate("oilderrick" + i.ToString("D2") + ".mesh", GameFileLocs.Model);

                    model[i] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                    model[i].CurrentAnimation.Clear();
                    model[i].CurrentAnimation.Add(new NoAnimaionPlayer(
                                                      Matrix.Scaling(scale, scale, scale) * Matrix.RotationY(-MathEx.PiOver4)));
                }
            }



            Position = PlanetEarth.GetPosition(radLng, radLat, PlanetEarth.PlanetRadius + alt * TerrainMeshManager.PostHeightScale);
            BoundingSphere.Center = position;

            BoundingSphere.Radius = 200;
            Orientation           = PlanetEarth.GetOrientation(radLng, radLat);

            sound          = SoundManager.Instance.MakeSoundObjcet("oil", null, BoundingSphere.Radius * 8.0f / 3.0f);
            sound.Position = position;


            FileLocation fl2 = FileSystem.Instance.Locate("wooden_board_oil.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl2));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(-50, 25, 23) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));
        }