Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //defaults the hand to be untoggled
        showingHand      = false;
        pos              = transform.position;
        handSpriteRender = gameObject.GetComponent <SpriteRenderer>();
        //resize the sprite[] to 40, to hold all card sprites
        Array.Resize(ref cardSprites, 50);
        Resources.LoadAll <Sprite>("Assets/Cards").CopyTo(cardSprites, 0);
        //initializes array and used scripts
        spriteArray = this.GetComponent <SpriteArray>();
        deckHandler = playerDeck.GetComponent <DeckHandler>();
        cardData    = cards.GetComponent <CardData>();
        //initializes and tells the button "place" what to do
        Button placeCard = place.GetComponent <Button>();

        placeCard.onClick.AddListener(PlaceCards);
        //initializes the card places and attack text
        card1Sprite = card1.GetComponent <SpriteRenderer>();
        card2Sprite = card2.GetComponent <SpriteRenderer>();
        card3Sprite = card3.GetComponent <SpriteRenderer>();
        atkTxtMsh1  = atkTxt1.GetComponent <TextMesh>();
        atkTxtMsh2  = atkTxt2.GetComponent <TextMesh>();
        atkTxtMsh3  = atkTxt3.GetComponent <TextMesh>();
        hlthTxtMsh1 = hlthTxt1.GetComponent <TextMesh>();
        hlthTxtMsh2 = hlthTxt2.GetComponent <TextMesh>();
        hlthTxtMsh3 = hlthTxt3.GetComponent <TextMesh>();
    }
 public void InitializeFromSprites(ushort location, SpriteArray sprites)
 {
     Memory = new Memory();
     foreach (var sprite in sprites)
     {
         Memory.SetBytes(new SimpleLocation((Address)location), sprite.GetBytes());
         location += 63;
     }
     spriteToolStripMenuItem_Click(null, new EventArgs());
 }
    void RandomizeTweet()
    {
        int randomChannel = Random.Range(0, ChannelPositions.Length);

        renderer.material.color = ChannelColors [randomChannel];

        SpriteArray tweets      = TweetImages [randomChannel];
        int         randomTweet = Random.Range(0, tweets.Sprites.Length);

        CurrentTweet = tweets.Sprites [randomTweet];
    }
Ejemplo n.º 4
0
		public void SaveScene(string fileName, Camera cameraPosition, SpriteArray spriteArray, bool snapping, float PixelSize, StringArrayArray SpriteArrays, SpriteManager sprMan)
		{
			spriteArrays = SpriteArrays;
			camera = new CameraSave(cameraPosition);
			snappingOn = snapping;
			pixelSize = PixelSize;
			ssa.AddSpriteArray(spriteArray, sprMan);
			FileStream stream= File.Create(fileName);
			BinaryFormatter binFormatter = new BinaryFormatter();
			binFormatter.Serialize(stream, this);
			stream.Close();
		}
Ejemplo n.º 5
0
        public void SaveScene(string fileName, Camera cameraPosition, SpriteArray spriteArray, bool snapping, float PixelSize, StringArrayArray SpriteArrays, SpriteManager sprMan)
        {
            spriteArrays = SpriteArrays;
            camera       = new CameraSave(cameraPosition);
            snappingOn   = snapping;
            pixelSize    = PixelSize;
            ssa.AddSpriteArray(spriteArray, sprMan);
            FileStream      stream       = File.Create(fileName);
            BinaryFormatter binFormatter = new BinaryFormatter();

            binFormatter.Serialize(stream, this);
            stream.Close();
        }
Ejemplo n.º 6
0
        public static void Paint(Graphics g, bool redrawBackground, Color backColor, int windowWidth, int windowHeight, int extraOffsetY, SpriteEditor spriteEditor, SpriteArray sprites, C64Sprite sprite, ColorPicker colorPicker)
        {
            g.CompositingMode    = CompositingMode.SourceOver;
            g.CompositingQuality = CompositingQuality.AssumeLinear;
            g.SmoothingMode      = SmoothingMode.None;
            g.InterpolationMode  = InterpolationMode.NearestNeighbor;
            g.PixelOffsetMode    = PixelOffsetMode.HighSpeed;

            if (redrawBackground)
            {
                g.Clear(backColor);
            }

            spriteEditor.X = 10;
            spriteEditor.Y = 10 + ColorPickerCell.Size + extraOffsetY;

            var pw = (windowWidth - 200) / C64Sprite.Width;
            var ph = (windowHeight - 200) / C64Sprite.Height;

            spriteEditor.PixelSize = Math.Min(pw, ph);
            spriteEditor.PixelSize = spriteEditor.PixelSize < 6 ? 6 : spriteEditor.PixelSize;

            var doubleSize    = windowWidth * 1.5 > windowHeight;
            var spritesStartX = doubleSize ? windowWidth - 68 : windowWidth - 44;
            var spritesStartY = spriteEditor.Y;

            for (var i = 0; i < SpriteArray.Length; i++)
            {
                sprites[i].Draw(g, spritesStartX, spritesStartY, doubleSize);
                spritesStartY += doubleSize ? 44 : 22;
            }

            spriteEditor.Draw(g);
            ColorPickerCell.Size = spriteEditor.PixelSize * 2;

            colorPicker.Draw(
                g,
                sprite,
                spriteEditor.X,
                spriteEditor.Y - (ColorPickerCell.Size + 8)
                );
        }
