示例#1
0
    public void Show()
    {
        Loc.GetTimeManager().Pause();
        Loc.GetGameController().Typing = true;

        _showingConsole = true;
    }
示例#2
0
    private static string SetTime(string args)
    {
        var split = args.Split(':');

        Loc.GetTimeManager().Data.Hour = int.Parse(split[0]);
        Loc.GetTimeManager().Data.Minute = int.Parse(split[1]);
        return($"Time Set To: {Loc.GetTimeManager().Data.Hour}:{Loc.GetTimeManager().Data.Minute}");
    }
示例#3
0
    public void Update()
    {
        if (Loc.GetTimeManager().Paused)
        {
            return;
        }

        LastUpdate += Time.deltaTime;
        if (LastUpdate > UpdateTick)
        {
            LastUpdate = 0;

            foreach (var blueprint in Blueprints)
            {
                if (blueprint.AssociatedBuildTask == null)
                {
                    AddTask(new Build(blueprint));
                }
            }

            const int maxStoreTasks = 2;

            var storeTasks = AllTasks.OfType <StoreItem>().ToList();
            if (storeTasks.Count < maxStoreTasks)
            {
                if (StorageZones.Any(s => s.GetFreeCellCount() > 0))
                {
                    var items = DomainCells.GetCells().SelectMany(c => c.Items)
                                .Where(i => !i.IsReserved() &&
                                       !i.IsStored() &&
                                       !storeTasks.Any(t => t.GetItemId() == i.Id))
                                .ToList();

                    foreach (var storageZone in StorageZones)
                    {
                        foreach (var item in items)
                        {
                            if (storageZone.CanStore(item))
                            {
                                AddTask(new StoreItem(item));
                                break;
                            }
                        }
                    }
                }
            }
        }

        ResumeDelta += Time.deltaTime;
        if (ResumeDelta > AutoResumeTime)
        {
            ResumeDelta = 0;
            foreach (var task in AvailableTasks.Where(t => t.IsSuspended() && t.AutoResume))
            {
                task.Resume();
            }
        }
    }
示例#4
0
        public void Update()
        {
            if (Loc.GetTimeManager().Paused)
            {
                return;
            }

            UpdateWorkStructures();
        }
示例#5
0
    public void Update()
    {
        foreach (var step in AllButtons)
        {
            step.Value.GetComponent <Image>().color = step.Key == Loc.GetTimeManager().GetTimeStep() ? ColorConstants.BlueBase : ColorConstants.GreyBase;
        }

        TimeDisplay.text = $"{Loc.GetTimeManager().Data.Hour.ToString().PadLeft(2, '0')}:{Loc.GetTimeManager().Data.Minute.ToString().PadLeft(2, '0')}";
    }
示例#6
0
    public void Toggle()
    {
        gameObject.SetActive(!gameObject.activeInHierarchy);
        MainMenuActive = gameObject.activeInHierarchy;

        if (MainMenuActive)
        {
            Loc.GetTimeManager().Pause();
        }
    }
示例#7
0
    public static void Load(string saveFile)
    {
        Loc.GetTimeManager().Pause();

        if (string.IsNullOrEmpty(saveFile))
        {
            saveFile = Directory.EnumerateFiles(SaveDir).Last();
        }

        Restart(Save.FromFile(saveFile));
    }
示例#8
0
 public static Save MakeSave()
 {
     return(new Save
     {
         MapGenerationData = MapGenerationData.Instance,
         Factions = Loc.GetFactionController().Factions.Values.ToList(),
         Time = Loc.GetTimeManager().Data,
         Items = Loc.GetIdService().ItemIdLookup.Values.ToList(),
         CameraData = new CameraData(Loc.GetCamera()),
         Rooms = Loc.GetZoneController().RoomZones,
         Stores = Loc.GetZoneController().StorageZones,
         Areas = Loc.GetZoneController().AreaZones,
         Chunks = Loc.GetMap().Chunks.Values.Select(s => s.Data).ToList(),
     });
 }
