Esempio n. 1
0
 public void GetGridSize(out int columns, out int rows)
 {
     columns = 0;
     rows    = 0;
     if (this.m_gridData == null)
     {
         return;
     }
     for (int i = 0; i < this.m_gridData.Length; i++)
     {
         if (this.m_gridData[i] > 0)
         {
             rows++;
             columns = Mathf.Max(columns, WPFMonoBehaviour.GetNumberOfHighestBit(this.m_gridData[i]) + 1);
         }
     }
 }
Esempio n. 2
0
    public override void InitGameMode()
    {
        base.CurrentConstructionGridRows = this.levelManager.m_constructionGridRows;
        int num           = 1;
        int newGridHeight = 1;

        for (int i = 0; i < base.CurrentConstructionGridRows.Count; i++)
        {
            if (base.CurrentConstructionGridRows[i] != 0)
            {
                int numberOfHighestBit = WPFMonoBehaviour.GetNumberOfHighestBit(base.CurrentConstructionGridRows[i]);
                if (numberOfHighestBit + 1 > num)
                {
                    num = numberOfHighestBit + 1;
                }
                newGridHeight = i + 1;
            }
        }
        int     newGridXMin = -(num - 1) / 2;
        int     newGridXMax = num / 2;
        Vector3 position    = (!this.levelStart) ? Vector3.zero : this.levelStart.transform.position;

        this.levelManager.CreateGrid(num, newGridHeight, newGridXMin, newGridXMax, position);
        if (this.levelManager.ConstructionUI)
        {
            if (GameProgress.HasKey(SchematicButton.LastLoadedSlotKey, GameProgress.Location.Local, null))
            {
                base.CurrentContraptionIndex = GameProgress.GetInt(SchematicButton.LastLoadedSlotKey, 0, GameProgress.Location.Local, null);
            }
            base.BuildContraption(WPFPrefs.LoadContraptionDataset(base.GetCurrentContraptionName()));
        }
        foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors)
        {
            EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount));
        }
        GameObject gameObject = new GameObject("CollectibleStash");

        gameObject.transform.parent = this.levelManager.transform;
        this.FindChallenges();
        this.levelManager.m_CollectedDessertsCount = 0;
        this.PlaceDesserts(false);
        this.InitializeChallenges();
    }
Esempio n. 3
0
    public override void InitGameMode()
    {
        CakeRaceInfo?cakeRaceInfo = CakeRaceMode.cakeRaceInfo;

        if (cakeRaceInfo == null)
        {
            this.FindCakeRaceInfo(CakeRaceMode.currentRaceTrackIndex);
        }
        else
        {
            CakeRaceMode.currentRaceTrackIndex = CakeRaceMode.cakeRaceInfo.Value.TrackIndex;
        }
        this.gainedXP = 0;
        this.IsRaceOn = false;
        this.InitScoreVariables();
        this.CreateCakes();
        this.CreateProps();
        base.Preview = this.CreatePreview();
        base.CurrentConstructionGridRows = CakeRaceMode.cakeRaceInfo.Value.Start.GridData;
        base.CameraLimits   = CakeRaceMode.cakeRaceInfo.Value.CameraLimits;
        base.GridCellPrefab = CakeRaceMode.cakeRaceInfo.Value.GridCellPrefab;
        base.TutorialPage   = CakeRaceMode.cakeRaceInfo.Value.TutorialBookPrefab;
        int num           = 1;
        int newGridHeight = 1;

        for (int i = 0; i < base.CurrentConstructionGridRows.Count; i++)
        {
            if (base.CurrentConstructionGridRows[i] != 0)
            {
                int numberOfHighestBit = WPFMonoBehaviour.GetNumberOfHighestBit(base.CurrentConstructionGridRows[i]);
                if (numberOfHighestBit + 1 > num)
                {
                    num = numberOfHighestBit + 1;
                }
                newGridHeight = i + 1;
            }
        }
        int newGridXMin = -(num - 1) / 2;
        int newGridXMax = num / 2;

        this.levelManager.CreateGrid(num, newGridHeight, newGridXMin, newGridXMax, CakeRaceMode.cakeRaceInfo.Value.Start.Position);
        base.ContraptionProto.transform.position = CakeRaceMode.cakeRaceInfo.Value.Start.Position;
        this.InitParts();
        base.CameraOffset       = new Vector3(0f, 15f, 0f);
        base.PreviewOffset      = new Vector3(0f, 15f, 0f);
        base.ConstructionOffset = new Vector3(0f, 0f, 0f);
        this.timeRunning        = false;
        if (this.levelManager.ConstructionUI)
        {
            if (GameProgress.HasKey(SchematicButton.LastLoadedSlotKey, GameProgress.Location.Local, null))
            {
                base.CurrentContraptionIndex = GameProgress.GetInt(SchematicButton.LastLoadedSlotKey, 0, GameProgress.Location.Local, null);
            }
            base.BuildContraption(WPFPrefs.LoadContraptionDataset(base.GetCurrentContraptionName()));
            foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors)
            {
                EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount));
            }
        }
        EventManager.Connect(new EventManager.OnEvent <TimeBomb.BombOutOfBounds>(this.OnBombOutOfBounds));
    }