Ejemplo n.º 1
0
 void UpdatePrimaryScores(int totalAScore, int totalBScore)
 {
     if (gamemode != null)
     {
         if (gamemode.Type == GamemodeType.TDM)
         {
             TDMGamemode tdm = (TDMGamemode)gamemode;
             teamAScoreLabel.Text   = tdm.TeamAScore.ToString();
             teamBScoreLabel.Text   = tdm.TeamBScore.ToString();
             gamemodeInfoLabel.Text = string.Format("Playing until {0} kills", tdm.ScoreCap);
         }
         else if (gamemode.Type == GamemodeType.CTF)
         {
             CTFGamemode ctf = (CTFGamemode)gamemode;
             teamAScoreLabel.Text   = ctf.TeamAScore.ToString();
             teamBScoreLabel.Text   = ctf.TeamBScore.ToString();
             gamemodeInfoLabel.Text = string.Format("Playing until {0} captures", ctf.ScoreCap);
         }
         else
         {
             teamAScoreLabel.Text   = totalAScore.ToString();
             teamBScoreLabel.Text   = totalBScore.ToString();
             gamemodeInfoLabel.Text = "";
         }
     }
     else
     {
         teamAScoreLabel.Text   = totalAScore.ToString();
         teamBScoreLabel.Text   = totalBScore.ToString();
         gamemodeInfoLabel.Text = "";
     }
 }
