protected void OnLittleZooDataReply(Message msg)
        {
            var _msg   = msg as LittleZooDataReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            //LogWarp.LogErrorFormat("{0}, {1}", _msg != null, entity != null);
            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            int cdVal      = _msg.littleZoo.visitCDValue;
            var playerData = GlobalDataManager.GetInstance().playerData;

            if (playerData.playerZoo.buffVisitCDVal != UFrame.Const.Invalid_Float)
            {
                int buffVisitCDVal = Math_F.FloatToInt1000(playerData.playerZoo.buffVisitCDVal);
                cdVal = Mathf.Min(cdVal, buffVisitCDVal);
            }

            if (visitCD == null)
            {
                visitCD = new IntCD(cdVal);
            }
            else
            {
                visitCD.ResetOrg(cdVal);
            }
            if (!GlobalDataManager.GetInstance().playerData.playerZoo.isGuide)
            {
                GetSceneUIGameObject();
            }

            visitCD.Run();
            isRevCDVal = true;

            //cd时间太短就执行idle
            if (cdVal < Math_F.FloatToInt1000(Config.globalConfig.getInstace().VisitorMinAnimLen))
            {
                entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorIdle);
                return;
            }
            var cell = entity.PlayActionAnim();

            if (cell.effectresid > 0)
            {
                effID = cell.effectresid;
                var pool = PoolManager.GetInstance().GetGameObjectPool(effID);
                effGo    = pool.New();
                effTrans = effGo.transform;
                effTrans.SetParent(GlobalDataManager.GetInstance().zooGameSceneData.littleZooParentNode, false);
                effPos            = entity.position;
                effPos.y          = cell.effectY;
                effTrans.position = effPos;
                effTrans.rotation = entity.rotation;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 轮船开过来,下指定数量的游客
        /// </summary>
        /// <param name="maxSpawnVisitorNum"></param>
        public static void GetoffVisitor(int maxSpawnVisitorNum)
        {
            LogWarp.LogError("GetoffVisitor");
            EntityShip entity;

            int sceneID       = GlobalDataManager.GetInstance().playerData.playerZoo.currSceneID;
            int visitorpathID = Config.sceneConfig.getInstace().getCell(sceneID).visitorpath;

            Config.sceneaddvisitorCell sceneaddvisitorCell = Config.sceneaddvisitorConfig.getInstace().getCell(visitorpathID);

            switch (visitorpathID)
            {
            case 0:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Ship, EntityFuncType.Ship) as EntityShip;
                break;

            case 1:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Train, EntityFuncType.Train) as EntityShip;
                break;

            default:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Ship, EntityFuncType.Ship) as EntityShip;
                break;
            }

            EntityManager.GetInstance().AddToEntityMovables(entity);
            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }
            entity.moveSpeed = sceneaddvisitorCell.movespeed;
            var path = PathManager.GetInstance().GetPath(sceneaddvisitorCell.intopath);

            entity.position = path[0];
            entity.followPath.Init(entity, path, path[0], 0, entity.moveSpeed, false);
            entity.maxSpawnVisitorNum    = maxSpawnVisitorNum;
            entity.visitorGetOffInterval = Math_F.FloatToInt1000(Config.globalConfig.getInstace().ShipVisitorGetOffInterval);
            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineShip(entity);

                entity.fsmMachine.AddState(new StateShipGoto((int)ShipState.Goto,
                                                             entity.fsmMachine));
                entity.fsmMachine.AddState(new StateShipGoback((int)ShipState.Goback,
                                                               entity.fsmMachine));

                entity.fsmMachine.SetDefaultState((int)ShipState.Goto);
            }
            else
            {
                entity.fsmMachine.GotoState((int)ShipState.Goto);
            }
            entity.Active();
        }
Esempio n. 3
0
        /// <summary>
        /// CD递减
        /// </summary>
        /// <param name="deltaTimeMS"></param>
        public override void Tick(int deltaTimeMS)
        {
            if (!isRecvCDVal)
            {
                return;
            }
            if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide)
            {
                if (visitCDGameObject == null)
                {
                    GetSceneUIGameObject();
                }
            }
            checkInCD.Tick(deltaTimeMS);  // cd时间递减
#if UNITY_EDITOR && !NOVICEGUIDE
            if (visitCDGameObject == null)
            {
                string e = string.Format("visitCDGameObject == null");
                throw new System.Exception(e);
                //GetSceneUIGameObject();
            }
