public override void OnEndDrag(PointerEventData eventData) { if (Status.REFRESH == state) { return; } base.OnEndDrag(eventData); if (Status.PULL == state) { refreshTip.pullTip.SetActive(false); refreshTip.releaseTip.SetActive(false); refreshTip.refreshTip.SetActive(true); state = Status.REFRESH; if (null != onTriggerRefresh) { CoroutineMgr.Start(delayOneSecond(() => { onTriggerRefresh(); })); } } else { refreshTip.root.SetActive(false); } }
public override Vector2 GetNextWaypointPos() { if (isHitting || isCooldown) { return(transform.position); } if (playerInRange) { Vector2 moveDir = (Vector2)player.transform.position - (Vector2)transform.position; moveDir.y = 0; moveDir = moveDir.normalized; // If enemy isn't moving in the same direction, wait if (!Utils.SameSign(moveDir.x, lastMoveDir.x)) { CoroutineMgr.Start(StartCooldown(0.25f)); } lastMoveDir = moveDir; Vector2 testLoc = (Vector2)testPoint.transform.position + moveDir; Collider2D Col = Physics2D.OverlapPoint(testLoc); if (Col == null || Col.isTrigger) { return(transform.position); } return(player.transform.position); } return(base.GetNextWaypointPos()); }
public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish) { string cache_asset = ""; if (!_params.TryGetValue("cache_asset", out cache_asset)) { Log.Error("Play2D", "need params cache_asset"); return; } string track = ""; if (!_params.TryGetValue("track", out track)) { Log.Error("Play2D", "need params track"); return; } int track_ = int.Parse(track); try { byte[] bytes = UGCMgr.Take(cache_asset); AudioClip clip = UGC.Audio.WAVUtil.BuildAudioClip(bytes); CoroutineMgr.Start(play2DSound(clip, track_, _onFinish)); } catch (System.Exception e) { Log.Error("Play2dSound", "Parse json hsa error:" + e.Message); } }
//SVMAPI public static void Play(string _cache_asset, int _track, SVMAPI.FinishDelegate _onFinish) { try { byte[] bytes = UGCMgr.Take(_cache_asset); AudioClip clip = UGC.Audio.WAVUtil.BuildAudioClip(bytes); CoroutineMgr.Start(play2DSound_SVMAPI(clip, _track, _onFinish)); } catch (System.Exception e) { Log.Error("Play2dSound", "Parse json hsa error:" + e.Message); } }
private static void punchRotation(GameObject _go, Vector3 _position, float _duration, ActionDelegate _onFinish) { Hashtable hash = new Hashtable(); hash.Add("amount", _position); hash.Add("time", _duration); iTween.PunchRotation(_go, hash); CoroutineMgr.Start(wait(_duration, () => { _onFinish(); })); }
public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish) { string package = ""; if (!_params.TryGetValue("package", out package)) { Log.Error("Play2D", "need params package"); return; } string file = ""; if (!_params.TryGetValue("file", out file)) { Log.Error("Play2D", "need params file"); return; } string track = ""; if (!_params.TryGetValue("track", out track)) { Log.Error("Play2D", "need params track"); return; } int track_ = int.Parse(track); try { ResourceMgr.LoadAudioClip(package, file, track_ , () => { Log.Debug("Play2D", "ready"); } , (_audioclip) => { AudioClip clip = _audioclip as AudioClip; CoroutineMgr.Start(play2DSound(clip, track_, _onFinish)); } , (_error) => { Log.Error("Play2D", _error); }); } catch (System.Exception e) { Log.Error("Play2dSound", "Parse json hsa error:" + e.Message); } }
public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish) { string duration = "0"; if (!_params.TryGetValue("duration", out duration)) { Log.Error("ActionMgr", "need params duration"); return; } float timer = float.Parse(duration); CoroutineMgr.Start(sleep(timer, _onFinish)); }
private static void scaleTo(GameObject _go, Vector3 _scale, float _duration, ActionDelegate _onFinish) { Hashtable hash = new Hashtable(); hash.Add("easeType", iTween.EaseType.linear); hash.Add("scale", _scale); hash.Add("time", _duration); iTween.ScaleTo(_go, hash); CoroutineMgr.Start(wait(_duration, () => { _onFinish(); })); }
private static void lookFrom(GameObject _go, Vector3 _position, float _duration, ActionDelegate _onFinish) { Hashtable hash = new Hashtable(); hash.Add("easeType", iTween.EaseType.linear); hash.Add("looktarget", _position); hash.Add("time", _duration); iTween.LookFrom(_go, hash); CoroutineMgr.Start(wait(_duration, () => { _onFinish(); })); }
private static void rotateAdd(GameObject _go, Vector3 _rotation, float _duration, ActionDelegate _onFinish) { Hashtable hash = new Hashtable(); hash.Add("easeType", iTween.EaseType.linear); hash.Add("amount", _rotation); hash.Add("time", _duration); iTween.RotateAdd(_go, hash); CoroutineMgr.Start(wait(_duration, () => { _onFinish(); })); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == Tags.Player) { collision.gameObject.GetComponent <PlayerController>()?.OnPortalEnter(); Destroy(collision.gameObject); GameObject partObj = ObjectPool.Alloc(PortalParticles); partObj.transform.position = transform.position; partObj.transform.rotation = transform.rotation; CoroutineMgr.Start(WaitAndLoadNextLevel()); } }
public override void OnDie() { AudioManager.PlaySfx(AudioEffects.PlayerDie); SpawnParticles(deathParticle); Gib.SpawnRandomGibs(transform.position, 5); GameGUI?.SetRickHealth(0); GameGUI?.AddScore(-10); gameObject.SetActive(false); vcam.enabled = false; // TODO: Coroutines //Respawn(); //StartCoroutine(DelayAndRespawn()); CoroutineMgr.Start(DelayAndRespawn()); }
public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish) { string durationStr = ""; if (!_params.TryGetValue("duration", out durationStr)) { Log.Error("Move", "need params duration"); return; } float duration = float.Parse(durationStr); try { CoroutineMgr.Start(move(duration, _onFinish)); } catch (System.Exception e) { Log.Error("VRPushByTime", "Parse json has error: " + e.Message); } }
public static void SpawnRandomGib(Vector2 Pos) { if (!Enabled) { return; } if (GibPrefabs == null) { GibPrefabs = Resources.LoadAll <GameObject>("Prefabs/Gibs"); } GameObject gibInstance = ObjectPool.Alloc(Utils.Random(GibPrefabs)); gibInstance.transform.position = Pos; Rigidbody2D body2d = gibInstance.GetComponent <Rigidbody2D>(); body2d.velocity = Utils.NormalFromAngle(135 - Utils.RandomFloat() * 90) * 5; CoroutineMgr.Start(gibInstance.GetComponent <Gib>().WaitAndFree()); }
public override void OnUpdate() { base.OnUpdate(); float distance = float.PositiveInfinity; if (player?.activeInHierarchy ?? false) { distance = Vector2.Distance(transform.position, player.transform.position); } playerInRange = distance < followRadius; playerInHitRng = distance < hitRange; anim.SetFloat("Speed", Mathf.Abs(body2d.velocity.x)); if (playerInHitRng && !isHitting) { anim.SetBool("canHit", true); isHitting = true; CoroutineMgr.Start(WaitAndStopHitting()); } }
//SVMAPI public static void Play(string _package, string _file, int _track, SVMAPI.FinishDelegate _onFinish) { try { ResourceMgr.LoadAudioClip(_package, _file, _track , () => { Log.Debug("Play2D", "ready"); } , (_audioclip) => { AudioClip clip = _audioclip as AudioClip; CoroutineMgr.Start(play2DSound_SVMAPI(clip, _track, _onFinish)); } , (_error) => { Log.Error("Play2D", _error); }); } catch (System.Exception e) { Log.Error("Play2dSound", "Parse json hsa error:" + e.Message); } }
public override void OnUpdate() { if (GameGUI?.IsPaused() ?? false) { return; } horizontalMoveInput = Input.GetAxisRaw("Horizontal"); anim.SetFloat("Speed", Mathf.Abs(horizontalMoveInput)); anim.SetBool("Shooting", false); bool isNowGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround); if (isNowGrounded && !isGrounded) { CoroutineMgr.Start(PlayLandSfxIfAlive()); } isGrounded = isNowGrounded; if (horizontalMoveInput > 0) { rnd.flipX = true; lookDir = new Vector2(1, 0); } else if (horizontalMoveInput < 0) { rnd.flipX = false; lookDir = new Vector2(-1, 0); } if (isGrounded == true && Input.GetButtonDown("Jump")) { isJumping = true; AudioManager.PlaySfx(AudioEffects.PlayerJump); anim.SetBool("isJumping", isJumping); jumpTimeCounter = jumpTime; body2d.velocity = Vector2.up * jumpForce; } if (Input.GetButton("Jump") && isJumping == true) { if (jumpTimeCounter > 0) { body2d.velocity = Vector2.up * jumpForce; jumpTimeCounter -= Time.deltaTime; } else { isJumping = false; anim.SetBool("isJumping", isJumping); } } if (Input.GetButtonUp("Jump")) { isJumping = false; anim.SetBool("isJumping", isJumping); } if (Input.GetButton("Fire1")) { if (nextFireTime <= Time.time) { nextFireTime = Time.time + fireRatePause; FireGun(lookDir); } } if (Input.GetKeyDown(KeyCode.Escape)) { GameGUI?.ShowMainMenu(true); } // TODO: Update the score and time here int TimeLeft = GetPlayerTimeLeft(); GameGUI?.SetRickHealth(health); GameGUI?.SetTime(TimeLeft); if (TimeLeft <= 0 && health > 0) { OnReceiveDamage(9999); } }