Example #1
0
        public virtual void Reset(int from, int to, int image, Glowing glowing, ICallback listener)
        {
            Revive();

            View(image, glowing);

            _callback = listener;

            Point(DungeonTilemap.TileToWorld(from));
            var dest = DungeonTilemap.TileToWorld(to);

            var d = PointF.Diff(dest, Point());

            Speed.Set(d).Normalize().Scale(SPEED);

            if (image == 31 || image == 108 || image == 109 || image == 110)
            {
                AngularSpeed = 0;
                Angle        = 135 - (float)(Math.Atan2(d.X, d.Y) / 3.1415926 * 180);
            }
            else
            {
                AngularSpeed = image == 15 || image == 106 ? 1440 : 720;
            }

            var tweener = new PosTweener(this, dest, d.Length / SPEED);

            tweener.Listener = this;
            Parent.Add(tweener);
        }
Example #2
0
        public ItemSprite(int image, Glowing glowing)
            : base(Assets.ITEMS)
        {
            if (film == null)
            {
                film = new TextureFilm(texture, SIZE, SIZE);
            }

            View(image, glowing);
        }
Example #3
0
        public virtual ItemSprite View(int image, Glowing glowing)
        {
            Frame(film.Get(image));
            if ((this.glowing = glowing) == null)
            {
                ResetColor();
            }

            return(this);
        }
Example #4
0
    IEnumerator Glow(GameObject detail, GameObject item)
    {
        Glowing    glDetail = detail.GetComponent <Glowing>();
        GameObject child    = item.transform.GetChild(0).gameObject;

        child.SetActive(true);

        glDetail.AddGlow();

        yield return(new WaitForSeconds(4f));

        glDetail.RemoveGlow();
        child.SetActive(false);
    }
        public override void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
        {
            Color   glowColor = new Color(250, 250, 250, item.alpha);
            Glowing glow      = item.modItem as Glowing;

            if (glow != null)
            {
                float     bias     = 0f;
                Texture2D texture  = glow.Glowmask(out bias);
                Color     alpha    = Color.Lerp(alphaColor, glowColor, bias);
                Vector2   origin   = new Vector2(texture.Width >> 1, texture.Height >> 1);
                Vector2   position = item.position - Main.screenPosition;
                position.X += item.width >> 1;
                position.Y += item.height - (texture.Height >> 1) + 2f;
                spriteBatch.Draw(texture, position, null, alpha, rotation, origin, scale, SpriteEffects.None, 0f);
            }

            if (glyph != GlyphType.None)
            {
                Texture2D texture = Glyphs.GlyphBase.FromType(glyph).Overlay;
                if (texture != null)
                {
                    Vector2 position = item.position - Main.screenPosition;
                    position.X += (item.width >> 1);
                    position.Y += 2 + item.height - (Main.itemTexture[item.type].Height >> 1);

                    //Color alpha = Color.Lerp(alphaColor, glowColor, .2f);
                    Color alpha = alphaColor;
                    alpha.R = (byte)Math.Min(alpha.R + 25, 255);
                    alpha.G = (byte)Math.Min(alpha.G + 25, 255);
                    alpha.B = (byte)Math.Min(alpha.B + 25, 255);
                    //alpha.A = (byte)(alpha.A * .6f);
                    Vector2 origin = new Vector2(texture.Width >> 1, texture.Height >> 1);
                    spriteBatch.Draw(texture, position, null, alpha, rotation, origin, scale, SpriteEffects.None, 0f);
                }
            }
        }
Example #6
0
        public void Effect(Player player, string effect, int level = 1, int duration = 20)
        {
            EffectType effectType;

            if (Enum.TryParse(effect, true, out effectType))
            {
                Effect eff = null;
                switch (effectType)
                {
                case EffectType.Speed:
                    eff = new Speed();
                    break;

                case EffectType.Slowness:
                    eff = new Slowness();
                    break;

                case EffectType.Haste:
                    eff = new Haste();
                    break;

                case EffectType.MiningFatigue:
                    eff = new MiningFatigue();
                    break;

                case EffectType.Strenght:
                    eff = new Strength();
                    break;

                case EffectType.InstandHealth:
                    eff = new InstandHealth();
                    break;

                case EffectType.InstantDamage:
                    eff = new InstantDamage();
                    break;

                case EffectType.JumpBoost:
                    eff = new JumpBoost();
                    break;

                case EffectType.Nausea:
                    eff = new Nausea();
                    break;

                case EffectType.Regeneration:
                    eff = new Regeneration();
                    break;

                case EffectType.Resistance:
                    eff = new Resistance();
                    break;

                case EffectType.FireResistance:
                    eff = new FireResistance();
                    break;

                case EffectType.WaterBreathing:
                    eff = new WaterBreathing();
                    break;

                case EffectType.Invisibility:
                    eff = new Invisibility();
                    break;

                case EffectType.Blindness:
                    eff = new Blindness();
                    break;

                case EffectType.NightVision:
                    eff = new NightVision();
                    break;

                case EffectType.Hunger:
                    eff = new Hunger();
                    break;

                case EffectType.Weakness:
                    eff = new Weakness();
                    break;

                case EffectType.Poison:
                    eff = new Poison();
                    break;

                case EffectType.Wither:
                    eff = new Wither();
                    break;

                case EffectType.HealthBoost:
                    eff = new HealthBoost();
                    break;

                case EffectType.Absorption:
                    eff = new Absorption();
                    break;

                case EffectType.Saturation:
                    eff = new Saturation();
                    break;

                case EffectType.Glowing:
                    eff = new Glowing();
                    break;

                case EffectType.Levitation:
                    eff = new Levitation();
                    break;
                }

                if (eff != null)
                {
                    eff.Level     = level;
                    eff.Duration  = duration;
                    eff.Particles = false;

                    player.SetEffect(eff);
                    player.Level.BroadcastMessage(string.Format("{0} added effect {1} with strenght {2}", player.Username, effectType, level), MessageType.Raw);
                }
            }
        }