Example #1
0
        public void Breed(double probability, double standardDeviation)
        {
            Brain = new NeuralNetwork(parent.Brain);
            Brain.Mutate(probability, standardDeviation);

            r           = parent.ObjectColor.R + (int)(50 * RandomHelper.Range(-standardDeviation, standardDeviation));
            g           = parent.ObjectColor.G + (int)(50 * RandomHelper.Range(-standardDeviation, standardDeviation));
            b           = parent.ObjectColor.B + (int)(50 * RandomHelper.Range(-standardDeviation, standardDeviation));
            r           = r > 255 ? 255 : r;
            g           = g > 255 ? 255 : g;
            b           = b > 255 ? 255 : b;
            r           = r < 0 ? 0 : r;
            g           = g < 0 ? 0 : g;
            b           = b < 0 ? 0 : b;
            ObjectColor = new Color(r, g, b);
            roof.SetColor(ObjectColor);

            if (playerControlled)
            {
                ObjectColor = Palette.BloodRed;
                roof.SetColor(ObjectColor);
            }

            Reset();
        }
Example #2
0
    IEnumerator _ShowSaving()
    {
        Sprite s = GuiSaving.Instance.Sprite;

        DefaultSpriteUI.ShowSprite(s);
        Color c = Color.white;

        c.a = 0;
        s.SetColor(c);

        while (s.color.a < 1)
        {
            c.a = Mathf.Min(1.0f, c.a + 2 * Time.deltaTime);
            s.SetColor(c);
            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(1.5f));

        while (s.color.a > 0)
        {
            c.a = Mathf.Max(0.0f, c.a - 2 * Time.deltaTime);
            s.SetColor(c);
            yield return(new WaitForEndOfFrame());
        }

        DefaultSpriteUI.HideSprite(s);
    }
Example #3
0
    public void Init(Vector3 oriDir, float speed, float life, int oriRot, float oriScaleX, float oriScaleY, Color oriColor, Vector2 oriLowerUv, Vector2 oriUVDimension)
    {
        OriDirection   = oriDir;
        LifeTime       = life;
        OriRotateAngle = oriRot;
        OriScaleX      = oriScaleX;
        OriScaleY      = oriScaleY;
        Color          = oriColor;
        ElapsedTime    = 0f;
        Velocity       = OriDirection * speed;
        Acceleration   = 0f;
        LowerLeftUV    = oriLowerUv;
        UVDimensions   = oriUVDimension;
        if (Type == 1)
        {
            Sprite.SetUVCoord(LowerLeftUV, UVDimensions);
            Sprite.SetColor(oriColor);
        }
        else if (Type == 2)
        {
            Ribbon.SetUVCoord(LowerLeftUV, UVDimensions);
            Ribbon.SetColor(oriColor);
            Ribbon.SetHeadPosition(ClientTrans.position + Position + OriDirection.normalized * Owner.TailDistance);
            Ribbon.ResetElementsPos();
        }

        if (Type == 1)
        {
            Sprite.SetRotationTo(OriDirection);
        }
    }
Example #4
0
    IEnumerator ShowBlood(Vector2 pos, int type)
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(0.0f, 0.2f)));

        if (BloodSplashes.GuiSprites.Count == 0)
        {
            yield break;
        }

        Sprite s = BloodSplashes.GuiSprites[0];

        BloodSplashes.GuiSprites.Remove(s);
        BloodSplashes.GuiSpritesInUse.Add(s);

        Color       alphaColor = new Color(1, 1, 1);
        const float speed      = 5;
        const float speedFade  = 0.25f;

        float size = Random.Range(0.8f, 1.0f);

        s.clientTransform.eulerAngles = new Vector3(0, 0, UnityEngine.Random.Range(0, 360));

        DefaultSpriteUI.UpdateSpriteSize(s, pos, GuiBlood.UvWidth * size, GuiBlood.UvHeight * size,
                                         GuiBlood.UvLeft[type], GuiBlood.UvTop[type], GuiBlood.UvWidth, GuiBlood.UvHeight);
        DefaultSpriteUI.ShowSprite(s);

        while (alphaColor.a < 1)
        {
            alphaColor.a += Time.deltaTime * speed;
            if (alphaColor.a > 1)
            {
                alphaColor.a = 1;
            }

            s.SetColor(alphaColor);
            yield return(new WaitForEndOfFrame());
        }
        yield return(new WaitForSeconds(UnityEngine.Random.Range(0.8f, 1.5f)));

        while (alphaColor.a > 0)
        {
            alphaColor.a -= Time.deltaTime * speedFade;
            if (alphaColor.a < 0)
            {
                alphaColor.a = 0;
            }

            s.SetColor(alphaColor);
            yield return(new WaitForEndOfFrame());
        }
        DefaultSpriteUI.HideSprite(s);
        BloodSplashes.GuiSprites.Add(s);
        BloodSplashes.GuiSpritesInUse.Remove(s);
    }
 private void ToggleFlash()
 {
     flash = !flash;
     if (flash)
     {
         sprite.SetColor(1, 1, 1);
     }
     else
     {
         sprite.SetColor(0.3f, 0.3f, 0.3f);
     }
 }
