示例#1
0
        public void DrawMap(bool deposit, KethaneDeposit depo)
        {
            if (Vessel.mainBody != null && PlanetTextures.ContainsKey(Vessel.mainBody.name))
            {
                Texture2D planetTex = PlanetTextures[Vessel.mainBody.name];

                if (this.Vessel != null)
                {
                    int x = Misc.GetXOnMap(Misc.clampDegrees(Vessel.mainBody.GetLongitude(Vessel.transform.position)), planetTex.width);
                    int y = Misc.GetYOnMap(Vessel.mainBody.GetLatitude(Vessel.transform.position), planetTex.height);
                    if (deposit && depo != null) {
                        float ratio = (depo.Kethane + depo.Kuranium) / (2.0f * KethaneDeposit.MaximumAmount);
                        Color col = Color.white - ratio * (Color.white - XKCDColors.Green);
                        planetTex.SetPixel(x, y, col);
                    }
                    else {
                        Color c = XKCDColors.Black;
                        c.a = 0.1f;
                        planetTex.SetPixel(x, y, c);
                    }
                }

                planetTex.Apply();
            }
        }
示例#2
0
        public KethaneDeposits(CelestialBody CBody)
        {
            Width  = 2.0f * (float)Math.PI * (float)CBody.Radius;
            Height = Width / 2.0f;
            Name   = CBody.name;

            int   DepositCount  = (CBody.name == "Kerbin" ? 15 : 20) + (CBody.name == "Mun" ? 7 : -3);
            int   NumberOfTries = 30;
            float MinRadius     = (CBody.name == "Kerbin" ? 0.25f : 0.45f) * Width * 0.045f;
            float MaxRadius     = Width * 0.045f * (CBody.name == "Minmus" ? 0.8f : 1);

            for (int i = 0; i < DepositCount; i++)
            {
                KethaneDeposit Deposit = new KethaneDeposit();
                float          R       = UnityEngine.Random.Range(MinRadius, MaxRadius);
                for (int j = 0; j < NumberOfTries; j++)
                {
                    Vector3 Pos = new Vector3(UnityEngine.Random.Range(R, Width - R), 0, UnityEngine.Random.Range(R, Height - R));
                    if (IsPositionOK(Pos, R))
                    {
                        Deposit.Generate(Pos, R);
                        Deposits.Add(Deposit);
                        break;
                    }
                }
            }
        }
示例#3
0
        public KethaneDeposits(CelestialBody CBody)
        {
            Width = 2.0f * (float)Math.PI * (float)CBody.Radius;
            Height = Width / 2.0f;
            Name = CBody.name;

            int DepositCount = (CBody.name == "Kerbin" ? 15 : 20) + (CBody.name == "Mun" ? 7 : -3);
            int NumberOfTries = 25;
            float MinRadius = (CBody.name == "Kerbin" ? 0.25f : 0.45f) * Width * 0.045f;
            float MaxRadius = Width * 0.045f * (CBody.name == "Minmus" ? 0.8f : 1);

            for (int i = 0; i < DepositCount; i++)
            {
                KethaneDeposit Deposit = new KethaneDeposit();
                float R = UnityEngine.Random.Range(MinRadius, MaxRadius);
                for (int j = 0; j < NumberOfTries; j++)
                {
                    Vector3 Pos = new Vector3(UnityEngine.Random.Range(R, Width - R), 0, UnityEngine.Random.Range(R, Height - R));
                    if (IsPositionOK(Pos, R))
                    {
                        Deposit.Generate(Pos, R);
                        Deposits.Add(Deposit);
                        break;
                    }
                }
            }
        }