private void PushOneStack(int coinNum, int fishOdd, int gunScore)
    {
        //return;
        if (coinNum <= 0)
        {
            return;
        }


        //CoinStack coinStackNew = Instantiate(Prefab_coinStack) as CoinStack;
        CoinStack coinStackNew   = Pool_GameObj.GetObj(Prefab_coinStack.gameObject).GetComponent <CoinStack>();
        Transform coinStackNewTs = coinStackNew.transform;

        mCoinStackCurrentDepth       = mCoinStacks.Count == 0 ? 0F : mCoinStackCurrentDepth - 0.1F;
        coinStackNewTs.parent        = transform;
        coinStackNewTs.localRotation = Quaternion.identity;
        coinStackNewTs.localPosition = new Vector3(-mCoinStacks.Count * (OneStackWidth + OneStackSpace), 0F, mCoinStackCurrentDepth);
        coinStackNew.PileUp(coinNum, GetCoinStackHeight(fishOdd, gunScore), mCurCoinStackBGColor);

        mCurCoinStackBGColor = !mCurCoinStackBGColor;

        coinStackNew.EvtDisappear  += Handle_CoinStackDisappear;
        coinStackNew.EvtRoleToHead += Handle_CoinStackRollToHead;

        mCoinStacks.Enqueue(coinStackNew);

        //mState_IsMovingStacks = true;
    }
 void Handle_CoinStackRollToHead(CoinStack cStack)
 {
     if (mCoinStacks.Count != 0 &&
         cStack.GetInstanceID() == mCoinStacks.Peek().GetInstanceID())
     {
         cStack.FadeOut();
     }
 }
    private float mCenterToCenterBetweenStack;  //币堆间的距离
    void Update()
    {
        //如果显示中的币堆少于限制数,则加入新币堆.
        if (mCoinStackDataToView.Count > 0 && mCoinStacks.Count < NumCoinStackLimit)
        {
            CoinStackDataToView csdtv = mCoinStackDataToView.Dequeue();
            PushOneStack(csdtv.coinNum, csdtv.fishOdd, csdtv.gunScore);
        }

        if (mState_IsMovingStacks)
        {
            if (mCoinStacks.Count == 0)
            {
                goto TAG_BREAK_MOVINGSTACK;
            }

            if (mElapse_MovingStacks < TimeMoveUse)
            {
                int       idx = 1;
                Transform tsCoinStack;
                foreach (CoinStack cs in mCoinStacks)
                {
                    tsCoinStack = cs.transform;
                    tsCoinStack.localPosition = new Vector3(-mCenterToCenterBetweenStack * idx + mElapse_MovingStacks / TimeMoveUse * mCenterToCenterBetweenStack, 0F, tsCoinStack.localPosition.z);
                    ++idx;
                }
                //if (mElapse_MovingStacks == TimeMoveUse)
                //{
                //    break;
                //}

                //if (mElapse_MovingStacks > TimeMoveUse)
                //    mElapse_MovingStacks = TimeMoveUse;


                mElapse_MovingStacks += Time.deltaTime;
            }
            else//移动到目标位置
            {
                int       idx = 1;
                Transform tsCoinStack;
                foreach (CoinStack cs in mCoinStacks)
                {
                    tsCoinStack = cs.transform;
                    tsCoinStack.localPosition = new Vector3(-mCenterToCenterBetweenStack * idx + mCenterToCenterBetweenStack, 0F, tsCoinStack.localPosition.z);
                    ++idx;
                }
                CoinStack coinStackHead = mCoinStacks.Peek();
                if (coinStackHead.IsRoleToHead)//如果最前面的还没有pileup到顶部,则不进行消失
                {
                    coinStackHead.FadeOut();
                    mElapse_MovingStacks  = 0F;
                    mState_IsMovingStacks = false;
                }
            }
            TAG_BREAK_MOVINGSTACK :;
        }
    }
 void Handle_CoinStackDisappear(CoinStack cStack)
 {
     mCoinStacks.Dequeue();
     Pool_GameObj.RecycleGO(null, cStack.gameObject);
     if (mCoinStacks.Count != 0)
     {
         mState_IsMovingStacks = true;
         mElapse_MovingStacks  = 0F;
     }
 }
        private CoinStack GetExportCoins()
        {
            var coinStack = new CoinStack();

            coinStack.Add(safe.Contents.AuthCoinOnes, (int)pickerOne.SelectedRowInComponent(0));
            coinStack.Add(safe.Contents.AuthCoinFives, (int)pickerFive.SelectedRowInComponent(0));
            coinStack.Add(safe.Contents.AuthCoinQuarters, (int)picker25.SelectedRowInComponent(0));
            coinStack.Add(safe.Contents.AuthCoinHundreds, (int)picker100.SelectedRowInComponent(0));
            coinStack.Add(safe.Contents.AuthCoinKiloQuarters, (int)picker250.SelectedRowInComponent(0));
            return(coinStack);
        }
