예제 #1
0
파일: Hud.cs 프로젝트: bethge/GalaticChaos
        /// <summary>
        /// Get the Upgrade a planet has
        /// </summary>
        /// <param name="obj">The Planet Object</param>
        /// <returns>A List of Upgrades a Planet has</returns>
        private Upgrade[] GetActiveUpgrades(GraphicObject obj)
        {
            var planet = (Planet) obj.mGameObject;
             // initialized by just one Upgrade, to reduce redundancy
              var result = new Upgrade[1];

             // Check which Upgrade the Planet has, and save it to the result
              if (planet.MinionBoostUpgrade) result[0] = GetUpgrade(planet, 1);
              else if (planet.SateliteStationUpgrade) result[0] = GetUpgrade(planet, 2);
              else if (planet.PlanetaryShieldUpgrade) result[0] = GetUpgrade(planet, 3);
              else if (planet.StarfleetAcademyUpgrade)
              {
               // on StarfleetAcademyUpgrade, there are three possible upgrades (ships)
            result = new Upgrade[3];
               // Get the ShipUpgrades(5,6,7) and calulate the Circles of Upgrades
            for (var i = 0; i < 3; i++)
            {
              result[i] = GetUpgrade(planet, 5 + i);
              result[i].mCircle =
            GetUpgradeCircle(mRenderer.GetCamera().GetCircleOfObject(obj, 50 + (int) planet.PlanetSize * 18), i, 3);
            }
            return result;
              }
              else
              {
               // if the planet has no Upgrade, it has five possible upgrades
            result = new Upgrade[5];
            // Get the Upgrades(0,1,2,3,4) and calulate the Circles of Upgrades
            for (var i = 0; i < 5; i++)
            {
              result[i] = GetUpgrade(planet, i);
              result[i].mCircle =
            GetUpgradeCircle(mRenderer.GetCamera().GetCircleOfObject(obj, 50 + (int) planet.PlanetSize * 18), i, 5);
            }
            return result;
              }

             // if no return yet, the planet has an upgrade (not StarFleet!)
             // the circle is now in the center of the upgrade
             return result;
        }
예제 #2
0
        /// <summary>
        /// Draws all (not 3D) things for every unit
        /// </summary>
        /// <param name="state">mouse position</param>
        private void DrawUnit(MouseState state)
        {
            var hoverUpgrade = new Upgrade();
              float sizeOfTargetCross = 0;
              mHud.mInformation = "";

              foreach (var obj in GraphicObjectManager.GetInstance().GetList())
              {
               // if unit is visible
            var vis = obj.mGameObject as IVisible;
            if (vis != null)
              if (!vis.GetVisibility().VisibleToPlayer) continue;
               // get allegiance color
            var color = obj.mGameObject.Allegiance == Allegiance.Player
                      ? GlobalValues.GetInstance().mPlayerColor
                      : obj.mGameObject.Allegiance == Allegiance.Computer
                          ? GlobalValues.GetInstance().mComputerColor
                          : GlobalValues.GetInstance().mNeutralColor;
               // get the position and size of the object
            var pos = mRenderer.GetCamera().GetCircleOfObject(obj, 0);

            if (mSelectionManager.GetSelected().Contains(obj))
            {
             //if object is selected draw a selction circle
              DrawSelectionCircle(obj, pos, mCircle, color);

              if (obj.mGameObject is Planet && obj.mGameObject.Allegiance == Allegiance.Player)
              {
               // and if its a planet of the player draw the possible upgrades
            var res = mHud.DrawPlanetUpgradeAroundPlanet(obj, state);
               // and remember the upgrade, where the mouse was over
            if (res.mTexture != null)
              hoverUpgrade = res;
              }

              // Remember the size (radius) of the last selected object, for the size of the target cross
              sizeOfTargetCross = pos.Z;
            }

            //Draw Active Upgrade picture
            if (obj.mGameObject is Planet && obj.mGameObject.Allegiance == Allegiance.Player)
            {
              mHud.DrawPlanetUpgradePictogram(obj);
            }

            DrawLiveBar(obj, pos);
            DrawMinionAmount(obj, pos, color);
              }

              //Draw the Target Point
              var target = mHud.TargetSelection;
             // if a target exists
              if (target != null)
              {
               // the model is null if the target is in the void
            if (target.mModel != null)
            {
              var vec3 = mRenderer.GetCamera().GetCircleOfObject(target, 0);

             // canhe the size of the cross, depending on the kind of the target
              if (target.mGameObject is IMinionContainer) vec3.Z *= 0.3f;
              if (target.mGameObject is ISpaceship) vec3.Z *= 0.8f;
              if (target.mGameObject is DeathStar) vec3.Z *= 0.5f;

              DrawSelectionCircle(null,
                              vec3,
                              mTargetMark,
                              target.mGameObject.Allegiance == Allegiance.Player
                                ? GlobalValues.GetInstance().mPlayerColor
                                : target.mGameObject.Allegiance == Allegiance.Computer
                                    ? GlobalValues.GetInstance().mComputerColor
                                    : GlobalValues.GetInstance().mNeutralColor);
            }
            else
            {
             // get the position from the target and calulate its screen position
              var vec2 = mRenderer.GetCamera().SpaceToScreenPosition(target.mGameObject.Position);
              var vec3 = new Vector3(vec2.X, vec2.Y, sizeOfTargetCross * .8f);
              DrawSelectionCircle(null,
                              vec3,
                              mTargetMark,
                              mUap.AggressiveMove ? Color.Red : GlobalValues.GetInstance().mPlayerColor);
            }
              }

             // Write the information of the hoverd upgrade to the status bar
              if (hoverUpgrade.mTexture == null) return;
              mHud.mInformation = hoverUpgrade.mTyp + " | " + hoverUpgrade.mDescription;
        }