#endif
            accumulativeUpdateUITime += deltaTimeMS;
            if (!checkInCD.IsFinish() && accumulativeUpdateUITime >= maxUpdateUIDuration)
            {
                image_VisitCD.fillAmount = 1 - (float)checkInCD.cd / checkInCD.org;
                accumulativeUpdateUITime = 0;
            }

            if (!checkInCD.IsFinish() && this.shouldImmediateFinishEntryGateCheckInCD)
            {
                checkInCD.cd             = Math_F.FloatToInt1000(playerData.playerZoo.buffEntryGateCDVal);
                image_VisitCD.fillAmount = 1 - (float)checkInCD.cd / checkInCD.org;
                shouldImmediateFinishEntryGateCheckInCD = false;
            }

            //cd自己结束或者收到秒cd
            if (checkInCD.IsRunning() && checkInCD.IsFinish())
            {
                image_VisitCD.fillAmount             = 0;
                visitCDGameObject.transform.position = UFrame.Const.Invisible_Postion;
                //只有最新解锁的场景动物栏和大门产钱
                if (playerData.playerZoo.currSceneID == playerData.playerZoo.lastUnLockSceneID)
                {
                    GetFlutterTextGameObject();
                }
                checkInCD.Stop();
                WhenCDFinished();
            }
        }
        public override void Tick(int deltaTimeMS)
        {
            if (!isRevCDVal)
            {
                return;
            }

            visitCD.Tick(deltaTimeMS);  // cd时间递减

            if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide)
            {
                if (visitCDGameObject == null)
                {
                    GetSceneUIGameObject();
                }
            }

            if (!visitCD.IsFinish())
            {
                image_VisitCD.fillAmount = 1 - (float)visitCD.cd / visitCD.org;
            }

            if (!visitCD.IsFinish() && shouldImmediateFinishVisitCD)
            {
                visitCD.cd = Math_F.FloatToInt1000(playerData.playerZoo.buffVisitCDVal);
                image_VisitCD.fillAmount     = 1 - (float)visitCD.cd / visitCD.org;
                shouldImmediateFinishVisitCD = false;
            }

            //cd结束腾出观光位
            //是再次进入选动物栏状态,还是已经到最后一组准备离开
            if (visitCD.IsRunning() && visitCD.IsFinish())
            {
                image_VisitCD.fillAmount             = 0;
                visitCDGameObject.transform.position = UFrame.Const.Invisible_Postion;
                //只有最新解锁的场景动物栏和大门产钱
                if (playerData.playerZoo.currSceneID == playerData.playerZoo.lastUnLockSceneID)
                {
                    GetFlutterTextGameObject();
                }

                visitCD.Stop();
                WhenVisitCDFinished();
            }
        }
Esempio n. 5
0
        protected void OnGetEntryGateDataReply(Message msg)
        {
            var _msg   = msg as GetEntryGateDataReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            //LogWarp.LogErrorFormat("{0}, {1}", _msg != null, entity != null);
            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            int cdVal = _msg.entryGate.checkInCDVal;

#if UNITY_EDITOR
            if (cdVal <= 0)
            {
                string e = string.Format("cdVal = {0}", cdVal);
                throw new System.Exception(e);
            }
#endif
            var playerData = GlobalDataManager.GetInstance().playerData;
            if (playerData.playerZoo.buffEntryGateCDVal != UFrame.Const.Invalid_Float)
            {
                int buffCD = Math_F.FloatToInt1000(playerData.playerZoo.buffEntryGateCDVal);
                cdVal = Mathf.Min(cdVal, buffCD);
            }

            if (checkInCD == null)
            {
                checkInCD = new IntCD(cdVal);
            }
            else
            {
                checkInCD.ResetOrg(cdVal);
            }

            if (!GlobalDataManager.GetInstance().playerData.playerZoo.isGuide)
            {
                GetSceneUIGameObject();
            }

            checkInCD.Run();

            isRecvCDVal = true;
        }
        protected void RunCheckInCD()
        {
            int cdVal      = ExitGateModule.GetChinkinCDValMs();
            var playerData = GlobalDataManager.GetInstance().playerData;

            if (playerData.playerZoo.buffExitEntryCDVal != UFrame.Const.Invalid_Float)
            {
                int buffExitEntryCDValMS = Math_F.FloatToInt1000(playerData.playerZoo.buffExitEntryCDVal);
                cdVal = Mathf.Min(cdVal, buffExitEntryCDValMS);
            }
            checkInCD.ResetOrg(cdVal);
            checkInCD.Run();
#if UNITY_EDITOR
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;
            LogWarp.LogFormat("{0} RunCheckInCD cdVal={1}", entity.entityID, cdVal);
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} RunCheckInCD cdVal={1}", entity.entityID, cdVal);
#endif
        }
