Beispiel #1
0
        private void RenderSelectedHarvHP(Sprite sprite)
        {
            if (selectedHarv != null)
            {
                float radLng = (selectedHarv.Longitude);
                float radLat = (selectedHarv.Latitude);

                Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat);
                Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat);

                Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat);
                cityNormal.Normalize();

                Vector3 hpPos = selectedHarv.Position + tangy * 100;

                Viewport vp        = renderSys.Viewport;
                Vector3  screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix,
                                                scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);


                float scale = 1.0f * Vector3.Distance(lp, rp);

                Matrix trans = Matrix.Translation(-harvHPBarBackground.Width / 2, -harvHPBarBackground.Height / 2, 0) *
                               Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);



                int hpTexWidth = (int)(harvHPValue.Width * selectedHarv.HPRate);

                sprite.SetTransform(trans);
                sprite.Draw(harvHPBarBackground, 0, 0, ColorValue.White);
                sprite.Draw(harvHPValue, new Rectangle(0, 0, hpTexWidth, harvHPValue.Height),
                            new Rectangle(0, 0, hpTexWidth, harvHPValue.Height), ColorValue.White);
                sprite.Draw(harvHPBorader, 0, 0, ColorValue.White);
                //f6.DrawString(sprite, SelectedCity.Level.ToString(), 25, -16, ColorValue.White);

                sprite.SetTransform(Matrix.Identity);
            }
        }
Beispiel #2
0
        private void RenderSelectedCityHP(Sprite sprite)
        {
            if (SelectedCity != null)
            {
                float radLng = MathEx.Degree2Radian(SelectedCity.Longitude);
                float radLat = MathEx.Degree2Radian(SelectedCity.Latitude);

                Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat);
                Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat);

                Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat);
                cityNormal.Normalize();

                Vector3 hpPos = SelectedCity.Position + tangy * 150 + cityNormal * 400;

                Viewport vp        = renderSys.Viewport;
                Vector3  screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix,
                                                scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);


                float scale = 1.75f * Vector3.Distance(lp, rp) / 2;

                Matrix trans = Matrix.Translation(-onCityHPBackground.Width / 2, -onCityHPBackground.Height / 2, 0) *
                               Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);



                int hpTexWidth = (int)(onCityHPTex.Width * SelectedCity.HPRate);

                sprite.SetTransform(trans);
                sprite.Draw(onCityHPBase, 0, 0, ColorValue.White);
                sprite.Draw(onCityHPTex, new Rectangle(0, 0, hpTexWidth, onCityHPTex.Height),
                            new Rectangle(0, 0, hpTexWidth, onCityHPTex.Height), ColorValue.White);
                sprite.Draw(onCityHPBackground, 0, 0, ColorValue.White);
                f6.DrawString(sprite, SelectedCity.Level.ToString(), 25, -16, ColorValue.White);

                sprite.SetTransform(Matrix.Identity);
            }
        }
Beispiel #3
0
        private void RenderSendBall(Sprite sprite)
        {
            if (targetCity != null)
            {
                float radLng = MathEx.Degree2Radian(targetCity.Longitude);
                float radLat = MathEx.Degree2Radian(targetCity.Latitude);

                float lngSign = Math.Sign(radLng);

                Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat);
                Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat);


                Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat);
                cityNormal.Normalize();

                Vector3 hpPos = targetCity.Position + cityNormal * 100 + tangx * (lngSign * City.CityRadius * 0.55f);

                Viewport vp        = renderSys.Viewport;
                Vector3  screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix,
                                                scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);

                Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix,
                                        scene.Camera.ViewMatrix, Matrix.Identity);


                float scale0 = MathEx.Saturate(1.5f * Vector3.Distance(lp, rp));
                float scale  = (animProgress * animProgress) * scale0;

                Matrix trans = Matrix.Translation(0, -background.Height / 2, 0) *
                               Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);



                sprite.SetTransform(trans);

                if (selectedIndex == -1)
                {
                    sprite.Draw(background, 0, 0, ColorValue.White);
                }
                else
                {
                    sprite.Draw(backgroundSelected[selectedIndex], 0, 0, ColorValue.White);
                }
                UpdateHotarea(ref trans);

                if (state == State.Opened)
                {
                    Matrix trans2 = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) *
                                    Matrix.Scaling(scale0, scale0, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);

                    sprite.SetTransform(trans2);

                    RenderBallIcon(sprite);
                }

                sprite.SetTransform(Matrix.Identity);
            }
        }