Exemplo n.º 1
0
    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);
            }
        }
    }
Exemplo n.º 2
0
    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();
    }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    // 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;
    }
Exemplo n.º 6
0
    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);
        }
    }
Exemplo n.º 7
0
    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);
        }
    }
Exemplo n.º 8
0
    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);
        }
    }
Exemplo n.º 9
0
    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);
        }
    }
Exemplo n.º 10
0
    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();
    }
Exemplo n.º 11
0
    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);
        }
    }
Exemplo n.º 12
0
 IEnumerator FlickerFXLoop()
 {
     while (true)
     {
         MFX.Flicker(light, minIntensity, maxIntensity);
         yield return(new WaitForSeconds(Rand.Range(.01f, .3f)));
     }
 }
Exemplo n.º 13
0
    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();
    }
Exemplo n.º 15
0
 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);
     }
 }
Exemplo n.º 16
0
 // 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);
 }
Exemplo n.º 17
0
    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();
    }
Exemplo n.º 18
0
    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();
    }
Exemplo n.º 19
0
    // 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);
        }
    }
Exemplo n.º 20
0
    void FadeOutStashedWeapons(Weapon stashedWeapon)
    {
        float fadeAfter = 0f;
        float fadeTime  = .2f;

        SpriteRenderer stashedSprite = stashedWeapon.GetComponent <SpriteRenderer>();

        stashedSprite.DOKill();
        MFX.Fade(stashedSprite, 0f, fadeAfter, fadeTime);
    }
Exemplo n.º 21
0
        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;
            }
        }
Exemplo n.º 22
0
    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();
    }
Exemplo n.º 23
0
    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();
    }
Exemplo n.º 24
0
 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());
 }
Exemplo n.º 25
0
    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();
    }
Exemplo n.º 26
0
    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();
    }
Exemplo n.º 27
0
    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();
    }
Exemplo n.º 28
0
    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();
    }
Exemplo n.º 29
0
    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();
    }
Exemplo n.º 30
0
    void OnChangeScore(int newScore)
    {
        HUDScore.text = newScore.ToString();

        int scoreChange = (newScore - previousScore);

        if (scoreChange > 5)
        {
            MFX.DisplayScoreFX(gameObject, HUDScore);
        }

        previousScore = newScore;
    }