Beispiel #6
0
        private bool CheckChangeCanBeGiven(decimal itemPrice)
        {
            var combinedResources = new CoinStack();

            combinedResources.AddCoinsToStack(currentCoins.GetAllCoins());
            combinedResources.AddCoinsToStack(cashBox.GetAllCoins());

            var ordered = combinedResources.GetAllCoins().OrderBy(x => x.Key.CoinWorth);

            foreach (var coinType in ordered)
            {
                var coinsAvailable = coinType.Value;
                while (itemPrice >= coinType.Key.CoinWorth && coinsAvailable > 0)
                {
                    itemPrice      -= coinType.Key.CoinWorth;
                    coinsAvailable -= 1;
                    coinReturn.AddCoinsToStack(coinType.Key);
                }
            }

            return(itemPrice == 0 ? true : false);
        }
        private void InitializeMethods()
        {
            btnCancel.TouchUpInside += (sender, e) =>
            {
                RemoveAnimate();
            };

            btnExport.TouchUpInside += async(sender, e) =>
            {
                bool isJson = segmentFormat.SelectedSegment == 1 ? true : false;
                exportCoins = GetExportCoins();

                appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;

                int isUnZip = 1;
                if (appDelegate.IsSupportZip())
                {
                    isUnZip = await ShowAlert("Export", "Would you like to export as zip file?", new string[] { "Yes", "No" });
                }

                var isExported = safe.SaveOutStack(GetExportCoins(), (int)desiredSum, isJson, lblNote.Text);

                if (isExported)
                {
                    var fileDataList = new List <NSObject>();

                    if (isUnZip == 0)
                    {
                        var zipViewController = (ZipPasswordViewController)Storyboard.InstantiateViewController("ZipPasswordViewController");
                        zipViewController.ShowInView(View, true);
                        var enterPassword = await zipViewController.GetEnterPassword();

                        zipViewController.RemoveAnimate();

                        var zip     = new ZipArchive();
                        var zipPath = appDelegate.ExportDir + "/cloudcoin.zip";
                        zip.CreateZipFile(zipPath, enterPassword);
                        foreach (var path in safe.ExportedPaths)
                        {
                            zip.AddFile(path, Path.GetFileName(path));
                        }
                        fileDataList.Add(NSUrl.FromFilename(zipPath));
                        zip.CloseZipFile();
                    }
                    else
                    {
                        foreach (var path in safe.ExportedPaths)
                        {
                            fileDataList.Add(NSUrl.FromFilename(path));
                        }
                    }

                    Logger.Write("Export coins", Logger.Level.Normal);

                    var activityViewController = new UIActivityViewController(fileDataList.ToArray(), null);

                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        activityViewController.PopoverPresentationController.SourceView = this.View;
                    }

                    activityViewController.CompletionHandler += SetCompletionHandler;

                    PresentViewController(activityViewController, true, null);
                }
                else
                {
                    await ShowAlert("Export", "Nothing to export!\n", new string[] { "Ok" });

                    Logger.Write("Nothing to export!", Logger.Level.Normal);
                }
            };
        }
Beispiel #8
0
 void Start()
 {
     instance = this;
     player   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>();
 }
Beispiel #9
0
 void Handle_CoinStackRollToHead(CoinStack cStack)
 {
     if (mCoinStacks.Count != 0
         && cStack.GetInstanceID() == mCoinStacks.Peek().GetInstanceID())
         cStack.FadeOut();
 }
Beispiel #10
0
 void Handle_CoinStackDisappear(CoinStack cStack)
 {
     mCoinStacks.Dequeue();
     Pool_GameObj.RecycleGO(null, cStack.gameObject);
     if (mCoinStacks.Count != 0)
     {
         mState_IsMovingStacks = true;
         mElapse_MovingStacks = 0F;
     }
 }