Пример #1
0
    // Update is called once per frame
    void Update()
    {
        mSttArr.DoAction();   // [2012:10:29:MOON] IAP .. Reject ..

        mCount++;

        mCoin.GetComponent <TextMesh> ().text = Ag.mySelf.mGold.ToString();

//        if (mCount > 900) { // Once in 30 sec...
//            if ( mSttArr.GetCurStateName() == "Rest")  {  AgStt.mIAP.CheckUnsentTransaction();  }
//            mCount = 1;
//        }

        if (mSttArr.GetCurStateName() == "InitPurchase")
        {
            mLodingbar2.active = true;
        }
        else
        {
            mLodingbar2.active = false;
        }

        //Ag.LogString("Is Started .. " + Ag.mIAP.mSendPackBool.mIsStarted );
    }
    public override void Update()
    {
        mCounter++;

        if (AgStt.DebugOnDevice)
        {
            int cur = (int)(mCounter % 30);
            FrameRate [cur] = Time.time;

            float last   = cur == 0 ? FrameRate [29] : FrameRate [cur - 1];
            float before = cur == 29 ? FrameRate [0] : FrameRate [cur + 1];
            AgStt.FpsLast = 1f / (FrameRate [cur] - last);
            AgStt.FramePS = 30f / (FrameRate [cur] - before);
        }

        if (mThreadEnd)
        {
            mInEverySomeFrame++;
            return;
        }

        if (mCounter % mInEverySomeFrame != 1)
        {
            return;
        }

//        string sceneName = "";
//        if (Application.platform == RuntimePlatform.OSXEditor)
//            sceneName = EditorApplication.currentScene;
//        else
//            sceneName = Application.loadedLevelName;
//        //Ag.LogString (sceneName + "   index " + sceneName.IndexOf ("Game") );
//        if (sceneName.IndexOf ("Game") > 0)
//            Ag.CurrentScene = "GAME";
//        else
//            Ag.CurrentScene = "MENU";

        // 30 1 sec.   정각보상  // 오전 8시~오후 11시   // Sleep Check ...
        if (mCounter % 200 == 1)
        {
            DateTime iNow = DateTime.Now;
            //Ag.LogString ("  Now  ::   " + iNow + "   Min : ?  " + (iNow.Minute == 0) + "  Hour  " + (iNow.Hour != hour) + "    Node ?   " + (Ag.NodeObj != null));
            //everyHour = "  Now  :: >> " + iNow + " <<      Min : < " + (iNow.Minute == 0) + " >       Hour : < " + (iNow.Hour != hour) + " >        Node :  < " + (Ag.NodeObj != null) + " >";

//            TimeSpan deActiveTS = DateTime.Now - Ag.NetExcpt.WASActionTime;
//            if (deActiveTS.TotalSeconds > 1200)
//                Application.LoadLevel ("Title");
//
            if (iNow.Minute == 0 && iNow.Hour != hour && Ag.NodeObj != null && (8 <= iNow.Hour && iNow.Hour <= 23))
            {
                WasCodeOnlyProtocol aObj = new WasCodeOnlyProtocol()
                {
                    User = Ag.mySelf, protoCode = 610
                };
                aObj.messageAction = (int pInt) => {
                    if (pInt == 0)
                    {
                        hour = iNow.Hour;
                        if (Ag.CurrentScene == "MENU")
                        {
                            FindGameObject("Axis/Camera/Match", true).GetComponent <MenuManager> ().dicMenuList ["LPanel_olclock"].SetActive(true);
                        }
                        else
                        {
                            HourlyEvent = true;
                        }
                        Ag.LogIntenseWord("   >>>>>     " + Tbl.dicHanLog ["EveryHourEvent"] + "       Result ::  " + pInt);
                    }
                    aObj = null;
                };
            }

            if (HourlyEvent && Application.loadedLevelName == "StartMenu")
            {
                FindGameObject("Axis/Camera/Match", true).GetComponent <MenuManager> ().dicMenuList ["LPanel_olclock"].SetActive(true);
            }
        }

        if (mNetDebug && mStt != null)
        {
            ("< Net > >>  { " + mCounter + " }   <<<  [arrJobs.Count ::  " + arrJobs.Count + " ]    @ Scene : " + Ag.CurrentScene
             //+ "    \t State >> " + mStt.GetCurStateName () + "    <<  >>>  " + everyHour).HtLog ();
             + "    \t " + "  <<  >>>  " + everyHour).HtLog();
        }

        everyHour = " .. ";

        if (mStt != null)
        {
            mStt.DoAction();
        }
        if (mCounter > 1000000)
        {
            mCounter = 0;
        }
    }
    public virtual void GenState()
    {
        Ag.LogIntenseWord(" NetworkManagerMono :: GenState ");
        mStt = new StateArray();

        mStt.AddAMember("Online", 0);
        mStt.AddEntryAction(() => {
            mInEverySomeFrame = 5;
        });
        mStt.AddDuringAction(() => {
            if (arrJobs.Count > 0)
            {
                SetState("PacketSend");   // Change State
            }
            else
            {
                mInEverySomeFrame = 100;
            }
        });
        mStt.AddExitCondition(() => {
            return(false);
        });
        mStt.AddAMember("PacketSend", 0);
        mStt.AddEntryAction(() => {
            //SendWaitingCount = 0;
            SendPacket();
        });
        mStt.AddDuringAction(() => {
            SendWaitingCount++;
            Ag.LogDouble("  ::  PacketSend  >>>   SendWaitingCount : " + SendWaitingCount);
            if (SendWaitingCount > 5)
            {
                arrJobs.Remove(CurJob);
                //Ag.NetExcpt.DisconnectedWith (was: true);
                SetState("Online");
            }
        });
        mStt.AddAMember("Receive", 0);
        mStt.AddDuringAction(() => {
            SendWaitingCount = 0;
            if (CurJob.dlgtJobCompleted())
            {
                PrepareNextJob();
            }
            else
            {
                arrJobs.Remove(CurJob);
                SetState("Online");   // Change State
                return;
//                if (NetworkFailedJob != null)
//                    NetworkFailedJob ();
                // RetryJob ();

                //Ag.HttpNetworkFailure = true;
            }
        });
        mStt.AddAMember("ERROR", 0);
        mStt.AddEntryAction(() => {
            mInEverySomeFrame = 150;
        });
        SetState("Online");   // Set Initial State..
        mStt.DoAction();
    }
 public void AddAUnitJob(AmNetUnitJob aJob)
 {
     arrJobs.Add(aJob);
     SetState("PacketSend");
     mStt.DoAction();
 }