Example #6
0
        public Lamp(EntityData data, Vector2 offset) : base(data.Position + offset)
        {
            flag       = data.Attr("flag", "");
            id         = data.ID;
            baseColor  = ColorHelper.GetColor(data.Attr("baseColor", "White"));
            lightColor = ColorHelper.GetColor(data.Attr("lightColor", "White"));

            Add((Component)(startupSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/start")));
            startupSprite.AddLoop("start", "", 0.1f);
            startupSprite.JustifyOrigin(0.5f, 0.5f);
            startupSprite.Play("start");
            startupSprite.OnLastFrame = onLastFrame;
            startupSprite.Stop();

            Add((Component)(idleSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/idle")));
            idleSprite.AddLoop("idle", "", 0.125f);
            idleSprite.JustifyOrigin(0.5f, 0.5f);
            idleSprite.Play("idle");
            idleSprite.Visible = false;

            Add((Component)(baseSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/base")));
            baseSprite.AddLoop("base", "", 0.1f);
            baseSprite.JustifyOrigin(0.5f, 0.5f);
            baseSprite.Play("base");
            baseSprite.SetColor(baseColor);

            inStartupAnimation = false;

            Add((Component)(bloom = new BloomPoint(0.5f, 8f)));
            Add((Component)(light = new VertexLight(lightColor, 1f, 48, 64)));

            bloom.Visible = light.Visible = false;

            Depth = 5;
        }
Example #7
0
        public override void Draw(Canvas canvas, GameTime gameTime)
        {
            background.Draw(canvas, 0, 0);

            sprite.Draw(canvas, particle_x, particle_y);

            animated_sprite.Draw(canvas, char_x, char_y);

            tweenedSprite.SetColor(Color.DodgerBlue);
            tweenedSprite.Draw(canvas, tweenedValue.Value, 200);

            _trail.Draw(canvas);

            _explosion.Draw(canvas);

            canvas.FillRect(100, 100, 100, 100, Color.DodgerBlue);

            canvas.DrawText(10, 10,
                            $"Elapsed Update: {elapsed}, Elapsed Draw: {gameTime.ElapsedGameTime.Milliseconds}", Color.DodgerBlue, 0.25f);


            canvas.DrawText(10, 60, $"Trail Particles: {_trail.ParticlesAlive}", Color.White, 0.25f);

            canvas.DrawText(10, 80, $"Explosion Particles: {_explosion.ParticlesAlive}", Color.White, 0.25f);

            canvas.DrawText(10, 100, $"Tweener Allocations: {tweener.AllocationCount}", Color.White, 0.25f);

            canvas.DrawText(10, 120, $"Draw Calls: {canvas.MaxDrawCalls}", Color.White, 0.25f);
        }
Example #8
0
        public Bubbler(EntityData data, Vector2 offset) : base(data.Position + offset)
        {
            visible  = data.Bool("visible", false);
            Collider = new Hitbox(14f, 14f, 0f, 0f);
            Collider.CenterOrigin();
            Add(new PlayerCollider(new Action <Player>(OnPlayer), null, null));
            color = ColorHelper.GetColor(data.Attr("color", "White"));

            nodes = data.NodesOffset(offset);

            if (visible)
            {
                Add(sprite = new Sprite(GFX.Game, "objects/FrostHelper/bubble"));
                sprite.AddLoop("idle", "", 0.1f);
                sprite.CenterOrigin();
                sprite.Play("idle", false, false);
                sprite.SetColor(color);
                Add(previewSprite = new Sprite(GFX.Game, "objects/FrostHelper/bubble"));
                previewSprite.AddLoop("idle", "", 0.1f);
                previewSprite.CenterOrigin();
                previewSprite.Play("idle", false, false);
                previewSprite.Position = nodes.Last() - Position;
                previewSprite.SetColor(new Color(color.R, color.G, color.B, 128f) * 0.3f);
            }
        }
Example #9
0
    public void SetFadeOut(float fadeOut)
    {
        currentAlpha = fadeOut;
        targetAlpha  = fadeOut;
        alphaColor.a = fadeOut;
        Fade.SetColor(alphaColor);

        if (currentAlpha == fadeOut)
        {
            DefaultSpriteUI.HideSprite(Fade);
        }
        else
        {
            DefaultSpriteUI.ShowSprite(Fade);
        }
    }
Example #10
0
        public override void Render(Renderer renderer)
        {
            Sprite sp = Sprites[Index];

            sp.SetPosition(Position.X, Position.Y);
            sp.SetColor(new Color(1, 1, 1, 0.5f));
            renderer.DrawSprite(sp, Position.X, Position.Y, OffsetAngle + 90);
        }
Example #11
0
 public virtual void RandomizeColor()
 {
     myColor = (EBlockColor)myGridBundle.GridRandomizer.Next(0, 5);
     if (mySprite != null)
     {
         mySprite.SetColor(GetColorFromEnum());
     }
 }
Example #12
0
    IEnumerator ShowSprite(Sprite s, float time)
    {
        DefaultSpriteUI.ShowSprite(s);

        float step = 1 / time;
        Color c    = Color.white;

        c.a = 0;
        s.SetColor(c);

        while (s.color.a < 1)
        {
            c.a = Mathf.Min(1.0f, c.a + step * Time.deltaTime);
            s.SetColor(c);
            yield return(new WaitForEndOfFrame());
        }
    }
Example #13
0
    IEnumerator BlinkComboMessage(Sprite s, float scale, float speed, int count, float decreaseScale, float basewidth, float baseHeight)
    {
        ComboMessageOn = true;

        if (SpriteHitsMessage.hidden == false)
        {
            GuiManager.StartCoroutine(DisappearSprite(SpriteHitsMessage, 0.2f));
        }

        for (int i = 0; i < SpriteHitNumbers.Sprites.Length; i++)
        {
            if (SpriteHitNumbers.Sprites[i].hidden == false)
            {
                GuiManager.StartCoroutine(DisappearSprite(SpriteHitNumbers.Sprites[i], 0.2f));
            }
        }

        yield return(new WaitForSeconds(0.1f));

        GuiManager.StartCoroutine(ShowSprite(SpriteComboMessage, 0.2f));

        float newWidth;
        float newHeight;
        Color c = Color.white;

        for (int i = 0; i < count; i++)
        {
            float progress = 0;

            while (progress < 2)
            {
                progress += speed * Time.deltaTime;

                if (progress > 2)
                {
                    progress = 2;
                }

                newWidth  = Mathfx.Sinerp(basewidth, basewidth * scale, progress);
                newHeight = Mathfx.Sinerp(baseHeight, baseHeight * scale, progress);
                s.SetSizeXY(newWidth, newHeight);

                if (progress > 1)
                {
                    c.a = 2 - progress;
                    s.SetColor(c);
                }
                yield return(new WaitForEndOfFrame());
            }
            scale -= decreaseScale;
        }

        DefaultSpriteUI.HideSprite(s);

        ComboMessageOn = false;
        SetHitsCount(Game.Instance.Hits, false);
    }
Example #14
0
 public void Display()
 {
     sprite = spriteManager.AddSprite(this.gameObject,
                                      sizeW, sizeH,
                                      uvX, uvY,
                                      uvW, uvH,
                                      true // no billboarding
                                      );
     sprite.SetColor(color);
 }
Example #15
0
        public FLowerBody(TextureManager _t, float w_h = 16)
        {
            Texture texture = _t.Get("Ef_etama2");

            body         = new Sprite();
            body.Texture = texture;
            body.SetWidth(w_h);
            body.SetHeight(w_h);
            body.SetUVs(2 * per_256, 12 * per_256, 4 * per_256, 14 * per_256);
            body.SetColor(new Color(1, 1, 1, 1));
        }
Example #16
0
 public void Render(IntPtr renderer, Point viewOffset)
 {
     if (Sprite != null)
     {
         var width          = Sprite.Width * Scale;
         var height         = Sprite.Height * Scale;
         var locationOffset = new Vector((int)(width / 2.0), (int)(height / 2.0));
         Sprite.SetColor(Color);
         Sprite.DrawEx(renderer, Location.ToPoint() - locationOffset - viewOffset, Rotation, null, Scale, SDL2.SDL.SDL_RendererFlip.SDL_FLIP_NONE);
     }
 }
Example #17
0
        public override void Render(Renderer renderer)
        {
            base.Render(renderer);
            Sprite sp = Sprites[currentIndex];

            sp.SetWidth(width);
            sp.SetHeight(height);
            sp.SetColor(new Color(1, 1, 1, 0.8f));
            sp.SetPosition(Position.X, Position.Y);
            renderer.DrawSprite(sp);
        }
Example #18
0
            public void Render(Renderer renderer)
            {
                if (!Working)
                {
                    return;
                }
                //背景
                Sprite sp = BackGround[selectComp];

                sp.SetColor(new Color(1, 1, 1, Back_Alpha * 0.7f));
                sp.SetWidth(Back_WidthMax);
                sp.SetHeight(Back_HeightPercent * Back_HeightMax);
                sp.SetPosition(Position.X + BackOffsetX, Position.Y);
                renderer.DrawSprite(sp);
                //文字
                sp = MainSprites[selectComp];
                sp.SetColor(new Color(1, 1, 1, Text_Alpha));
                MainSprites[selectComp].SetPosition(Position.X + Text_OffsetX, Position.Y);
                renderer.DrawSprite(sp);
            }
Example #19
0
        void CreateBox()
        {
            box         = new Sprite();
            box.Texture = Extras.CreateFilledBox(ScreenManager.GraphicsDevice);
            box.SetSize(224, 96);
            box.Position = GHelper.Center(Globals.ScreenBox, box.Size) - new Vector2(0, box.Size.Y * .5f);
            box.SetColor(Color);

            outline         = new Sprite();
            outline.Texture = Extras.CreateFilledBox(ScreenManager.GraphicsDevice);
            outline.SetSize((int)box.Size.X + 4, (int)box.Size.Y + 4);
            outline.Position = box.Position - new Vector2(2, 2);
            outline.SetColor(Color.Black);
        }
Example #20
0
        public void Draw(SpriteBatch aSpriteBatch)
        {
            myBackdropSprite.SetColor(myBackdropColor);
            myBackdropSprite.SetPosition(myPosition);

            myBackdropSprite.Draw(aSpriteBatch);
            aSpriteBatch.DrawString(myFont, myText, myPosition, Color.White);

            //aSpriteBatch.DrawString(myFont,
            //    "Bonus time: " + myChainTimer.ToString() +
            //    "\nGame Time: " + myGameTime.ToString() +
            //    "\nGame Speed: " + myGameSpeed.ToString()
            //    , new Vector2(500, 100), Color.MidnightBlue);
        }
Example #21
0
    IEnumerator DisappearSprite(Sprite s, float time)
    {
        float step = 1 / time;
        Color c    = Color.white;

        while (s.color.a > 0)
        {
            c.a = Mathf.Max(0.0f, c.a - step * Time.deltaTime);
            s.SetColor(c);
            yield return(new WaitForEndOfFrame());
        }

        DefaultSpriteUI.HideSprite(s);
    }
Example #22
0
 public AbstractBullet(IGameObject shooter, Vector2 position, float damage, Color?color, float lifeTime = -1)
 {
     this.shooter = shooter;
     Position     = position;
     Damage       = damage;
     sprite       = SpriteFactory.CreateSprite(this.GetType());
     if (color is null)
     {
         color = Color.White;
     }
     sprite.SetColor(new Collection <Color> {
         (Color)color
     });
     this.lifeTime = lifeTime;
 }
Example #23
0
        public BreakPointBody(TextureManager _t, int color, int select)
        {
            float   x       = color * 8 * per_256 + select * 2 * per_256;
            Texture texture = _t.Get("Ef_etama2");

            body         = new Sprite();
            body.Texture = texture;
            body.SetWidth(8);
            body.SetHeight(8);
            float leftop_x = color * 8 * per_256 + select * 2 * per_256;

            body.SetUVs(leftop_x, 30 * per_256,
                        leftop_x + 2 * per_256, 32 * per_256);
            body.SetColor(new Color(1, 1, 1, 0.5f));
        }
Example #24
0
 private void UpdateMaddyCrown(Player player)
 {
     if (Settings.DoMaddyCrown && maddyCrownSprite == null)
     {
         foreach (Sprite sprite in player.Components.GetAll <Sprite>())
         {
             if (sprite.Animations.ContainsKey("crown"))
             {
                 maddyCrownSprite = sprite;
             }
         }
     }
     if (Settings.DoMaddyCrown && maddyCrownSprite != null)
     {
         maddyCrownSprite.SetColor(lastColor);
     }
 }
Example #25
0
        public static Node Create()
        {
            var cmp = new MyMouseSelector ();

            var spr = new Sprite (1, 1);
            spr.SetColor (255, 64, 64, 64);

            var col = new CollisionObject ();
            col.Shape = new BoxShape (1, 1, 1);

            var node = new Node ("MouseSelector");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);

            node.DrawPriority = -1;
            node.Visible = false;

            return node;
        }
Example #26
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyMouseSelector ();
            cmp.start = Graphics2D.GetInstance ().GetMousePosition ();

            var spr = new Sprite (1, 1);
            spr.SetColor (255, 64, 64, 64);

            var col = new CollisionObject ();
            col.Shape = new BoxShape (1, 1, 1);

            var node = new Node ("MouseSelector");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);

            node.DrawPriority = -1;
            node.Translation = pos;

            return node;
        }
Example #27
0
        public static Node Create()
        {
            var cmp = new MyMouseSelector ();

            var spr = new Sprite (1, 1);
            spr.AddTexture (new Texture ("media/image128x128(Purple).png"));
            spr.SetColor (255, 255, 255, 64);

            var col = new BoxCollision (600, 900, 0);
            col.SetOffset (600, 900, 0);

            var node = new Node ("MouseSelector");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);
            node.DrawPriority = -1;

            node.Drawable = false;

            return node;
        }
Example #28
0
    public HUD(Player pPlayer)
    {
        //Getting the player
        _player = pPlayer;

        //Scoreboard Initialization
        _scoreboardX        = MyGame.OldX() - 160;
        _scoreboardX_offset = 25;
        _scoreboardY        = 20;
        _scoreboard         = new TextBox(game.width, game.height, _scoreboardX, _scoreboardY);
        _scoreText          = "score:";
        _initialScoreLength = _scoreText.Length;
        AddChild(_scoreboard);

        //Energy Bar
        _energyBack = new Sprite("assets/hud/energy.png");
        AddChild(_energyBack);
        _energyBack.SetXY(-10, 10);
        _energyBack.scaleX = 2;
        _energyBack.scaleY = 0.5f;
        _energyFront       = new Sprite("assets/hud/button_new.png");
        AddChild(_energyFront);
        _energyFront.SetXY(30, 19);
        _energyFront.scaleX = 3.3f;
        _energyFront.scaleY = 0.5f;
        _energyFront.SetColor(0, 1, 1);

        //Energy Meter initialization
        _energyX     = 20;
        _energyY     = 20;
        _energyMeter = new TextBox(game.width, game.height, _energyX, _energyY);
        AddChild(_energyMeter);

        //Testing Purposes
        _fpsX       = 20;
        _fpsY       = MyGame.OldY() - 40;
        _fpsCounter = new TextBox(game.width, game.height, _fpsX, _fpsY);
        AddChild(_fpsCounter);
        barOrMeter = true; // true for bar, false for meter
    }
Example #29
0
        public Player(float x, float y) : base(x, y, 1, 1, 1)
        {
            PlayerIndex = PlayerIndex.One;
            input       = new Input(PlayerIndex);

            sightLength    = 50;
            fov            = 135 * (float)Math.PI * 2 / 360;
            angleIncrement = 15 * (float)Math.PI * 2 / 360;
            angle          = (float)Math.PI / 2;

            MoveSpeed        = 15f;
            terminalVelocity = 10;
            turningForce     = 2;
            deceleration     = 2f;

            car = new Sprite(X, Y, Sprite.Type.Car);
            car.SetCenter(8, 8);
            car.Rotation = angle;
            roof         = new Sprite(X, Y, Sprite.Type.Roof);
            roof.SetCenter(8, 8);
            roof.Rotation = angle;

            rays = new List <Ray2D>();

            checkPointIndex = 0;

            CreateRays();

            Brain  = new NeuralNetwork(rays.Count + 3, 2, rays.Count + 3 + 2, 3, ActivationFunction.Functions.ReLU);
            inputs = new double[Brain.TotalInputNodes];

            progress = new Timer(3000);

            r           = Playfield.RNG.Next(0, 256);
            g           = Playfield.RNG.Next(0, 256);
            b           = Playfield.RNG.Next(0, 256);
            ObjectColor = new Color(r, g, b);
            roof.SetColor(ObjectColor);
        }
Example #30
0
        /// <summary>
        /// 通过Bonus_Font进行书写文字
        /// </summary>
        /// <param name="renderer">着色器</param>
        /// <param name="font">Bonus_Font工具</param>
        /// <param name="str">需要书写的字符串</param>
        /// <param name="x">字符串中心的坐标x位置</param>
        /// <param name="y">字符串中心的坐标y位置</param>
        /// <param name="alpha">显示透明度</param>
        /// <param name="dis">字体间的间距</param>
        public static void WriteText(Renderer renderer, Bonus_Font font, string str,
                                     double x, double y, float alpha = 1, float dis = 8)
        {
            char[] Arr      = str.ToCharArray();
            int    lenth    = Arr.Length;
            float  offset_x = -(lenth / 2) * dis;          //坐标偏移量

            for (int i = 0; i < lenth; i++)
            {
                Sprite sp = font.GetChar(Arr[i].ToString());
                if (Arr[i] != '/')
                {
                    sp.SetPosition(x + dis * i + offset_x, y);
                }
                else
                {
                    sp.SetPosition(x + dis * i + offset_x, y + 4);
                }
                sp.SetColor(new Color(1, 1, 1, alpha));
                renderer.DrawSprite(sp);
            }
        }
Example #31
0
    public CharacterSprite CreateSprite(char c)
    {
        CharacterData charData = _characterData[c];
        Sprite        sprite   = new Sprite();

        sprite.Texture = _texture;

        // Setup UVs
        Point topLeft = new Point(
            (float)charData.X / (float)_texture.Width,
            (float)charData.Y / (float)_texture.Height);

        Point bottomRight = new Point(
            topLeft.X + ((float)charData.Width / (float)_texture.Width),
            topLeft.Y + ((float)charData.Height / (float)_texture.Height));

        sprite.SetUVs(topLeft, bottomRight);
        sprite.SetWidth(charData.Width);
        sprite.SetHeight(charData.Height);
        sprite.SetColor(new Color(1, 1, 1, 1));

        return(new CharacterSprite(sprite, charData));
    }
Example #32
0
		void CreateSprites()
		{
			var cache = ResourceCache;
			var graphics = Graphics;
			UI ui = UI;

			// Get the Urho3D fish texture
			Texture2D decalTex = cache.GetTexture2D("Textures/UrhoDecal.dds");

			for (uint i = 0; i < NumSprites; ++i)
			{
				// Create a new sprite, set it to use the texture
				Sprite sprite = new Sprite();
				sprite.Texture = decalTex;

				// The UI root element is as big as the rendering window, set random position within it
				sprite.Position = new IntVector2((int) (NextRandom()*graphics.Width), (int) (NextRandom()*graphics.Height));

				// Set sprite size & hotspot in its center
				sprite.Size = new IntVector2(128, 128);
				sprite.HotSpot = new IntVector2(64, 64);

				// Set random rotation in degrees and random scale
				sprite.Rotation = NextRandom()*360.0f;
				sprite.SetScale(NextRandom(1.0f) + 0.5f);

				// Set random color and additive blending mode
				sprite.SetColor(new Color(NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f));
				sprite.BlendMode = BlendMode.Add;

				// Add as a child of the root UI element
				ui.Root.AddChild(sprite);

				// Store sprites to our own container for easy movement update iteration
				spritesWithVelocities[sprite] = new Vector2(NextRandom(200.0f) - 100.0f, NextRandom(200.0f) - 100.0f);
			}
		}
Example #33
0
        void CreateSprites()
        {
            var cache    = ResourceCache;
            var graphics = Graphics;
            UI  ui       = UI;

            // Get the Urho3D fish texture
            Texture2D decalTex = cache.GetTexture2D("Textures/UrhoDecal.dds");

            for (uint i = 0; i < NumSprites; ++i)
            {
                // Create a new sprite, set it to use the texture
                Sprite sprite = new Sprite();
                sprite.Texture = decalTex;

                // The UI root element is as big as the rendering window, set random position within it
                sprite.Position = new IntVector2((int)(NextRandom() * graphics.Width), (int)(NextRandom() * graphics.Height));

                // Set sprite size & hotspot in its center
                sprite.Size    = new IntVector2(128, 128);
                sprite.HotSpot = new IntVector2(64, 64);

                // Set random rotation in degrees and random scale
                sprite.Rotation = NextRandom() * 360.0f;
                sprite.SetScale(NextRandom(1.0f) + 0.5f);

                // Set random color and additive blending mode
                sprite.SetColor(new Color(NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f));
                sprite.BlendMode = BlendMode.Add;

                // Add as a child of the root UI element
                ui.Root.AddChild(sprite);

                // Store sprites to our own container for easy movement update iteration
                spritesWithVelocities[sprite] = new Vector2(NextRandom(200.0f) - 100.0f, NextRandom(200.0f) - 100.0f);
            }
        }
Example #34
0
        public Lamp(EntityData data, Vector2 offset) : base(data.Position + offset)
        {
            id               = data.ID;
            flag             = data.Attr("flag", "");
            baseColor        = ColorHelper.GetColor(data.Attr("baseColor", "White"));
            lightColor       = ColorHelper.GetColor(data.Attr("lightColor", "White"));
            lightStartRadius = data.Int("lightStartRadius", 48);
            lightEndRadius   = data.Int("lightEndRadius", 64);
            inverted         = data.Bool("inverted", false);

            Add((Component)(startupSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/start")));
            startupSprite.AddLoop("start", "", startupAnimationDelay);
            startupSprite.JustifyOrigin(0.5f, 0.5f);
            startupSprite.Play("start");
            startupSprite.OnLastFrame = onLastFrame;
            startupLerpTotal          = startupAnimationDelay * startupSprite.CurrentAnimationTotalFrames;
            startupSprite.Stop();

            Add((Component)(idleSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/idle")));
            idleSprite.AddLoop("idle", "", 0.125f);
            idleSprite.JustifyOrigin(0.5f, 0.5f);
            idleSprite.Play("idle");
            idleSprite.Visible = false;

            Add((Component)(baseSprite = new Sprite(GFX.Game, "objects/pandorasBox/lamp/base")));
            baseSprite.AddLoop("base", "", 0.1f);
            baseSprite.JustifyOrigin(0.5f, 0.5f);
            baseSprite.Play("base");
            baseSprite.SetColor(baseColor);

            inStartupAnimation = false;

            Add((Component)(bloom = new BloomPoint(0.5f, 8f)));
            Add((Component)(light = new VertexLight(lightColor, 1f, lightStartRadius, lightEndRadius)));

            Depth = 5;
        }
Example #35
0
 public BreakPointBody(TextureManager _t, int color, int select)
 {
     float x = color * 8 * per_256 + select * 2 * per_256;
     Texture texture = _t.Get("Ef_etama2");
     body = new Sprite();
     body.Texture = texture;
     body.SetWidth(8);
     body.SetHeight(8);
     float leftop_x = color * 8 * per_256 + select * 2 * per_256;
     body.SetUVs(leftop_x, 30 * per_256,
         leftop_x + 2 * per_256, 32 * per_256);
     body.SetColor(new Color(1, 1, 1, 0.5f));
 }
Example #36
0
 public FLowerBody(TextureManager _t,float w_h = 16)
 {
     Texture texture = _t.Get("Ef_etama2");
     body = new Sprite();
     body.Texture = texture;
     body.SetWidth(w_h);
     body.SetHeight(w_h);
     body.SetUVs(2 * per_256, 12 * per_256, 4 * per_256, 14 * per_256);
     body.SetColor(new Color(1, 1, 1, 1));
 }
Example #37
0
        public void Test_SetColor()
        {
            var spr = new Sprite (64, 64);

            spr.Color = new Color (1, 2, 3, 4);
            Assert.AreEqual (new Color (1, 2, 3, 4), spr.Color);

            spr.SetColor (5, 6, 7, 8);
            Assert.AreEqual (new Color (5, 6, 7, 8), spr.Color);
        }