Ejemplo n.º 7
0
        public static IEnumerator FadeSequence(SpriteRenderer im, Vector2 range, float time, Easings.Functions fun, SpriteArray sa)
        {
            float startTime = Time.time;
            float numb      = range.y - range.x;

            float add       = 0;
            int   index     = 0;
            int   lastIndex = -99;

            int length = sa.alphaMaskSequence.Length - 1;

            while (Time.time - startTime < time)
            {
                add = range.x + numb * Easings.Interpolate((Time.time - startTime) / time, fun);

                index = (int)(add * length);

                if (index != lastIndex)
                {
                    im.material.SetTexture("_DissolveTex", sa.alphaMaskSequence[index]);
                    lastIndex = index;
                }
                yield return(null);
            }

            im.material.SetTexture("_DissolveTex", sa.alphaMaskSequence[(int)(range.y * length)]);
#if (PRINT)
            Debug.Log("Coroutine 'FadeSequence' ended in " + (Time.time - startTime));
#endif
        }
Ejemplo n.º 8
0
        private MiEntity CreateBackground()
        {
            RenderWindow window = Manager.Game.Window;

            MiEntity bg = new MiEntity("Background", window);

            if (!bg.AddNewComponent <SpriteArray>())
            {
                return(Logger.LogReturn <MiEntity>("Failed creating background components.", null, LogType.Error));
            }

            View      view = window.GetView();
            Texture   ptr  = Program.Theme.PointerTexture;
            Transform trn  = bg.GetComponent <Transform>();

            trn.Size = new Vector2f(view.Size.X - ((ptr?.Size.X ?? 0) * Program.Theme.PointerScale.X), view.Size.Y);

            switch (Program.PointerDirection)
            {
            case Direction.Left:
                trn.Position = new Vector2f((ptr?.Size.X ?? 0) * Program.Theme.PointerScale.X, 0.0f);
                break;

            case Direction.Right:
                trn.Position = new Vector2f(0.0f, 0.0f);
                break;
            }

            SpriteArray spr = bg.GetComponent <SpriteArray>();

            spr.TexturePath = Program.Theme.BackgroundPath;

            Vector2u texsize = spr.Texture.Size;
            float    third   = texsize.X / 3.0f;

            FloatRect tl = new FloatRect(0, 0, third, third),
                      t  = new FloatRect(third, 0, third, third),
                      tr = new FloatRect(third * 2, 0, third, third),
                      l  = new FloatRect(0, third, third, third),
                      m  = new FloatRect(third, third, third, third),
                      r  = new FloatRect(third * 2, third, third, third),
                      bl = new FloatRect(0, third * 2, third, third),
                      b  = new FloatRect(third, third * 2, third, third),
                      br = new FloatRect(third * 2, third * 2, third, third);

            Settings settings = Program.FolderSettings;

            Vector2u cellsize;
            {
                uint csize = Program.GetCellSize();

                cellsize.X = csize;
                cellsize.Y = settings.DisplayType == IconDisplayType.IconOnly ?
                             csize : (uint)((float)(csize / 3.0f) * 4);
            }

            Vector2u cellcount = settings.DisplayType == IconDisplayType.IconOnly ?
                                 settings.GridCells * 3 :
                                 new Vector2u(settings.GridCells.X * 3, settings.GridCells.Y * 4);

            Vector2f sprsize = new Vector2f(cellsize.X / 3.0f,
                                            cellsize.X / 3.0f);

            for (int y = 0; y < cellcount.Y; y++)
            {
                for (int x = 0; x < cellcount.X; x++)
                {
                    FloatRect rect;

                    if (x == 0)
                    {
                        if (y == 0)
                        {
                            rect = tl;
                        }
                        else if (y == (cellcount.Y - 1))
                        {
                            rect = bl;
                        }
                        else
                        {
                            rect = l;
                        }
                    }
                    else if (x == cellcount.X - 1)
                    {
                        if (y == 0)
                        {
                            rect = tr;
                        }
                        else if (y == (cellcount.Y - 1))
                        {
                            rect = br;
                        }
                        else
                        {
                            rect = r;
                        }
                    }
                    else
                    {
                        if (y == 0)
                        {
                            rect = t;
                        }
                        else if (y == (cellcount.Y - 1))
                        {
                            rect = b;
                        }
                        else
                        {
                            rect = m;
                        }
                    }

                    spr.Sprites.Add(new SpriteInfo(rect, Program.Theme.Color,
                                                   new Vector2f(sprsize.X * x, sprsize.Y * y),
                                                   sprsize));
                }
            }

            return(bg);
        }