Esempio n. 7
0
    /// <summary>
    /// 秒售票口CD
    /// </summary>
    /// <param name="obj"></param>
    private void OnClickAdsButton_TicketButton(string obj)
    {
        float timeCount = 0.1f;

        DOTween.To(() => timeCount, a => timeCount = a, 0.1f, 0.1f).OnComplete(new TweenCallback(delegate
        {
            //PageMgr.ShowPage<UIAdvertTouristPage>(obj);
            PageMgr.ShowPage <UINewCurrencyAdvertPage>(AdTagFM.Add_Ticket_Advert);

            ticketButton.gameObject.SetActive(false);
            int ticketButton_Time = Math_F.FloatToInt1000(Config.globalConfig.getInstace().TicketAccelerateCD);
            if (ticketIntCD == null)
            {
                multiTickObj.AddCD(ticketButton_Time, AdsButtonShow_Ticket);
            }
            else
            {
                ticketIntCD.Reset();
                ticketIntCD.Run();
            }
        }));
    }
 public void Update()
 {
     this.Tick(Math_F.FloatToInt1000(Time.deltaTime));
 }
Esempio n. 9
0
 public void Update()
 {
     SetAndroidQuit();
     this.Tick(Math_F.FloatToInt1000(Time.deltaTime));
 }
        /// <summary>
        /// 加载路,并存储路的rect区域
        /// </summary>
        protected void LoadRoad()
        {
            roadModel.Release();
            var animalRoad = LoadAnimalRoad();

            roadModel.spaceRoad = FSMCrossRoadGame.GetSize_Z(animalRoad);

            var cellStage = Config.crossroadstageConfig.getInstace().getCell(stageID);

            for (int i = 0; i < cellStage.roadnum; i++)
            {
                int numRoad = cellStage.roadweightmin;
                if (cellStage.roadweightmin != cellStage.roadweightmax)
                {
                    numRoad = Random.Range(cellStage.roadweightmin, cellStage.roadweightmax + 1);
                }

                int roadResID = Config.crossroadroadConfig.getInstace().getCell(numRoad).resid;

                var road = ResourceManager.GetInstance().LoadGameObject(Config.resourceConfig.getInstace().getCell(roadResID).prefabpath);


                int carInterval = Math_F.FloatToInt1000(Random.Range(cellStage.Intervalmin, cellStage.Intervalmax));

                lastRoadPos = startPoint + (roadModel.spaceRoad * i * Vector3.forward);
                Vector3 bcSize = road.GetComponent <BoxCollider>().size;

                float halfWidth = bcSize.z * 0.5f;
                if (i > 0)
                {
                    lastRoadPos += (preHalfWidth + halfWidth + preOffset) * Vector3.forward;
                    preOffset   += (preHalfWidth + halfWidth);
                }

                preHalfWidth = halfWidth;
                var roadRect = new Rect(
                    lastRoadPos.x, lastRoadPos.z,
                    bcSize.x, bcSize.z);
                roadModel.AddCrossRoad(
                    numRoad, roadRect, lastRoadPos, lastRoadPos + (Vector3.left * bcSize.x * 0.5f),
                    lastRoadPos + (Vector3.right * bcSize.x * 0.5f),
                    carInterval, RoadDir.LeftToRight, cellStage.speedmin, cellStage.speedmax);

                road.transform.position = lastRoadPos;

                if (i < cellStage.roadnum - 1)
                {
                    roadModel.AddToAnimalRoadSegment(lastRoadPos, roadRect, false);
                }
                else
                {
                    roadModel.AddToAnimalRoadSegment(lastRoadPos, roadRect, true);
                }
#if UNITY_EDITOR
                road.name = string.Format("CarRoad-{0}-{1}", i, halfWidth);
#endif

                animalRoad.transform.position = lastRoadPos - Vector3.forward * 0.5f * (roadModel.spaceRoad + bcSize.z);
#if UNITY_EDITOR
                animalRoad.name = string.Format("AnimalRoad-{0}", i);
#endif
                if (i < cellStage.roadnum - 1)
                {
                    animalRoad = LoadAnimalRoad();
                }
            }
        }