Ejemplo n.º 1
0
        private void DrawMissionTab(Rect rect, Mission mission, StoryControlDef SCD, int num)
        {
            mission.Notify_Seen();
            rect = rect.ContractedBy(1f);
            if (Mouse.IsOver(rect) || SelectedMission == mission)
            {
                Widgets.DrawHighlight(rect);
            }
            float     offset = (rect.height - 24f) * 0.5f;
            WidgetRow tab    = new WidgetRow(rect.x + offset, rect.y + offset);
            MOState   state  = mission.LatestState;

            if (mission.def.repeatable)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.repeatableIconPath, false));
            }
            else if (state == MOState.Active)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.activeIconPath, false));
            }
            else if (state == MOState.Finished)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.finishedIconPath, false));
            }
            else if (state == MOState.Failed)
            {
                tab.Icon(ContentFinder <Texture2D> .Get(SCD.failedIconPath, false));
            }
            tab.Gap(5f);
            string  label       = mission.def.LabelCap;
            Vector2 labelSize   = Text.CalcSize(label);
            float   width       = rect.width - tab.FinalX;
            float   labelHeight = Text.CalcHeight(label, width);

            offset = (rect.height - labelHeight) * 0.5f;
            Rect labelRect = new Rect(tab.FinalX, rect.y + offset, width, rect.height);

            Widgets.Label(labelRect, label);

            if (Widgets.ButtonInvisible(rect, true))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                selectedLockedMission = null;
                this.SelectedMission  = mission;
                SetActiveObjective();
            }

            /*
             * bool mouseOver = Mouse.IsOver(rect);
             * if (mouseOver || this.SelectedMission == mission)
             * {
             *  Color color = SCD.borderColor.ToColor;
             *  Color half = color;
             *  half.a = 0.5f;
             *  GUI.color = mouseOver ? half : color;
             *  Widgets.DrawBox(rect, 1);
             *  GUI.color = Color.white;
             * }
             */
        }
Ejemplo n.º 2
0
 public virtual void ObjectiveTick()
 {
     if (LatestState == MOState.Active)
     {
         Notify_Start();
         if (timer > 0)
         {
             timer -= 1;
         }
         if (Find.TickManager.TicksGame % GenTicks.TickRareInterval == 0)
         {
             if (def.type == ObjectiveType.Travel)
             {
                 travelTracker.UpdateCaravans();
             }
             if (def.type == ObjectiveType.Own)
             {
                 List <Thing> tempList = new List <Thing>();
                 List <Map>   Maps     = Find.Maps;
                 foreach (Map map in Maps)
                 {
                     List <SlotGroup> slots = map.haulDestinationManager.AllGroupsListForReading;
                     foreach (SlotGroup slot in slots)
                     {
                         tempList.AddRange(slot.HeldThings);
                     }
                 }
                 thingTracker.CheckOwnedItems(tempList);
             }
             if (thingTracker != null)
             {
                 thingTracker.TrackerTick();
             }
         }
         if (ObjectiveComplete)
         {
             Notify_Finish();
             return;
         }
         if (ObjectiveFailed)
         {
             Notify_Fail();
             return;
         }
     }
     LatestState = CurrentState;
 }
        public static string GetTimerText(int ticks, MOState state)
        {
            string label = "";
            int    timer = ticks;

            if (state == MOState.Finished || state == MOState.Failed || ticks == 0)
            {
                return(label = "---");
            }
            if (timer > GenDate.TicksPerYear)
            {
                label = Math.Round((decimal)timer / GenDate.TicksPerYear, 1) + "y";
            }
            else if (timer > GenDate.TicksPerDay)
            {
                label = Math.Round((decimal)timer / GenDate.TicksPerDay, 1) + "d";
            }
            else if (timer < GenDate.TicksPerDay)
            {
                label = Math.Round((decimal)timer / GenDate.TicksPerHour, 1) + "h";
            }
            return(label);
        }