Ejemplo n.º 2
0
        public void Update(float deltaTime)
        {
            if (Player == null || !ShowCharacterInformation)
            {
                ammoLabel.Visible   = false;
                healthLabel.Visible = false;
                hitmarker.Visible   = false;
                crosshair.Visible   = false;

                if (Player == null)
                {
                    return;
                }
            }
            else
            {
                ammoLabel.Visible   = true;
                healthLabel.Visible = true;
                hitmarker.Visible   = true;
                crosshair.Visible   = true;
            }

            ItemManager itemManager = Player.ItemManager;

            if (itemManager.SelectedItem != null)
            {
                if (itemManager.SelectedItem.Type.HasFlag(ItemType.Weapon))
                {
                    ammoLabel.Visible = ShowCharacterInformation;
                    Weapon wep = (Weapon)itemManager.SelectedItem;

                    if (wep.Type.HasFlag(ItemType.Gun))
                    {
                        Gun gun = (Gun)wep;
                        if (!gun.IsReloading)
                        {
                            int storedAmmo = GlobalNetwork.IsConnected ? gun.ServerStoredAmmo : gun.StoredAmmo;
                            int mag        = GlobalNetwork.IsConnected ? gun.ServerMag : gun.CurrentMag;
                            ammoLabel.Text = string.Format("{0}/{1} | {2}", mag, gun.GunConfig.MagazineSize, storedAmmo);
                        }
                        else
                        {
                            int storedAmmo = GlobalNetwork.IsConnected ? gun.ServerStoredAmmo : gun.StoredAmmo;
                            ammoLabel.Text = string.Format("R/{0} | {1}", gun.GunConfig.MagazineSize, storedAmmo);
                        }
                    }
                    else if (wep.Type.HasFlag(ItemType.Grenade))
                    {
                        ammoLabel.Text = string.Format("Gx{0}", Player.NumGrenades);
                    }
                    else if (wep.Type.HasFlag(ItemType.Spade))
                    {
                        ammoLabel.Text = string.Format("Bx{0}", Player.NumBlocks);
                    }
                    else if (wep.Type.HasFlag(ItemType.MelonLauncher))
                    {
                        ammoLabel.Text = string.Format("Mx{0}", Player.NumMelons);
                    }
                    else
                    {
                        ammoLabel.Text = string.Format("--/-- | x--");
                    }
                }
                else if (itemManager.SelectedItem.Type.HasFlag(ItemType.BlockItem))
                {
                    BlockItem bitem = (BlockItem)itemManager.SelectedItem;

                    string text = string.Format("Bx{0}", Player.NumBlocks);

                    ammoLabel.Text    = text;
                    ammoLabel.Visible = ShowCharacterInformation;
                }
                else
                {
                    ammoLabel.Visible = false;
                }
            }
            else
            {
                ammoLabel.Visible = false;
            }

            healthLabel.Text = string.Format("Health: {0}", (int)Math.Max(Math.Ceiling(Player.Health), 0));

            for (int i = feed.Count - 1; i >= 0; i--)
            {
                FeedItem item = feed[i];
                item.TimeLeft -= deltaTime;

                if (item.TimeLeft < 0)
                {
                    feed.RemoveAt(i);
                    area.RemoveTopLevel(item);

                    for (int k = 0; k < feed.Count; k++)
                    {
                        feed[k].ShiftY(-25);
                    }
                }
            }

            foreach (Vector3 vec in Player.HitFeedbackPositions)
            {
                hitIndications.Add(new HitIndication(vec));
            }
            Player.HitFeedbackPositions.Clear();

            Camera  camera = Camera.Active;
            Matrix4 mat    = camera.ViewMatrix;

            for (int i = hitIndications.Count - 1; i >= 0; i--)
            {
                HitIndication indication = hitIndications[i];

                indication.TimeLeft -= deltaTime;
                if (indication.TimeLeft <= 0)
                {
                    hitIndications.RemoveAt(i);
                }
            }

            if (Player.HitPlayer)
            {
                Player.HitPlayer = false;
                hitmarkerTime    = HITMARKER_LIFETIME;
            }

            hitmarker.Visible = hitmarkerTime > 0;

            if (hitmarkerTime > 0)
            {
                hitmarkerTime -= deltaTime;
            }

            //if (Input.GetControlDown("ToggleGameIcons") && (Player == null || Player.AllowUserInput))
            //    showGameItems = !showGameItems;

            if (gamemode != null)
            {
                CTFGamemode ctf = gamemode as CTFGamemode;
                if (ctf != null)
                {
                    if (Player != null && ctf.OurPlayerHasIntel && !hasIntel)
                    {
                        intelInHand.Image.Color = world.GetTeamColor(Player.Team == Team.A ? Team.B : Team.A);

                        hasIntel = true;
                        intelInHand.Position.Y.Offset             = 100;
                        intelPickedUpNotification.TextColor.A     = 255;
                        intelPickedUpNotification.TextShadowColor = new Color(0, 0, 0, 156);
                        intelInHand.Visible = true;
                        intelPickedUpNotification.Visible = true;

                        intelPickupBeforeFadeTime = INTEL_NOTIFICATION_BEFORE_FADE_DELAY;
                        intelPickupAfterFadeTime  = INTEL_NOTIFICATION_AFTER_FADE_DELAY;
                        showingIntelAnimation     = true;
                    }
                    else if ((Player == null || !ctf.OurPlayerHasIntel) && hasIntel)
                    {
                        hasIntel            = false;
                        intelInHand.Visible = false;
                        intelPickedUpNotification.Visible = false;
                        intelInHand.Position.Y.Offset     = 100;
                    }
                    else if (hasIntel && showingIntelAnimation)
                    {
                        if (intelPickupBeforeFadeTime > 0)
                        {
                            intelPickupBeforeFadeTime -= deltaTime;
                        }
                        else
                        {
                            if (intelPickupAfterFadeTime > 0)
                            {
                                intelPickupAfterFadeTime -= deltaTime;
                                float i = intelPickupAfterFadeTime / INTEL_NOTIFICATION_AFTER_FADE_DELAY;
                                intelPickedUpNotification.TextColor.A     = (byte)(i * 255);
                                intelPickedUpNotification.TextShadowColor = new Color(intelPickedUpNotification.TextShadowColor.Value,
                                                                                      ((byte)MathHelper.Clamp(i * 255 - 128, 0, 255)));
                                intelInHand.Position.Y.Offset = 25 + (75 * i);
                            }
                            else
                            {
                                intelPickedUpNotification.Visible = false;
                                intelInHand.Position.Y.Offset     = 25;
                                showingIntelAnimation             = false;
                            }
                        }
                    }
                }
            }
        }