void LateUpdate() { // check left bound. if (transform.position.x - (spriteWidth / 2 - leftOffset) < leftBound) { transform.SetPositionX(leftBound + (spriteWidth / 2 - leftOffset)); } // check right bound. if (transform.position.x + (spriteWidth / 2 - rightOffset) > rightBound) { transform.SetPositionX(rightBound - (spriteWidth / 2 - rightOffset)); } // check upper bound. if (transform.position.y + (spriteHeight - upperOffset) > upperBound) { transform.SetPositionY(upperBound - (spriteHeight - upperOffset)); } // check lower bound. if (transform.position.y - lowerOffset < lowerBound) { transform.SetPositionY(lowerBound - lowerOffset); EventKit.Broadcast <int, Weapon.WeaponType>("player dead", -1, Weapon.WeaponType.OutOfBounds); } }
public void TakesHit(Hit hit) { player.HP -= (hit.weapon.damage * diffDamageModifier); //params for ShakeCamera = duration, strength, vibrato, randomness EventKit.Broadcast("shake camera", .5f, .3f, 20, 5f); EventKit.Broadcast("reduce hp", player.HP); if (hit.horizontalSide == Side.Right) { gameObject.SendEventDown("RepulseToLeft", 5.0F); } else { gameObject.SendEventDown("RepulseToRight", 5.0F); } if (player.HP > 0) { fadeWhenHit.Restart(); } else { OnPlayerDead(hit); EventKit.Broadcast("player dead", hit); } }
void Update() { float h; h = playerControls.GetAxisRaw("Move Horizontal"); if (h > 0) { creature.MoveRight(); } if (h < 0) { creature.MoveLeft(); } if (playerControls.GetButtonDown("Jump")) { creature.Jump(); } if (playerControls.GetButtonDown("Attack")) { creature.Attack(); } if (playerControls.GetButtonDown("Next Weapon")) { EventKit.Broadcast <int>("switch weapon", RIGHT); } }
public void TakesHit(Hit hit) { player.HP -= (int)(hit.weapon.damage * diffDamageModifier); //params for ShakeCamera = duration, strength, vibrato, randomness EventKit.Broadcast <float, float, int, float>("shake camera", .5f, .3f, 20, 5f); EventKit.Broadcast <int>("reduce hp", player.HP); if (hit.hitFrom == RIGHT) { BroadcastMessage("RepulseToLeft", 5.0F); } else { BroadcastMessage("RepulseToRight", 5.0F); } if (player.HP > 0) { MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f); } else { EventKit.Broadcast <int, Weapon.WeaponType>("player dead", hit.hitFrom, hit.weaponType); } }
public void TakesProjectileHit(Weapon incomingWeapon, Collider2D coll) { if (!dead) { var hitSide = M.HorizontalSideHit(gameObject, coll); hp -= (incomingWeapon.damage); if (hitSide == RIGHT && !blockedLeft) { } else if (hitSide == LEFT && !blockedRight) { } else { rigidbody2D.velocity = Vector2.zero; } if (hp <= 0) { EventKit.Broadcast("prize collected", worth); KillSelf(hitSide, PROJECTILE); } } }
public virtual void Clear(NoteGrade grade) { if (IsCleared || grade == NoteGrade.Undetermined) { return; } IsCleared = true; Game.OnClear(this); View.OnClear(grade); if (!(Game.Instance is StoryboardGame)) { StartCoroutine(DestroyLater()); } if (TimeUntilEnd > -5) // Prevent storyboard seeking { EventKit.Broadcast("note clear", this); } // Hit sound if (grade != NoteGrade.Miss && (!(this is HoldNote) || !PlayerPrefsExt.GetBool("early hit sounds"))) { PlayHitSound(); } // gameObject.GetComponent<SpriteRenderer> ().material.SetFloat("_HRate", 1.0f); // Animation speed = 1.0f; }
void OnPlayerDead(int hitFrom, Weapon.WeaponType weaponType) { gameData.CurrentScore = gameData.LastSavedScore; gameData.Lives -= 1; EventKit.Broadcast <bool>("fade hud", true); EventKit.Broadcast <int>("load level", gameData.CurrentLevel); }
void PlatformSpecificUpdate() { float h; h = Input.GetAxisRaw("Horizontal"); if (h > 0) { creature.MoveRight(); } if (h < 0) { creature.MoveLeft(); } if (Input.GetButtonDown("Jump")) { creature.Jump(); } if (Input.GetButtonDown("Attack")) { creature.Attack(); } if (Input.GetButtonDown("Switch")) { EventKit.Broadcast("switch weapon", Side.Right); } }
void OnPlayerDead(Hit incomingHit) { gameData.CurrentScore = gameData.LastSavedScore; gameData.Lives -= 1; EventKit.Broadcast("fade hud", true); EventKit.Broadcast("load level", gameData.CurrentLevel); }
void OnLevelCompleted(bool status) { gameData.LastSavedScore = gameData.CurrentScore; gameData.CurrentLevel = gameData.CurrentLevel; EventKit.Broadcast("fade hud", true); EventKit.Broadcast("load level", gameData.CurrentLevel); }
public void SwitchRankedMode() { if (isLoggingIn) { Popup.Make(this, "Now signing in, please wait..."); return; } if (OnlinePlayer.Authenticated) { var ranked = PlayerPrefsExt.GetBool("ranked", false); ranked = !ranked; PlayerPrefsExt.SetBool("ranked", ranked); rankStatusText.text = ranked ? "On" : "Off"; UpdateBestText(); if (ranked && !PlayerPrefsExt.GetBool("dont_show_what_is_ranked_mode_again", false)) { UIManager.ShowUiElement("WhatIsRankedModeBackground", "MusicSelection"); UIManager.ShowUiElement("WhatIsRankedModeRoot", "MusicSelection"); } if (ranked) { EventKit.Broadcast("reload rankings"); } } else { UIManager.ShowUiElement("LoginRoot", "MusicSelection"); UIManager.ShowUiElement("LoginBackground", "MusicSelection"); } }
public void OnProfilePressed() { if (isLoggingIn) { Popup.Make(this, "Now signing in, please wait..."); return; } if (OnlinePlayer.Authenticated) { if (UIManager.GetUiElements("ProfileRoot", "MusicSelection")[0].isVisible) { UIManager.HideUiElement("ProfileRoot", "MusicSelection"); UIManager.HideUiElement("ProfileBackground", "MusicSelection"); } else { UIManager.ShowUiElement("ProfileRoot", "MusicSelection"); UIManager.ShowUiElement("ProfileBackground", "MusicSelection"); EventKit.Broadcast("reload player rankings"); } } else { UIManager.ShowUiElement("LoginRoot", "MusicSelection"); UIManager.ShowUiElement("LoginBackground", "MusicSelection"); } }
void TakesProjectileHit(Weapon playerWeapon, Collider2D coll, int hitFrom) { if (!dead) { hp -= (int)(playerWeapon.damage); // bounceback from projectile if (hitFrom == RIGHT && !blockedLeft) { // rigidbody2D.AddForce(new Vector3(-100, 0, 0)); MFX.RepulseToLeftRandomly(transform, .3f, .8f, .2f); } else if (hitFrom == LEFT && !blockedRight) { // rigidbody2D.AddForce(new Vector3(100, 0, 0)); MFX.RepulseToRightRandomly(transform, .3f, .8f, .2f); } else { rigidbody2D.velocity = Vector2.zero; } if (hp <= 0) { EventKit.Broadcast <int>("prize collected", worth); KillSelf(hitFrom, PROJECTILE); } } }
void TakesMeleeHit(Weapon playerWeapon, Collider2D coll, int hitFrom) { if (!dead) { hp -= (int)(playerWeapon.damage); // bounceback from projectile if (hitFrom == RIGHT && !blockedLeft) { MFX.RepulseToLeftRandomly(transform, repulseMin, repulseMax, repulseTime); } else if (hitFrom == LEFT && !blockedRight) { MFX.RepulseToRightRandomly(transform, repulseMin, repulseMax, repulseTime); } else { rigidbody2D.velocity = Vector2.zero; } if (hp <= 0) { EventKit.Broadcast <int>("prize collected", worth); KillSelf(hitFrom, MELEE); } } }
public override void InteractWith(GameObject character) { ClosePopup(); var pack = Object.Instantiate(prefab, transform.position + ( Vector3 )genOffset, Quaternion.identity); EventKit.Broadcast(GlobalSymbol.EVT_ExpressPackageGenerated, pack); }
void Init() { EventKit.Broadcast("init lvl", player.LVL); EventKit.Broadcast("init hp", player.HP); EventKit.Broadcast("init ac", player.AC); EventKit.Broadcast("init xp", player.XP); EventKit.Broadcast("init weapons", player.equippedWeapon, player.leftWeapon, player.rightWeapon); }
void Start() { gameData = GameObject.Find(_DATA).GetComponent <GameData>(); Assert.IsNotNull(gameData); EventKit.Broadcast("init score", gameData.CurrentScore); EventKit.Broadcast("set difficulty", NORMAL); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.layer == PLAYER_DEFAULT_LAYER) { pickupWeapon.Restart(); EventKit.Broadcast("prize collected", transform.parent.GetComponent <Weapon>().worth); EventKit.Broadcast("equip new weapon", transform.parent.gameObject); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.layer == PLAYER_COLLIDER) { MFX.PickupWeapon(gameObject); EventKit.Broadcast <int>("prize collected", transform.parent.GetComponent <Weapon>().worth); EventKit.Broadcast <GameObject>("equip new weapon", transform.parent.gameObject); } }
void CheckForSizeChange() { if (Screen.width != currentScreenWidth || Screen.height != currentScreenHeight) { vertExtent = Camera.main.GetComponent <Camera>().orthographicSize; horizExtent = vertExtent * Screen.width / Screen.height; EventKit.Broadcast <float, float>("screen size changed", vertExtent, horizExtent); } }
void CheckForSizeChange() { if (Screen.width != currentScreenWidth || Screen.height != currentScreenHeight) { vertExtent = camera.orthographicSize; horizExtent = vertExtent * Screen.width / Screen.height; EventKit.Broadcast("screen size changed"); } }
void OnTriggerExit2D(Collider2D coll) { layer = coll.gameObject.layer; coll.transform.parent = null; if (layer == PLAYER_COLLIDER && fastPlatform) { EventKit.Broadcast <bool>("player riding fast platform", false); } }
public IEnumerator LoginCoroutine() { if (OnlinePlayer.Authenticated || !PlayerPrefs.HasKey(PreferenceKeys.LastUsername()) || !PlayerPrefs.HasKey(PreferenceKeys.LastPassword())) { isLoggingIn = false; yield break; } // If not logged in previously yield return(OnlinePlayer.Authenticate()); CloseLoginWindows(); isLoggingIn = false; var authenticationResult = OnlinePlayer.LastAuthenticationResult; switch (authenticationResult.status) { case 0: Popup.Make(this, "Signed in."); rankStatusText.text = PlayerPrefsExt.GetBool("ranked") ? "On" : "Off"; StartCoroutine(LoadAvatarCoroutine()); if (PlayerPrefsExt.GetBool("ranked")) { EventKit.Broadcast("reload rankings"); } BestScoreText.WillInvalidate = true; break; case -1: LoadedAvatar = true; Popup.Make(this, "Could not fetch player data."); break; case 1: // User not exist LoadedAvatar = true; Popup.Make(this, authenticationResult.message); PlayerPrefs.DeleteKey(PreferenceKeys.LastUsername()); PlayerPrefs.DeleteKey(PreferenceKeys.LastPassword()); usernameInput.text = ""; passwordInput.text = ""; break; case 2: // Incorrect password LoadedAvatar = true; Popup.Make(this, authenticationResult.message); PlayerPrefs.DeleteKey(PreferenceKeys.LastPassword()); passwordInput.text = ""; break; } }
public IEnumerator PostPlayDataCoroutine() { if (IsUploading) { Popup.Make(this, "Already uploading."); } IsUploading = true; EventKit.Broadcast("reload rankings"); Debug.Log("Posting play data"); Popup.Make(this, "Uploading play data..."); yield return(OnlinePlayer.PostPlayData(CytoidApplication.CurrentPlay.IsRanked ? (IPlayData)CytoidApplication.CurrentRankedPlayData : CytoidApplication.CurrentUnrankedPlayData)); switch (OnlinePlayer.LastPostResult.status) { case 200: Popup.Make(this, "Uploaded play data."); EventKit.Broadcast("profile update"); SuccessfullyUploaded = true; break; case 400: Popup.Make(this, "ERROR: " + "Invalid play data."); uploadButton.interactable = true; SuccessfullyUploaded = false; break; case 401: Popup.Make(this, "ERROR: " + "You haven't signed in."); OnlinePlayer.Invalidate(); uploadButton.interactable = true; SuccessfullyUploaded = false; break; default: Popup.Make(this, "ERROR: " + OnlinePlayer.LastPostResult.message); uploadButton.interactable = true; SuccessfullyUploaded = false; break; } IsUploading = false; retryButton.interactable = true; nextButton.interactable = true; }
public void SwitchDifficulty(string type, bool newLevel) { if (CytoidApplication.CurrentChartType == type && !newLevel) { return; } SetDifficulty(level, level.charts.Find(it => it.type == type)); CytoidApplication.CurrentChartType = type; LevelSelectionController.Instance.UpdateBestText(); if (PlayerPrefsExt.GetBool("ranked")) { EventKit.Broadcast("reload rankings"); } }
void PeriodicUpdate() { QualitySettings.vSyncCount = vSyncEnabled ? 1 : 0; debug_AttackDisabled = !attackEnabled; debug_MovementDisabled = !movementEnabled; CheckTileMapStatus(); if (horizUnitsOnScreen != actualUnitsOnScreen) { savedUnitsOnScreen = actualUnitsOnScreen; EventKit.Broadcast("set screen size", horizUnitsOnScreen); } }
public void TouchesEnemy(string weaponType, CreatureEntity enemy, Collider2D coll, int hitFrom) { player.HP -= (int)(enemy.touchDamage * diffDamageModifier); EventKit.Broadcast <int>("reduce hp", player.HP); if (player.HP > 0) { MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f); } else { EventKit.Broadcast <int, Weapon.WeaponType>("player dead", hitFrom, Weapon.WeaponType.Struckdown); } }
void OnTriggerEnter2D(Collider2D coll) { if (!alreadyCollided && !levelCompleted && !playerDead) { int layer = coll.gameObject.layer; if (layer == BODY_COLLIDER) { alreadyCollided = true; EventKit.Broadcast <int>("prize collected", 5); FadeOutFast(); } } }
void PlayerJump() { velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity); animator.SetBool("jump", true); jump = false; if (ridingFastPlatform && movingHorizontally) { if (!jumpedFromFastPlatform) { jumpedFromFastPlatform = true; EventKit.Broadcast <bool>("player jumped from fast platform", true); } } }
void OnSetDifficulty(int difficulty) { switch (difficulty) { case NORMAL: EventKit.Broadcast("set difficulty damage modifier", 1); break; case HARD: EventKit.Broadcast("set difficulty damage modifier", 2); break; case EPIC: EventKit.Broadcast("set difficulty damage modifier", 3); break; } }