예제 #3
0
파일: Hud.cs 프로젝트: bethge/GalaticChaos
        /// <summary>
        /// Draws Upgradeoptions around the planet,
        /// if the planet allready have a upgrade it draws its identification
        /// </summary>
        /// <param name="obj">Graphic Object of the planet</param>
        /// <param name="state"> Position of the Mouse Cursor </param>
        /// <returns>The Upgrade where the Mouse is over</returns>
        internal Upgrade DrawPlanetUpgradeAroundPlanet(GraphicObject obj, MouseState state)
        {
            var hoverUpgrade = new Upgrade();

              var available = new Color(255, 255, 255);
              var blocked = new Color(70, 70, 70);
             // Get the list of Upgrades the planet has
              var list = GetActiveUpgrades(obj);
              var mousePosition = new Vector2(state.X, state.Y);

             // if the planet has no upgrades, Five Upgrades are available
             // if the panet has the starfleet upgrade, Three upgrades availbale
              if (list.Length > 1)
            foreach (var upgrade in list)
            {
              var upgradePosition = new Vector2(upgrade.mCircle.X, upgrade.mCircle.Y);
              var color = upgrade.mAvailable ? available : blocked;

             // make the hover effect and set the return upgrade
              if (Vector2.Distance(mousePosition, upgradePosition) < (upgrade.mCircle.Z / 2f))
              {
            if (upgrade.mAvailable) color = Color.PaleGreen;
            hoverUpgrade = upgrade;
              }

              // Draw the green circle behind upgrade picto
              mSpriteBatch.Draw(mUpgrade,
                            new Rectangle((int) (upgrade.mCircle.X - upgrade.mCircle.Z / 2f),
                                          (int) (upgrade.mCircle.Y - upgrade.mCircle.Z / 2f),
                                          (int) upgrade.mCircle.Z,
                                          (int) upgrade.mCircle.Z),
                            color);

              // draw upgrade picto
              mSpriteBatch.Draw(upgrade.mTexture,
                            new Rectangle((int) (upgrade.mCircle.X - upgrade.mCircle.Z / 2f),
                                          (int) (upgrade.mCircle.Y - upgrade.mCircle.Z / 2f),
                                          (int) upgrade.mCircle.Z,
                                          (int) upgrade.mCircle.Z),
                            color);
            }
             // return the object where the mouse is over at the moment
              return hoverUpgrade;
        }