Ejemplo n.º 1
0
        public PartData(BasePart part, PartListing partListInstance)
        {
            PartListing.PartData.partList = partListInstance;
            this.parts = new Dictionary <BasePart.PartTier, List <BasePart> >();
            this.parts.Add(part.m_partTier, new List <BasePart>());
            this.parts[part.m_partTier].Add(part);
            this.type = part.m_partType;
            CustomPartInfo customPart = WPFMonoBehaviour.gameData.GetCustomPart(part.m_partType);

            this.partInstances = new Dictionary <BasePart.PartTier, List <GameObject> >();
            this.partInstances.Add(part.m_partTier, new List <GameObject>());
            this.selectedIcon = null;
            if (customPart == null)
            {
                return;
            }
            for (int i = 0; i < customPart.PartList.Count; i++)
            {
                if (customPart.PartList[i].VisibleOnPartListBeforeUnlocking)
                {
                    if (!this.parts.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.parts.Add(customPart.PartList[i].m_partTier, new List <BasePart>());
                    }
                    this.parts[customPart.PartList[i].m_partTier].Add(customPart.PartList[i]);
                    if (!this.partInstances.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.partInstances.Add(customPart.PartList[i].m_partTier, new List <GameObject>());
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void InitButtons(PartListing partListing, Action <BasePart.PartType> onButtonPressed)
 {
     this.cachedPartListing = partListing;
     this.onButtonPressed   = onButtonPressed;
     if (this.initButtonsDone)
     {
         return;
     }
     if (this.customPartWidget != null)
     {
         Transform transform = this.cachedPartListing.transform.Find("Close");
         if (transform)
         {
             this.customPartWidget.closeButton = transform.GetComponent <Button>();
         }
     }
     for (int i = 0; i < Enum.GetNames(typeof(BasePart.PartType)).Length; i++)
     {
         for (int j = 0; j < Enum.GetNames(typeof(BasePart.PartTier)).Length; j++)
         {
             BasePart.PartType partType          = (BasePart.PartType)i;
             List <GameObject> partTierInstances = this.cachedPartListing.GetPartTierInstances(partType, (BasePart.PartTier)j);
             if (partTierInstances != null)
             {
                 for (int k = 0; k < partTierInstances.Count; k++)
                 {
                     bool enabled         = j == 0;
                     int  customPartIndex = WPFMonoBehaviour.gameData.GetCustomPartIndex(partType, partTierInstances[k].name);
                     if (j > 0)
                     {
                         enabled = CustomizationManager.IsPartUnlocked(WPFMonoBehaviour.gameData.GetCustomPart(partType, customPartIndex));
                     }
                     BoxCollider component = partTierInstances[k].GetComponent <BoxCollider>();
                     if (component != null)
                     {
                         component.enabled = enabled;
                         Button component2 = partTierInstances[k].GetComponent <Button>();
                         component2.MethodToCall.SetMethod(this, "CustomButtonPressed", new object[]
                         {
                             i,
                             customPartIndex
                         });
                     }
                 }
             }
         }
     }
     this.cachedPartListing.CreateSelectionIcons();
     this.initButtonsDone = true;
 }
Ejemplo n.º 3
0
 private void CreatePartListing()
 {
     if (this.partListing != null)
     {
         return;
     }
     this.partListing = PartListing.Create();
     this.partListing.transform.parent = base.transform.parent.parent;
     this.partListing.Close();
     if (this.scope == null)
     {
         this.CreatePartScope(UnityEngine.Object.FindObjectOfType <LevelManager>());
     }
     this.partListing.SetPartScope(this.scope);
 }
Ejemplo n.º 4
0
    public override void OnDataLoadedStart()
    {
        PartListing.Create().Close();
        int @int = GameProgress.GetInt("branded_reward_gift_time", 0, GameProgress.Location.Local, null);
        int num  = 86400;

        if (Singleton <GameConfigurationManager> .IsInstantiated() && Singleton <GameConfigurationManager> .Instance.HasValue("branded_reward_cooldown", "time"))
        {
            num = Singleton <GameConfigurationManager> .Instance.GetValue <int>("branded_reward_cooldown", "time");
        }
        if (@int > 0 && Singleton <TimeManager> .Instance.CurrentEpochTime - @int > num)
        {
            GameProgress.DeleteKey("branded_reward_gift_time", GameProgress.Location.Local);
            GameProgress.DeleteKey("branded_reward_gifts_today", GameProgress.Location.Local);
        }
    }
Ejemplo n.º 5
0
    private void OnEnable()
    {
        PartListing partListing = this.partListing;

        partListing.OnPartListingMoved = (Action <float>)Delegate.Combine(partListing.OnPartListingMoved, new Action <float>(this.OnPartListMoved));
        PartListing partListing2 = this.partListing;

        partListing2.OnPartListDragBegin = (Action)Delegate.Combine(partListing2.OnPartListDragBegin, new Action(this.OnPartListDragBegin));
        PartListingScrollbutton partListingScrollbutton = this.scrollButton;

        partListingScrollbutton.OnDragBegin = (Action)Delegate.Combine(partListingScrollbutton.OnDragBegin, new Action(this.OnButtonDragBegin));
        PartListingScrollbutton partListingScrollbutton2 = this.scrollButton;

        partListingScrollbutton2.OnDrag = (Action <float>)Delegate.Combine(partListingScrollbutton2.OnDrag, new Action <float>(this.OnButtonDrag));
        PartListingScrollbutton partListingScrollbutton3 = this.scrollButton;

        partListingScrollbutton3.OnDragEnd = (Action)Delegate.Combine(partListingScrollbutton3.OnDragEnd, new Action(this.OnButtonDragEnd));
    }
Ejemplo n.º 6
0
        public void CompleteMultipartUploadWithListParts()
        {
            var sourceFile = Config.MultiUploadTestFile;
            //get target object name
            var targetObjectKey = OssTestUtils.GetObjectKey(_className);

            var initRequest = new InitiateMultipartUploadRequest(_bucketName, targetObjectKey);
            var initResult  = _ossClient.InitiateMultipartUpload(initRequest);

            // Set the part size
            const int partSize = 1024 * 1024 * 1;

            var partFile = new FileInfo(sourceFile);
            // Calculate the part count
            var partCount = OssTestUtils.CalculatePartCount(partFile.Length, partSize);

            LogUtility.LogMessage("File {0} is splitted to {1} parts for multipart upload",
                                  sourceFile, partCount);

            //upload the file
            using (var fs = new FileStream(partFile.FullName, FileMode.Open))
            {
                for (var i = 0; i < partCount; i++)
                {
                    // Skip to the start position
                    long skipBytes = partSize * i;
                    fs.Position = skipBytes;

                    // calculate the part size
                    var size = partSize < partFile.Length - skipBytes
                        ? partSize
                        : partFile.Length - skipBytes;

                    // Create a UploadPartRequest, uploading parts
                    var uploadPartRequest = new UploadPartRequest(_bucketName, targetObjectKey, initResult.UploadId)
                    {
                        InputStream = fs,
                        PartSize    = size,
                        PartNumber  = (i + 1)
                    };
                    _ossClient.UploadPart(uploadPartRequest);
                }
            }

            var    lmuRequest = new ListMultipartUploadsRequest(_bucketName);
            var    lmuListing = _ossClient.ListMultipartUploads(lmuRequest);
            string mpUpload   = null;

            foreach (var t in lmuListing.MultipartUploads)
            {
                if (t.UploadId == initResult.UploadId)
                {
                    mpUpload = t.UploadId;
                }
            }

            Assert.IsNotNull(mpUpload, "The multipart uploading should be in progress");

            PartListing partList = _ossClient.ListParts(new ListPartsRequest(_bucketName, targetObjectKey, mpUpload));

            var completeRequest = new CompleteMultipartUploadRequest(_bucketName, targetObjectKey, initResult.UploadId);

            foreach (var part in partList.Parts)
            {
                completeRequest.PartETags.Add(part.PartETag);
            }
            _ossClient.CompleteMultipartUpload(completeRequest);

            Assert.IsTrue(OssTestUtils.ObjectExists(_ossClient, _bucketName, targetObjectKey));

            //delete the object
            _ossClient.DeleteObject(_bucketName, targetObjectKey);
        }