コード例 #1
0
 public static ContraptionDataset LoadContraptionDataset(string levelName)
 {
             #if !UNITY_EDITOR
     XmlSerializer      xmlSerializer = new XmlSerializer(typeof(ContraptionDataset));
     ContraptionDataset result        = new ContraptionDataset();
     string             str           = WPFPrefs.ContraptionFileName(levelName);
     string             str2          = "ux0:" + Path.DirectorySeparatorChar + "data";
     if (!File.Exists(str2 + "/" + str))
     {
         return(new ContraptionDataset());
     }
     try
     {
         FileStream fileStream = new FileStream(str2 + "/" + str, FileMode.Open);
         byte[]     array      = new byte[fileStream.Length];
         fileStream.Read(array, 0, array.Length);
         byte[]       buffer = WPFPrefs.m_crypto.Decrypt(array, 0);
         MemoryStream stream = new MemoryStream(buffer);
         result = (xmlSerializer.Deserialize(stream) as ContraptionDataset);
         fileStream.Close();
     }
     catch
     {
     }
     return(result);
             #else
     ContraptionDataset result = new ContraptionDataset();
     return(result);
             #endif
 }
コード例 #2
0
ファイル: GameMode.cs プロジェクト: mrdivdiz/bpvita
    protected void LoadContraptionFromSlot(int slotIndex)
    {
        if (this.ContraptionProto)
        {
            if (this.ContraptionProto.HasTurboCharge)
            {
                GameProgress.AddTurboCharge(1);
                EventManager.Send(new InGameBuildMenu.ApplyTurboChargeEvent(GameProgress.TurboChargeCount(), false));
            }
            if (this.ContraptionProto.HasNightVision)
            {
                GameProgress.AddNightVision(1);
                EventManager.Send(new InGameBuildMenu.ApplyNightVisionEvent(GameProgress.NightVisionCount(), false));
            }
            if (this.ContraptionProto.HasSuperGlue)
            {
                GameProgress.AddSuperGlue(1);
                EventManager.Send(new InGameBuildMenu.ApplySuperGlueEvent(GameProgress.SuperGlueCount(), false));
            }
            if (this.ContraptionProto.HasSuperMagnet)
            {
                GameProgress.AddSuperMagnet(1);
                EventManager.Send(new InGameBuildMenu.ApplySuperMagnetEvent(GameProgress.SuperMagnetCount(), false));
            }
            foreach (BasePart basePart in this.ContraptionProto.Parts)
            {
                this.ContraptionProto.DataSet.AddPart(basePart.m_coordX, basePart.m_coordY, (int)basePart.m_partType, basePart.customPartIndex, basePart.m_gridRotation, basePart.m_flipped);
            }
            this.ContraptionProto.SaveContraption(this.GetCurrentContraptionName());
            this.levelManager.ConstructionUI.ClearContraption();
            this.Destroy(this.ContraptionProto.gameObject);
            this.ContraptionProto = null;
        }
        this.CurrentContraptionIndex = slotIndex;
        Vector3 position = (!this.levelStart) ? Vector3.zero : this.levelStart.transform.position;

        if (this.gameData.m_contraptionPrefab)
        {
            Transform transform = UnityEngine.Object.Instantiate(this.gameData.m_contraptionPrefab, position, Quaternion.identity);
            this.ContraptionProto = transform.GetComponent <Contraption>();
        }
        this.levelManager.ConstructionUI.SetCurrentContraption();
        this.BuildContraption(WPFPrefs.LoadContraptionDataset(this.GetCurrentContraptionName()));
        foreach (ConstructionUI.PartDesc partDesc in this.levelManager.ConstructionUI.PartDescriptors)
        {
            EventManager.Send(new PartCountChanged(partDesc.part.m_partType, partDesc.CurrentCount));
        }
        this.levelManager.ConstructionUI.SetMoveButtonStates();
        this.levelManager.SetGameState(LevelManager.GameState.Building);
    }
コード例 #3
0
    public Contraption CreateContraption(TextAsset contraptionData)
    {
        this.m_contraptionData = contraptionData;
        Vector2 v = base.transform.position;

        v.x = -5f + -15f * (float)Screen.width / (float)Screen.height;
        base.transform.position = v;
        Transform transform = UnityEngine.Object.Instantiate <Transform>(this.m_gameData.m_contraptionPrefab, base.transform.position, Quaternion.identity);

        transform.parent   = base.transform;
        this.m_contraption = transform.GetComponent <Contraption>();
        ContraptionDataset cds = WPFPrefs.LoadContraptionDataset(this.m_contraptionData);

        this.BuildContraption(cds);
        this.m_contraption.StartContraption();
        this.m_contraption.ActivateAllPoweredParts();
        return(this.m_contraption);
    }
コード例 #4
0
 public static void SaveContraptionDataset(string levelName, ContraptionDataset cds)
 {
             #if !UNITY_EDITOR
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(ContraptionDataset));
     MemoryStream  memoryStream  = new MemoryStream();
     StreamWriter  textWriter    = new StreamWriter(memoryStream, Encoding.UTF8);
     xmlSerializer.Serialize(textWriter, cds);
     byte[] clearTextBytes = memoryStream.ToArray();
     memoryStream.Close();
     byte[] array = WPFPrefs.m_crypto.Encrypt(clearTextBytes);
     string str   = WPFPrefs.ContraptionFileName(levelName);
     //string text = "ux0:" + Path.DirectorySeparatorChar + "data" + "/contraptions";
     //Directory.CreateDirectory(text);
     FileStream fileStream = new FileStream("ux0:" + Path.DirectorySeparatorChar + "data" + "/" + str, FileMode.Create);
     fileStream.Write(array, 0, array.Length);
     fileStream.Close();
             #endif
 }
コード例 #5
0
ファイル: BaseGameMode.cs プロジェクト: mrdivdiz/bpvita
    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();
    }
コード例 #6
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));
    }