示例#9
0
    private void Update()
    {
        if (Loc.GetTimeManager().Paused)
        {
            return;
        }

        if (Data.FullSpan < 0)
        {
            Data.FullSpan = Data.LifeSpan;
        }

        if (Data.StartIntensity < 0)
        {
            Data.StartIntensity = Data.Intensity;
        }
        Data.TimeAlive += Time.deltaTime;
        Data.LifeSpan  -= Time.deltaTime;
        if (Data.LifeSpan <= 0)
        {
            DestroySelf();
            return;
        }

        float t    = Data.TimeAlive / Data.LifeSpan;
        var   step = Data.FadeOut ? Mathf.SmoothStep(0, Data.FullSpan, t) : Mathf.SmoothStep(Data.FullSpan, 0, t);

        if (Sprite != null)
        {
            if (Data.Fade)
            {
                Sprite.color = new Color(Sprite.color.r,
                                         Sprite.color.g,
                                         Sprite.color.b,
                                         step);
            }
        }

        if (Light != null)
        {
            if (Data.Fade)
            {
                Light.intensity = Data.Intensity * (Data.LifeSpan / Data.FullSpan);
            }
        }
    }
示例#10
0
    public void Start()
    {
        PauseButton.onClick.AddListener(() => Loc.GetTimeManager().SetTimeStep(TimeStep.Paused));
        SlowButton.onClick.AddListener(() => Loc.GetTimeManager().SetTimeStep(TimeStep.Slow));
        NormalButton.onClick.AddListener(() => Loc.GetTimeManager().SetTimeStep(TimeStep.Normal));
        FastButton.onClick.AddListener(() => Loc.GetTimeManager().SetTimeStep(TimeStep.Fast));
        FasterButton.onClick.AddListener(() => Loc.GetTimeManager().SetTimeStep(TimeStep.Hyper));

        AllButtons = new Dictionary <TimeStep, Button>
        {
            { TimeStep.Paused, PauseButton },
            { TimeStep.Slow, SlowButton },
            { TimeStep.Normal, NormalButton },
            { TimeStep.Fast, FastButton },
            { TimeStep.Hyper, FasterButton }
        };
    }
示例#11
0
        public static void HandleHotkeys()
        {
            if (Loc.GetGameController().Typing)
            {
                return;
            }

            if (Input.GetKeyDown("`"))
            {
                DeveloperConsole.Instance.Show();
            }
            else if (Input.GetKeyDown("space"))
            {
                if (Loc.GetTimeManager().GetTimeStep() == TimeStep.Paused)
                {
                    Loc.GetTimeManager().SetTimeStep(_oldTimeStep);
                }
                else
                {
                    _oldTimeStep = Loc.GetTimeManager().GetTimeStep();
                    Loc.GetTimeManager().Pause();
                }
            }
            else if (Input.GetKeyDown("escape"))
            {
                Loc.GetGameController().MainMenuController.Toggle();
            }
            else if (Input.GetKeyDown("1"))
            {
                Loc.GetTimeManager().SetTimeStep(TimeStep.Slow);
            }
            else if (Input.GetKeyDown("2"))
            {
                Loc.GetTimeManager().SetTimeStep(TimeStep.Normal);
            }
            else if (Input.GetKeyDown("3"))
            {
                Loc.GetTimeManager().SetTimeStep(TimeStep.Fast);
            }
            else if (Input.GetKeyDown("4"))
            {
                Loc.GetTimeManager().SetTimeStep(TimeStep.Hyper);
            }
            else if (Input.GetKeyDown("b"))
            {
                Loc.GetGameController().OrderSelectionController.BuildTypeClicked();
            }
            else if (Input.GetKeyDown("n"))
            {
                Loc.GetGameController().OrderSelectionController.DesignateTypeClicked();
            }
            else if (Input.GetKeyDown("z"))
            {
                Loc.GetGameController().OrderSelectionController.ZoneTypeClicked();
            }
            else if (Input.GetKeyDown("c"))
            {
                Loc.GetGameController().OrderSelectionController.ConstructTypeClicked();
            }
            else if (Input.GetKeyDown("e"))
            {
                Loc.Current.Get <CursorController>().RotateRight();
            }
            else if (Input.GetKeyDown("q"))
            {
                Loc.Current.Get <CursorController>().RotateLeft();
            }
            else if (Input.GetKeyDown(KeyCode.Tab))
            {
                Loc.GetGameController().UIController.Toggle();
            }
        }
示例#12
0
 public Timer GetTimer()
 {
     return(Loc.GetTimeManager().GetTimer(TimerId));
 }
示例#13
0
 public Wait(int duration, string reason, AnimationType animation = AnimationType.Idle) : this()
 {
     Animation = animation;
     TimerId   = Loc.GetTimeManager().StartTimer(duration);
     Reason    = reason;
 }