//crea e setta i timer collegati ai movimenti void SetTimers() { foreach (MovementData movementData in LevelManager.CurrentLevel.movementDatas) { Timer timer = timerManager.AddTimer(movementData.startTime); switch (movementData.movement.ToString()) { case "Jump": timer.triggeredEvent += WaitAndJump; break; case "Run": timer.triggeredEvent += Run; break; case "Stop": timer.triggeredEvent += Stop; break; } movementTimers.Add(timer); } timerBeforeExulting = timerManager.AddTimer(0.7f); timerBeforeExulting.triggeredEvent += Exult; }
// Use this for initialization private void Start() { TimerManager timerManager = TimerManager.instance; QuickUnity.Timers.Timer timer1 = new QuickUnity.Timers.Timer(0.6f); timer1.AddEventListener(TimerEvent.Timer, OnTimerHandler); timerManager.AddTimer("test1", timer1); QuickUnity.Timers.Timer timer2 = new QuickUnity.Timers.Timer(2.5f, 10); timer2.AddEventListener(TimerEvent.TimerComplelte, OnTimerCompleteHandler); timerManager.AddTimer("test2", timer2); }
public void StartStreaming(PictureSize size, int fps) { camDriver.StartVideoStreaming(size, fps); TimerManager tempTimerManager = TimerManager.GetInstance(); FlashTimerGuid = tempTimerManager.AddTimer(FlashThreadFunc, null, 0, 1000 / fps); }
public void StartStreaming(int width, int height, int fps) { camDriver.StartVideoStreaming(new PictureSize(width, height), fps); TimerManager tempTimerManager = TimerManager.GetInstance(); FlashTimerGuid = tempTimerManager.AddTimer(FlashThreadFunc, null, 0, 1000 / fps); }
public void CastSkillError(string error) { //防止最开始出现token气泡 if (!GuideModel.singleton.bIsGuideAllComp && GuideModel.singleton.bIsSelfSpeaked == false) { return; } if (!GuideModel.singleton.bIsGuideAllComp) { //再次尝试 GuideModel.singleton.NowTaskId = 6007; EventDispatch.Broadcast(Events.DlgGuideExecuteNextTask); } //出现口令 this.ShowToken(error); this.ShowMask(false); if (this.ShowTokenTimerId != uint.MinValue) { TimerManager.DelTimer(this.ShowTokenTimerId); this.ShowTokenTimerId = TimerManager.AddTimer(4000, 0, () => { this.ShowToken("", false); }); } else { this.ShowTokenTimerId = TimerManager.AddTimer(4000, 0, () => { this.ShowToken("", false); }); } }
public void CastSkill(string token) { int skillId = -1; if (string.IsNullOrEmpty(token)) { if (!GuideModel.singleton.bIsGuideAllComp) { //再次尝试 GuideModel.singleton.NowTaskId = 6007; EventDispatch.Broadcast(Events.DlgGuideExecuteNextTask); } } else { //出现口令 skillId = SkillManager.singleton.MatchSkill(token); if (skillId == -1) { Debug.Log("匹配不到技能"); this.ShowToken(token); if (!GuideModel.singleton.bIsGuideAllComp) { //再次尝试 GuideModel.singleton.NowTaskId = 6007; EventDispatch.Broadcast(Events.DlgGuideExecuteNextTask); } } } GameSkillBase skill = SkillManager.singleton.GetSkill(skillId); if (skill != null) { this.ShowToken(skill.skillConfig.skillName); skill.Enter(this.entity, true); if (!GuideModel.singleton.bIsGuideAllComp) { TimerManager.AddTimer(4000, 0, () => { GuideModel.singleton.NowTaskId = 6008; EventDispatch.Broadcast(Events.DlgGuideExecuteNextTask); }); } } if (this.ShowTokenTimerId != uint.MinValue) { TimerManager.DelTimer(this.ShowTokenTimerId); this.ShowTokenTimerId = TimerManager.AddTimer(4000, 0, () => { this.ShowToken("", false); }); } else { this.ShowTokenTimerId = TimerManager.AddTimer(4000, 0, () => { this.ShowToken("", false); }); } }
public void OnClickButtonSpeakTest() { GameSkillBase skill = SkillManager.singleton.GetSkill(this.selectSkillId); //等音频播放结束后,然后角色播放动作 if (skill != null) { this.ShowSpeakButton(false); //出现口令 this.ShowToken(skill.skillConfig.skillRealToken); skill.Enter(this.entity, true); TimerManager.AddTimer(4000, 0, () => { this.ShowToken("", false); this.ShowSpeakButton(true); if (!GuideModel.singleton.bIsGuideAllComp && GuideModel.singleton.bIsSelfSpeaked == false) { //然后开始guide进入自己说 GuideModel.singleton.NowTaskId = 6005; GuideModel.singleton.bIsSelfSpeaked = true; EventDispatch.Broadcast(Events.DlgGuideExecuteNextTask); } }); } }
// Called by Doors, to initialise the transition of the player between rooms // public static void BeginRoomTransition(ref GameObject goRoomFrom, ref GameObject goRoomTo) { GAssert.Assert(null != goRoomTo, "BeginRoomTransition called from a Door that's not setup with two rooms!"); GameInstance gcGameInstance = GameInstance.Object; // Play Some Audio gcGameInstance.GetAudioManager().PlayAudio(EGameSFX._SFX_MISC_ROOM_TRANSITION); // Do the transition (Camera is responsible for calling Begin/EndRoomTransition!) { gcGameInstance.GetPlayerState().LockPlayer(); gcGameInstance.GetPlayerController().BeginRoomTransition(); gcGameInstance.GetGameCamera().BeginRoomTransition(goRoomTo.transform.position); ; } // NOTE: Order is important here! OnRoomEnter may want to calculate it's origin, which // will only be accurate AFTER Camera.BeginRoomTransition! // // Every room MUST have a room controller attached, even if there's no logic! // Doorways assume this, and it simplifies the logic here... // { m_gcActiveRoomController.OnRoomExit(); m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!"); m_gcActiveRoomController.OnRoomEnter(); } // The player takes longer to transition than the camera does, and we know the duration, so set a timer TimerManager.AddTimer(Types.s_fPLAYER_RoomTransitionDuration, EndRoomTransition); }
public static void WarpPlayerToLevel2() { GameObject goRoomTo = GameObject.Find(Types.s_sRC_LevelTwoRoomController); GAssert.Assert(null != goRoomTo, "GameInstance unable to find the level 2 room controller!"); GameInstance gcGameInstance = GameInstance.Object; Messenger.Invoke(Types.s_sGF_BeginRoomTransition); // Transition (Camera is NOT responsible for calling Begin/EndRoomTransition!) { gcGameInstance.GetPlayerController().BeginTeleport(); gcGameInstance.GetGameCamera().BeginTeleport(goRoomTo.transform.position); } // Let the rooms cleanup... { m_gcActiveRoomController.OnRoomExit(); m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!"); m_gcActiveRoomController.OnRoomEnter(); } TimerManager.AddTimer(2f, EndWarpToLevel2); }
// Called on first entry into a new scene (level), just after load. // Searches through every gameobject in the scene, so shouldn't be used in // any other circumstance! // // It is assumed that every scene will have an initial RoomController on a game // object called: "ROOM_SpawnRoom" // public static void TransitionToDefaultRoom() { // Flag for the pause/UI controls that we're in-game. // Order is important! OnRomEnter() might immediately set this back to false! // GNTODO: it probably does in all cases... Remove this when Cecconoid handles it properly m_bCanPause = true; // SUPER DUPER SLOW! GameObject goRoomTo = GameObject.Find(Types.s_sRC_DefaultRoomController); GAssert.Assert(null != goRoomTo, "GameInstance unable to find the default room controller in this level!"); // Init the first room! m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>(); GAssert.Assert(null != m_gcActiveRoomController, "No room controller on the default room gameobject!"); m_gcActiveRoomController.OnRoomEnter(); // Because there's always a transition in (Spawn Effect, of screen roll) Player reset needs to delay // The rc_RobotronController in Eugatron scene handles all this for us, though... if (GameInstance.Object.m_bIsCecconoid) { TimerManager.AddTimer(2f, EndTransitionToDefaultRoom); } }
public virtual void LeaveLevel() { collider2d.enabled = false; if (this is EntityMyself) { //游戏结束 TimerManager.AddTimer(2000, 0, () => { PlayerManager.singleton.OverGame(); this.Clear(); }); return; } PlayerManager.singleton.allVisiableMonster.Remove(this); TimerManager.AddTimer(4000, 0, () => { PlayerManager.singleton.curWaveDicEntitys[LevelManager.singleton.curWaveIndex].Remove(EntityId); if (!PlayerManager.singleton.curWaveDicEntitys.ContainsKey(LevelManager.singleton.curWaveIndex)) { Debug.LogError("Error:" + LevelManager.singleton.curWaveIndex); } if (PlayerManager.singleton.curWaveDicEntitys[LevelManager.singleton.curWaveIndex].Count == 0) { PlayerManager.singleton.EndWave(); } this.Clear(); }); }
public void TurnOn() { m_bIsOn = true; m_bIsWaiting = false; // By pushing event time backwards we're offsetting the initial // position of the laser in it's arc... Only need to do this // the first time we turn the laser on... m_fEventTime = TimerManager.fGameTime - m_fRatioOffset; m_fRatioOffset = 0; if (null != m_goEndPointParticlePrefab) { m_goEndPointParticles = Instantiate(m_goEndPointParticlePrefab, transform.position, Quaternion.identity); m_goEndPointParticles.GetComponent <ParticleSystem>().Play(); } if (m_bHasAudio) { m_gcAudio.Play(); } // Timer lasts for a couple of frames too long, to ensure the PingPong (m_bIsForward) gets flipped in Update() if (m_bHasTimer) { m_iTimerHandle = TimerManager.AddTimer(m_fArcTrackingDuration + (TimerManager.fGameDeltaTime * 2), TurnOff); } }
/// <summary> /// 设置跳字 /// </summary> public static void SetJumpText(string content) { ResourceManager.Instance.LoadPrefab("jumpLabel", (name, obj) => { obj.AddComponent <TextDestroy>(); obj.GetComponent <UILabel>().text = content; Transform tparent = UICamera.mainCamera.transform; obj.transform.SetParent(tparent); obj.transform.localScale = Vector3.one; jumpList.Insert(0, obj); TweenScale.Begin(obj, 0.1f, new Vector3(1.16f, 1.16f, 1.16f)); index++; TimerManager.AddTimer("index" + index, 0.1f, OnScaleFinished, obj); if (jumpList.Count > 1) { TweenPosition.Begin(jumpList[1].gameObject, 0.1f, jumpList[1].transform.localPosition + pos); TweenScale.Begin(jumpList[1].gameObject, 0.1f, new Vector3(0.9f, 0.9f, 0.9f)); } if (jumpList.Count > 2) { TweenPosition.Begin(jumpList[2].gameObject, 0.1f, jumpList[2].transform.localPosition + pos); TweenScale.Begin(jumpList[2].gameObject, 0.1f, new Vector3(0.8f, 0.8f, 0.8f)); } if (jumpList.Count > 3) { MonoBehaviour.Destroy(jumpList[3].gameObject); jumpList.RemoveAt(3); } }); }
public void RequestServerState() { string ipInfo = "127.0.0.1";// Config.GetUpdaterConfig("StateServerPath", "Value"); if (string.IsNullOrEmpty(ipInfo)) { //状态服务器地址没有配置/ LogSystem.LogError("RequestServerState --> ipinfo not in config!"); return; } string[] ipinfoStrs = UtilTools.Split(ipInfo, ':'); if (ipinfoStrs.Length < 3) { LogSystem.LogError("RequestServerState -->ipinfo config Error"); return; } ip = ipinfoStrs[0]; port = UtilTools.IntParse(ipinfoStrs[1]); issuerId = UtilTools.IntParse(ipinfoStrs[2]); ServerStateSock sock = new ServerStateSock(OnTextSockConnected, OnTextSockConnectFailed, OnTextSockRecieveData); if (sock != null) { sock.Connect(ip, port); } dataIsReady = false; TimerManager.AddTimer("StateReqOverTime", 10f, StateReqListener); //#endif }
void Start() { UnityEngine.Cursor.visible = true; GameInstance.Object.GetGameOverScreen().OnHideInstant(); GameInstance.Object.GetMainMenuCecconoid().OnShow(); m_iTimerHandle = TimerManager.AddTimer(1f / Types.s_fDUR_MenuFadeSpeed, EnterMainMenu); }
protected virtual void UpdateAnimFrame() { switch (m_iDir) { case EAnimDirection._FORWARD: { ++m_iCurrentFrame; if (m_iCurrentFrame == m_aAnimationFrames.Length) { --m_iCurrentFrame; m_iDir = EAnimDirection._BACKWARD; } } break; case EAnimDirection._BACKWARD: { --m_iCurrentFrame; if (m_iCurrentFrame < 0) { m_iCurrentFrame = 0; m_iDir = EAnimDirection._FORWARD; } } break; } m_gcRenderer.sprite = m_aAnimationFrames[m_iCurrentFrame]; m_iTimerHandle = TimerManager.AddTimer(m_fDeltaFPS, UpdateAnimFrame); }
// GameInstance will call this when the player passes through a doorway, // initiating the transition between two rooms... // // For us, it's the start of the little mini game, so we need to verify // our settings and then begin spawning in waves... // public override void OnRoomEnter() { // When the game is finished we set a GameEvent so this mini-game can't be repeated switch (m_iEvent) { case ERobotronEvents._RB1_IckleBaddies: m_iEventBitField = Types.s_iGE_RobotronTest; break; case ERobotronEvents._RB2_Enforcers: m_iEventBitField = Types.s_iGE_Robotron2; break; case ERobotronEvents._RB3_FloatingLaserBrains: m_iEventBitField = Types.s_iGE_Robotron3; break; case ERobotronEvents._RB4_LoadsaBaddies: m_iEventBitField = Types.s_iGE_Robotron4; break; case ERobotronEvents._RB5_CircularShotTwats: m_iEventBitField = Types.s_iGE_Robotron5; break; } // If we've already completed this room, do nothing! if (GameGlobals.TestGameEvent(m_iEventBitField)) { return; } // Spawn in the warning Prefab... if (null != m_goWarningPrefab) { Instantiate(m_goWarningPrefab, transform.position, Quaternion.identity); } // Validate what we need { GAssert.Assert(null != m_SpawnSet._goEnemyPrefab, "Robotron Room Controller has no Enemy Prefab Assigned!"); GAssert.Assert(null != m_SpawnSet._goSpawnInEffect, "Robotron Room Controller has Spawn In Effect"); GAssert.Assert(null != m_SpawnSet._goSpawnWarningEffect, "Robotron Room Controller has Spawn Warning Prefab"); GAssert.Assert(null != m_SpawnSet._goSpawnWarningEffectShort, "Robotron Room Controller missing spawn effect short"); } // Init any additional objects, these aren't tracked as part of the unlock sequence { foreach (GameObject go in m_aAdditionalObjects) { if (null == go) { continue; } go.SetActive(true); Types.IRoom_EnemyObject[] aGC = go.GetComponents <Types.IRoom_EnemyObject>(); foreach (Types.IRoom_EnemyObject gc in aGC) { gc.OnRoomEnter(); } } } m_vRoomOrigin = GameMode.GetRoomOrigin(); m_aRoomObjects = new GameObject[m_iEnemiesToSpawn * m_iNumberOfWaves]; m_bIsActive = true; // Wait for the door to shut before we kick things off... m_iTimerHandle = TimerManager.AddTimer(Types.s_fDUR_RoomEntryDoorCloseDelay + 0.35f, FinaliseRoomEntry); }
public void ShowEntity(EntityParent entity, Vector3 pos, float duration = 0) { entity.Transform.position = pos; if (entity != null) { if (duration > 0) { this.AllDuration += (uint)(duration * 1000); this.timer.Add(TimerManager.AddTimer(this.AllDuration, 0, () => { entity.SetVisiable(true); if (entity.entityActor == null) { Debug.LogError("fwefefef:" + entity.EntityId); } entity.entityActor.Move(); allVisiableMonster.Add(entity); })); } else { entity.SetVisiable(true); if (entity is EntityMonster) { allVisiableMonster.Add(entity); } if (entity.entityActor != null) { entity.entityActor.Move(); } } } }
public Task AddHeartbeat(Nuid id, string timer, long gap_millseconds, int count, NEventCallback handler) { TimerManager.AddTimer(id, timer, gap_millseconds, count, handler); CheckTimer(); return(Task.CompletedTask); }
// Cycle through the stored spawn positions and instantiate one of our enemy prefabs // public void FinaliseWaveSpawning() { if (!m_bIsActive) { return; } for (int i = 0; i < m_iEnemiesToSpawn; ++i) { m_aRoomObjects[m_iWaveNumber * m_iEnemiesToSpawn + i] = Instantiate(m_SpawnSet._goEnemyPrefab, m_aSpawnPositions[i], Quaternion.identity); foreach (EnemyObjectBase gc in m_aRoomObjects[m_iWaveNumber * m_iEnemiesToSpawn + i].GetComponents <EnemyObjectBase>()) { gc.OnRoomEnter(); } foreach (Types.IRoom_EnemyObject eo in m_aRoomObjects[m_iWaveNumber * m_iEnemiesToSpawn + i].GetComponents <Types.IRoom_EnemyObject>()) { eo.OnRoomEnter(); } } // If we have waves left to spawn, do so ++m_iWaveNumber; if (m_iWaveNumber < m_iNumberOfWaves) { m_iTimerHandle = TimerManager.AddTimer(m_fWaveDelay, SpawnWave); } // Record when this happened, so we can spawn the next wave at the right time // even when the player dies in the middle... m_fLastEventTime = TimerManager.fGameTime; }
void CreateRewardItem() { if (rewardIndex == rewardList.Count - 1) { m_Panel.Mask.GetComponent <BoxCollider>().enabled = true; return; } string itemID = rewardList[rewardIndex] as string; ItemInfo info = ItemManager.GetItemInfo(itemID); GameObject go = GameObject.Instantiate(PoolManager.PopPrefab(PoolManager.PoolKey.Prefab_RewardItem).gameObject); go.transform.parent = m_Panel.getReward.transform; go.transform.localScale = Vector3.zero; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.GetComponent <UISprite>().spriteName = "color" + info.color; LoadSprite.LoaderItem(go.GetComponentInChildren <UITexture>(), itemID, false); go.gameObject.SetActive(true); TweenScale.Begin(go, 0.02f, Vector3.one); if (rewardIndex <= 4) { TweenPosition.Begin(go, 0.02f, new Vector3(-230 + rewardIndex * 130, 90, 0)); } else { TweenPosition.Begin(go, 0.02f, new Vector3(-230 + (rewardIndex - 5) * 130, -35, 0)); } rewardIndex++; TimerManager.AddTimer("rewardIndex", 0.2f, CreateRewardItem); }
public void OnRoomEnter() { if (m_bIsOn) { return; } // If we want the lasers offset by a certain percentage (to avoid chorus lining) // then ArcTrackingOffsetPercent is the lever. See TurnOn() // NOTE: Use StartOffsetSeconds if you want to de-sync the timings, this DOESN'T // affect the timer, only the position in the arc m_fRatioOffset = m_fArcTrackingDuration * m_fArcTrackingOffset; // GNTODO: Race conditon here if the player can exit the room before StartOffset expires // RoomControllerBase should store Room Entry time so we can compare durations and // clear offset timers without extra flags in each class... // // Or, just clear the timer and accept it might not always exist... (<-- Do this!) if (m_fStartOffsetSeconds > 0.0f) { m_bIsWaiting = true; m_iTimerHandle = TimerManager.AddTimer(m_fStartOffsetSeconds, TurnOn); } else { TurnOn(); } }
public Task AddCountdown(Nuid id, string timer, long over_millseconds, NEventCallback handler) { TimerManager.AddTimer(id, timer, over_millseconds, handler); CheckTimer(); return(Task.CompletedTask); }
// This is a delegate that TimerManager will call when the gun's m_fFiringPauseSeconds // has elapsed. It spawns a new bullet, sets its trajectory and then sets a new timer // for the next shot... // virtual public void Fire() { if (m_bCanFire) { // Bullet spawn position is gun's position, plus a definable distance, offset in the direction of fire... Vector3 vSpawnPos = (transform.position + m_vGunPositionOffset) + (new Vector3(m_vFireDirection.x, m_vFireDirection.y, 0.0f) * m_fBulletSpawnOffset); // Spawn the bullet { if (m_aBulletPool[m_iPoolIndex].activeSelf) { Debug.LogError(gameObject.name + ": Bullet Pool overrun!"); } m_aBulletPool[m_iPoolIndex].SetActive(true); m_aBulletPool[m_iPoolIndex].transform.position = vSpawnPos; m_aBulletPool[m_iPoolIndex].GetComponent <BulletMovement>().InitBullet(m_vFireDirection, m_fBulletSpeed); ++m_iPoolIndex; if (m_iPoolIndex >= m_iBulletPoolSize) { m_iPoolIndex = 0; } } // Set a timer for the next shot... m_iTimerHandle = TimerManager.AddTimer(m_fFiringPauseSeconds, Fire); } }
private static int AddTimer(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 5); TimerManager timerManager = (TimerManager)ToLua.CheckObject(L, 1, typeof(TimerManager)); GameObject go = (GameObject)ToLua.CheckUnityObject(L, 2, typeof(GameObject)); string timerName = ToLua.CheckString(L, 3); float delay = (float)LuaDLL.luaL_checknumber(L, 4); LuaTypes luaTypes = LuaDLL.lua_type(L, 5); TimerManager.UpdateFunc func; if (luaTypes != LuaTypes.LUA_TFUNCTION) { func = (TimerManager.UpdateFunc)ToLua.CheckObject(L, 5, typeof(TimerManager.UpdateFunc)); } else { LuaFunction func2 = ToLua.ToLuaFunction(L, 5); func = (DelegateFactory.CreateDelegate(typeof(TimerManager.UpdateFunc), func2) as TimerManager.UpdateFunc); } timerManager.AddTimer(go, timerName, delay, func); result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
public void TurnOff() { TurnOffInstant(); if (m_bHasTimer) { m_iTimerHandle = TimerManager.AddTimer(m_fTimeOff, TurnOn); } }
public void BeginTransitionToGameSelect() { GameInstance.Object.GetMainMenuCecconoid().OnHide(); GameInstance.Object.GetCompletionSequence().OnHideInstant(); Messenger.RemoveListener(Types.s_sMenu_BeginTransitionToGame, BeginTransitionToGame); Messenger.RemoveListener(Types.s_sMenu_ExitToSelect, BeginTransitionToGameSelect); TimerManager.AddTimer(1f, EndTransitionToGameSelect); }
static void Main(string[] args) { TimerManager manager = new TimerManager(); Timer timer = new Timer(manager); AnotherTimer anotherTimer = new AnotherTimer(manager); manager.AddTimer(5000, "efewsf", "wefewfew"); }
public override void OnRoomEnter() { base.OnRoomEnter(); if (!GameGlobals.TestGameEvent(Types.s_iGE_FirstBrains) && !m_gcDoorLeft.GetIsClosed()) { TimerManager.AddTimer(Types.s_fDUR_DoorCloseDuration, CloseDoorsFirstEntry); } }
//SOLO PER SAPERE QUANDO INIZIA L'ONDATA NULLA DI PIU' public void StartEnemyWave(TimerManager timerManagerParam) { actualAmount = 0; timerManager = timerManagerParam; allTimer = new Timer(initialDelay, false); timerManager.AddTimer(allTimer); allTimer.TimerEnded += EnemyWaveHasToSpawn; }