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); } } }
void Start() { playerLight = GameObject.Find("PlayerLight").GetComponent <Light>(); Assert.IsNotNull(playerLight); creatureLight = GameObject.Find("CreatureLight").GetComponent <Light>(); Assert.IsNotNull(creatureLight); tileLight = GameObject.Find("TileLight").GetComponent <Light>(); Assert.IsNotNull(tileLight); pickupLight = GameObject.Find("PickupLight").GetComponent <Light>(); Assert.IsNotNull(pickupLight); decorationLight = GameObject.Find("DecorationLight").GetComponent <Light>(); Assert.IsNotNull(decorationLight); // cache & pause tweens. (playerAboveGroundTween = MFX.FadeIntensity(playerLight, playerAboveGround, fadeAfter, timeToFade)).Pause(); (creatureAboveGroundTween = MFX.FadeIntensity(creatureLight, creatureAboveGround, fadeAfter, timeToFade)).Pause(); (tileAboveGroundTween = MFX.FadeIntensity(tileLight, tileAboveGround, fadeAfter, timeToFade)).Pause(); (pickupAboveGroundTween = MFX.FadeIntensity(pickupLight, pickupAboveGround, fadeAfter, timeToFade)).Pause(); (decorationAboveGroundTween = MFX.FadeIntensity(decorationLight, pickupAboveGround, fadeAfter, timeToFade)).Pause(); (playerBelowGroundTween = MFX.FadeIntensity(playerLight, playerBelowGround, fadeAfter, timeToFade)).Pause(); (creatureBelowGroundTween = MFX.FadeIntensity(creatureLight, creatureBelowGround, fadeAfter, timeToFade)).Pause(); (tileBelowGroundTween = MFX.FadeIntensity(tileLight, tileBelowGround, fadeAfter, timeToFade)).Pause(); (pickupBelowGroundTween = MFX.FadeIntensity(pickupLight, pickupBelowGround, fadeAfter, timeToFade)).Pause(); (decorationBelowGroundTween = MFX.FadeIntensity(decorationLight, pickupBelowGround, fadeAfter, timeToFade)).Pause(); }
void Start() { // cache & pause tween sequences. (projectileFadeIn = MFX.Fade(projSpriteRenderer, 1f, 0f, .3f)).Pause(); (projectileFadeInInstant = MFX.Fade(projSpriteRenderer, 1f, 0f, 0f)).Pause(); (projectileFadeOut = MFX.Fade(projSpriteRenderer, 0, 0, .15f)).Pause(); }
void CacheAndSetupWeapons() { // WEAPON GAMEOBJECT'S 'WEAPON' COMPONENT // ~~~~~~~~~~~~~~~~~~~~~~~~ // cache specific weapons (Sword, Hammer, etc) via parent class 'Weapon' // use to call currently equipped weapon animations leftWeapon = weaponBelt[left].GetComponent <Weapon>(); equippedWeapon = weaponBelt[equipped].GetComponent <Weapon>(); rightWeapon = weaponBelt[right].GetComponent <Weapon>(); // set correct names for weapon gameObjects weaponBelt[left].name = "Left"; weaponBelt[equipped].name = "Equipped"; weaponBelt[right].name = "Right"; // set weapons to correct layers weaponBelt[left].layer = PLAYER_LAYER; weaponBelt[equipped].layer = PLAYER_LAYER; weaponBelt[right].layer = PLAYER_LAYER; // set weapons to correct sorting layers; weaponBelt[left].GetComponent <SpriteRenderer>().sortingLayerName = HERO_WEAPON_SORTING_LAYER; weaponBelt[equipped].GetComponent <SpriteRenderer>().sortingLayerName = HERO_WEAPON_SORTING_LAYER; weaponBelt[right].GetComponent <SpriteRenderer>().sortingLayerName = HERO_WEAPON_SORTING_LAYER; // set weapon colliders to correct layers weaponBelt[left].transform.Find("MeleeCollider").gameObject.layer = WEAPON_COLLIDER; weaponBelt[equipped].transform.Find("MeleeCollider").gameObject.layer = WEAPON_COLLIDER; weaponBelt[right].transform.Find("MeleeCollider").gameObject.layer = WEAPON_COLLIDER; // set pickup colliders to correct layers weaponBelt[left].transform.Find("PickupCollider").gameObject.layer = PICKUP_LAYER; weaponBelt[equipped].transform.Find("PickupCollider").gameObject.layer = PICKUP_LAYER; weaponBelt[right].transform.Find("PickupCollider").gameObject.layer = PICKUP_LAYER; // disable SpriteRenderer for weapons that are not equipped leftWeapon.spriteRenderer.enabled = false; equippedWeapon.spriteRenderer.enabled = true; rightWeapon.spriteRenderer.enabled = false; // disable colliders for all weapons - they are only enabled during attacks leftWeapon.GetComponent <BoxCollider2D>().enabled = false; equippedWeapon.GetComponent <BoxCollider2D>().enabled = false; rightWeapon.GetComponent <BoxCollider2D>().enabled = false; // fade in newly equipped weapon float fadeAfter = 0f; float fadeTime = .2f; SpriteRenderer equippedSprite = weaponBelt[equipped].GetComponent <SpriteRenderer>(); equippedSprite.DOKill(); MFX.Fade(equippedSprite, 1f, fadeAfter, fadeTime); // fade out newly stashed weapons FadeOutStashedWeapons(leftWeapon); FadeOutStashedWeapons(rightWeapon); SendMessageUpwards("NewWeaponEquipped", equippedWeapon.weaponType); }
// fire directionally public void Fire(bool firedByPlayer, Weapon weapon, float direction) { Init(weapon); if (fadeIn) { MFX.Fade(spriteRenderer, 1f, 0f, .3f); } else { MFX.Fade(spriteRenderer, 1f, 0f, 0f); } // lob projectile like a cannon ball if (lob) { // if fired by the player, use the custom gravity supplied by the weapon (lobGravity,) // otherwise, for projectiles fired by an enemy, use the default gravity of .5f if (firedByPlayer) { rigidbody2D.gravityScale = lobGravity; } else { rigidbody2D.gravityScale = .5f; } } // otherwise, fire projectile linearally else { rigidbody2D.gravityScale = 0; } rigidbody2D.velocity = transform.right * weapon.speed * direction; }
public void TakesHit(string weaponType, Weapon weapon, Collider2D coll, int hitFrom) { // calculate damage player.HP -= (int)(weapon.damage * DIFFICULTY_DAMAGE_MODIFIER); // produce effects // params for ShakeCamera = duration, strength, vibrato, randomness Messenger.Broadcast <float, float, int, float>("shake camera", .5f, .3f, 20, 5f); Messenger.Broadcast <int>("reduce hp", player.HP); // float xDistance = hitFrom == LEFT ? 2f : -2f; // transform.DOJump(new Vector3(transform.position.x + xDistance, transform.position.y, transform.position.z), .2f, 1, .5f, false); if (hitFrom == RIGHT) { BroadcastMessage("RepulseToLeft", 5.0F); } else { BroadcastMessage("RepulseToRight", 5.0F); } if (player.HP > 0) { MFX.FadeToColorAndBack(spriteRenderer, MCLR.bloodRed, 0f, .2f); } else { Messenger.Broadcast <string, Collider2D, int>("player dead", "projectile", coll, hitFrom); } }
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); } }
void ChangeStashedWeapon(GameObject weapon) { HUDWeapon = spriteRenderer; HUDWeapon.sprite = weapon.GetComponent <Weapon>().iconSprite; transform.localPosition = hudPosition; if (hudSide == RIGHT) { // upon receiving new weapon for the right slot, instantly relocate it back to its previous location, // while setting opacity to 100%, then tween the image to the right, into the final right slot position, // all while tweening the transparency down to that of stashed weapons MFX.Fade(HUDWeapon, 1f, 0, 0); MFX.Fade(HUDWeapon, HUD_STASHED_TRANSPARENCY, 0f, .2f); // shift weapon left, to roughly the position it was just in transform.localPosition = new Vector3( transform.localPosition.x - 1.3281f, transform.localPosition.y, transform.localPosition.z ); // tween weapon to new position transform.DOLocalMove(new Vector3( transform.localPosition.x + SPACE_BETWEEN_WEAPONS, transform.localPosition.y, transform.localPosition.z), INVENTORY_SHIFT_SPEED, false).OnComplete(() => SetFinalPosition() ); } else { MFX.Fade(HUDWeapon, 0, 0, 0); MFX.Fade(HUDWeapon, HUD_STASHED_TRANSPARENCY, 0f, .05f); } }
void KillSelf(int hitFrom, int weaponType) { if (!dead) { // activate and kill breakable sprite if (weaponType == MELEE) { breakable.DirectionalSlump(hitFrom); } else if (weaponType == PROJECTILE) { breakable.Explode(hitFrom); } // deactivate and fade solid sprite rigidbody2D.isKinematic = true; collider2D.enabled = false; MFX.Fade(spriteRenderer, 0f, 0f, 0f); dead = true; gameObject.SendMessage("CreatureDead"); Invoke("DeactivateObject", MAX_BEFORE_FADE + 5f); } }
void Start() { // cache & pause tweens. switch (direction) { case Direction.Right: (movingPlatformTween = MFX.MoveBackAndForthHorizontal(pauseTime, transform, distance, time)).Pause(); break; case Direction.Left: (movingPlatformTween = MFX.MoveBackAndForthHorizontal(pauseTime, transform, -distance, time)).Pause(); break; case Direction.Up: (movingPlatformTween = MFX.MoveBackAndForthVertical(pauseTime, transform, distance, time)).Pause(); break; case Direction.Down: (movingPlatformTween = MFX.MoveBackAndForthVertical(pauseTime, transform, -distance, time)).Pause(); break; default: Assert.IsTrue(false, ("Direction missing from switch @ " + gameObject)); break; } movingPlatformTween.Restart(); }
void TakesProjectileHit(Weapon playerWeapon, Collider2D coll, int hitFrom) { hp -= (int)(playerWeapon.damage * DIFFICULTY_DAMAGE_MODIFIER); // 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) { Messenger.Broadcast <int>("prize collected", worth); KillSelf(hitFrom, PROJECTILE); } }
IEnumerator FlickerFXLoop() { while (true) { MFX.Flicker(light, minIntensity, maxIntensity); yield return(new WaitForSeconds(Rand.Range(.01f, .3f))); } }
void Start() { // cache & pause tween sequences. (fadeToNoTint = MFX.FadeToNoTint(spriteRenderer, 0, .5f)).Pause(); (setToStashedTint = MFX.SetToStashedTint(spriteRenderer)).Pause(); Invoke("SetTweens", .001f); BaseStart(); }
void Start() { player = GameObject.Find(_DATA).GetComponent <PlayerData>(); Assert.IsNotNull(player); (fadeWhenHit = MFX.FadeToColorAndBack(spriteRenderer.material, MCLR.bloodRed, 0f, .2f)).Pause(); Init(); }
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); } }
// upon recycling, clear previous references and fade gameObject to zero void OnDisable() { anim = null; weapon = null; animator.runtimeAnimatorController = null; spriteRenderer.sprite = null; CancelInvoke(); MFX.Fade(spriteRenderer, 0f, 0f, 0f); }
void Start() { // cache & pause tween sequences. (setTint = MFX.SetToStashedTint(spriteRenderer)).Pause(); (fadeToTint = MFX.FadeToStashedTint(spriteRenderer, 0f, .2f)).Pause(); (fadeInInstant = MFX.Fade(spriteRenderer, 1, 0, 0)).Pause(); Invoke("SetTweens", .001f); BaseStart(); }
void Start() { BaseStart(); // cache & pause tween sequences. (fadeOutInstant = MFX.Fade(textComponent, 0, 0, 0)).Pause(); (fadeIn = MFX.Fade(textComponent, 1, HUD_FADE_IN_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause(); (fadeOutHUD = MFX.Fade(textComponent, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause(); (displayScoreFX = MFX.DisplayScoreFX(gameObject)).Pause(); }
// fade and deactivate on impact void OnTriggerEnter2D(Collider2D coll) { int layer = coll.gameObject.layer; if (layer == ENEMY_COLLIDER) { MFX.Fade(spriteRenderer, 0, 0, .15f); Invoke("DeactivateEntireObject", .16f); } }
void FadeOutStashedWeapons(Weapon stashedWeapon) { float fadeAfter = 0f; float fadeTime = .2f; SpriteRenderer stashedSprite = stashedWeapon.GetComponent <SpriteRenderer>(); stashedSprite.DOKill(); MFX.Fade(stashedSprite, 0f, fadeAfter, fadeTime); }
internal static void SetMFXProvider(this MFX instance) { switch (instance.Type) { case IntegraMFXTypes.Equalizer: instance.Parameters = new MFXEqualizer(instance); break; default: instance.Parameters = new MFXThru(instance); break; } }
void Start() { // cache & pause tweens. (fadeInOnEquip = MFX.Fade(spriteRenderer, 1f, whenEquippedFadeAfter, whenEquippedFadeOver)).Pause(); (fadeOutOnDiscard = MFX.Fade(spriteRenderer, .2f, 0f, 0f)).Pause(); (fadeBackInAfterDiscard = MFX.FadeInWeapon(spriteRenderer, 1f, 2f, 1f)).Pause(); (fadeWhenStashed = MFX.Fade(spriteRenderer, 0f, whenStashedFadeAfter, whenStashedFadeOver)).Pause(); EstablishAttackStyle(); Init(); }
void Start() { // cache & pause tween sequences. (setTint = MFX.SetToStashedTint(spriteRenderer)).Pause(); (fadeToTint = MFX.FadeToStashedTint(spriteRenderer, 0f, .05f)).Pause(); (fadeInHUD = MFX.Fade(spriteRenderer, 1, HUD_FADE_IN_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause(); (fadeOutHUD = MFX.Fade(spriteRenderer, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause(); (fadeOutInstant = MFX.Fade(spriteRenderer, 0, 0, 0)).Pause(); BaseStart(); }
public static string PUS(string UP, ConsoleKey KEY, string TIT) { MFX.CTT(TIT); Console.Write(UP); while (Console.ReadKey().Key != KEY) { Console.ReadKey(false); } MFX.CTT("/n"); return(IOl.FXS.oFXSsg()); }
void Start() { player = GameObject.Find(PLAYER).GetComponent <Transform>(); Assert.IsNotNull(player); (fadeInViewport = MFX.FadeInViewport(spriteRenderer, fadeInAfter, timeToFadeIn)).Pause(); (fadeOutViewport = MFX.FadeOutViewport(spriteRenderer, fadeOutAfter, timeToFadeOut)).Pause(); spriteRenderer.enabled = true; FadeInNewLevel(); GetPlayerPosition(); }
void Awake() { transform = GetComponent <Transform>(); Assert.IsNotNull(transform); spriteRenderer = GetComponent <SpriteRenderer>(); Assert.IsNotNull(spriteRenderer); // cache & pause tween sequences. (fadeInInstant = MFX.FadeTween(spriteRenderer, 1f, 0f)).Pause(); (fadeOut = MFX.FadeTween(spriteRenderer, 0f, .5f)).Pause(); }
void Start() { rigidbody2D = GetComponent <Rigidbody2D>(); Assert.IsNotNull(rigidbody2D); rigidbody2D.mass = Rand.Range(.5f, 20f); rigidbody2D.drag = Rand.Range(0f, .5f); // cache & pause tween sequences. (fadeInInstant = MFX.Fade(spriteRenderer, 1f, 0f, 0f)).Pause(); (fadeOut = MFX.Fade(spriteRenderer, 0f, 0f, 3f)).Pause(); }
void SetTweens() { // set origin for item's slide tween slideTweenOrigin = new Vector3( transform.localPosition.x - STASHED_ITEM_OFFSET, transform.localPosition.y, transform.localPosition.z ); // cache & pause slide tween. (slideItem = MFX.SlideStashedItem(transform, slideTweenOrigin, STASHED_ITEM_OFFSET, INVENTORY_SHIFT_SPEED, false)).Pause(); }
void Start() { canvasScaler = gameObject.GetComponentInParent <CanvasScaler>(); Assert.IsNotNull(canvasScaler); canvasScaler.scaleFactor = PLATFORM_SPECIFIC_CANVAS_SCALE; M.PositionInHUD(rectTrans, textComponent, HP_ALIGNMENT, HP_X_POS, HP_Y_POS); // cache & pause tween sequences. (fadeOutInstant = MFX.Fade(textComponent, 0, 0, 0)).Pause(); (fadeIn = MFX.Fade(textComponent, 1, HUD_FADE_IN_AFTER, HUD_INITIAL_TIME_TO_FADE)).Pause(); (fadeOutHUD = MFX.Fade(textComponent, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_TIME_TO_FADE)).Pause(); }
void OnChangeScore(int newScore) { HUDScore.text = newScore.ToString(); int scoreChange = (newScore - previousScore); if (scoreChange > 5) { MFX.DisplayScoreFX(gameObject, HUDScore); } previousScore = newScore; }