Ejemplo n.º 1
0
        public SpriteCoin(Sprint4 game) : base(game)
        {
            this.Info.frameDelay   = 12;
            this.Info.harmfulIndex = -1;

            SpriteUtils.SetDefaultProperties(this, "Sprites/Items/coin");
        }
 public SpritedBattlePokemon(PBEBattlePokemon pkmn)
 {
     Pkmn        = pkmn;
     Minisprite  = SpriteUtils.GetMinisprite(pkmn.OriginalSpecies, pkmn.RevertForm, pkmn.Gender, pkmn.Shiny);
     FrontSprite = SpriteUtils.GetPokemonSprite(pkmn.OriginalSpecies, pkmn.RevertForm, pkmn.Gender, pkmn.Shiny, false, false);
     BackSprite  = SpriteUtils.GetPokemonSprite(pkmn.OriginalSpecies, pkmn.RevertForm, pkmn.Gender, pkmn.Shiny, true, false);
 }
Ejemplo n.º 3
0
    private void LoadQuestionImages(string path)
    {
        // TODO: replace with ImageStore.LoadAll
        var textures = Resources.LoadAll(path, typeof(Texture2D));

        // load sprites into list
        var list = new List <Card>();

        for (int i = 0; i < textures.Length; i++)
        {
            var sprite = SpriteUtils.Create((Texture2D)textures[i]);
            var card   = new Card(sprite, textures[i].name);
            list.Add(card);
        }

        // randomize list and create new stack
        list          = ListUtils.Randomize <Card>(list);
        questionCards = new Stack <Card>(list);

        // alloc answer cards
        answerCards = new Stack <Card> [MAX_STACKS];
        for (int i = 0; i < answerCards.Length; i++)
        {
            var newList = new Stack <Card>();
            answerCards[i] = newList;
        }

        totalQuestionCount = questionCards.Count;
    }
Ejemplo n.º 4
0
 public void Reveal()
 {
     if (!SpriteLayer.CollisionLayer.Sprites.Contains(this))
     {
         SpriteUtils.RevealItem(this.game, this);
     }
 }
Ejemplo n.º 5
0
    void OnJointBreak2D(Joint2D brokenJoint)
    {
        var center = (SpriteUtils.GetWolrdPositions(brokenJoint.attachedRigidbody.GetComponent <SpriteRenderer>()).Center + SpriteUtils.GetWolrdPositions(spriteRenderer).Center) / 2;
        var ps     = particleSystemContainer.NextAndPlay();

        ps.transform.position = new Vector3(center.x, center.y, Z_POSSITION);
    }
Ejemplo n.º 6
0
 public void AddSprite(SpriteCollection sprite)
 {
     lock (this)
     {
         Console.WriteLine("Adding sprite {0} to layer {1}", sprite.name, this.name);
         sprite.Info.paralaxLayer = this.Paralax;
         this.Sprites.Add(sprite);
     }
     if (this == CollisionLayer)
     {
         if (sprite.isStatic())
         {
             if (CollisionHandler.grid != null)
             {
                 List <int[]> grids = SpriteUtils.DetermineGrids(sprite);
                 foreach (int[] grid in grids)
                 {
                     CollisionHandler.grid[grid[0], grid[1]].Add(sprite);
                 }
             }
             CollisionHandler.statics.Add(sprite);
         }
         else
         {
             CollisionHandler.dynamics.Add(sprite);
         }
     }
 }
Ejemplo n.º 7
0
 public SpritePipe(Sprint4 game) : base(game)
 {
     SpriteUtils.SetDefaultProperties(this, "Sprites/Obstacles/pipetop");
     this.Info.bounds      = game.bounds;
     this.Info.spriteWidth = 32;
     this.Info.numFrames   = 1;
 }
Ejemplo n.º 8
0
        public SpriteBrokenBrick(Sprint4 game, int frame) : base(game)
        {
            this.Info.frameDelay   = 10;
            this.Info.bounds       = game.bounds;
            this.Info.spriteWidth  = 8;
            this.Info.currentFrame = frame;
            this.Info.bounds       = game.bounds;

            SpriteUtils.SetDefaultProperties(this, "Sprites/Blocks/broken_brick2");

            switch (frame)
            {
            case 0: this.Info.velocity.X = -1;
                break;

            case 1: this.Info.velocity.X = 1;
                break;

            case 2: this.Info.velocity.X = 1;
                this.Info.velocity.Y     = -2;
                break;

            case 3: this.Info.velocity.X = -1;
                this.Info.velocity.Y     = -2;
                break;

            default:
                this.Info.velocity.X = 1;
                break;
            }
        }
Ejemplo n.º 9
0
        private void rebuildTextureAtlasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!data.Build.NeedsRepack)
            {
                MessageBox.Show("The build data does not have any changes that require repacking.");
            }
            else
            {
                try
                {
                    Sprite[] sprites = SpriteUtils.BuildSprites(data.Texture, data.Build);
                    SpriteUtils.ResizeSprites(sprites);
                    data.Texture = SpriteUtils.RebuildAtlas(sprites);
                    foreach (var spr in sprites)
                    {
                        spr.FrameData.NeedsRepack = false;
                    }
                }
                catch
                { }

                UpdateAtlasView(data.Texture);
                propertyGrid.Refresh();
            }
        }
Ejemplo n.º 10
0
        /*
         *  Mushroom is a different sprite in that it is hidden behind a block before it is shown.
         *  it is added to the main sprite collection when you call MushroomAppear().
         *
         *  if you want the mushroom to be instantly visible, add it to the sprite collection
         *  as normal. It will be still if you do this unless you call Move();
         */
        public SpriteFireFlower(Sprint4 game) : base(game)
        {
            this.Info.layer        = 0.5f;
            this.Info.harmfulIndex = -1;

            SpriteUtils.SetDefaultProperties(this, "Sprites/Items/fireflower");
        }
Ejemplo n.º 11
0
 public void Reveal()
 {
     if (!SpriteLayer.CollisionLayer.Sprites.Contains(this))
     {
         Task <bool> t = SpriteUtils.RevealItem(this.game, this);
         Task.Factory.StartNew(delegate() { t.Wait(); this.Move(); });
     }
 }
Ejemplo n.º 12
0
        public void AddSkeleton(Vector2f pos, Vector2f scale)
        {
            var skeletonEnemy = enemySkeleton.Clone();

            skeletonEnemy.sprite.Origin = SpriteUtils.GetSpriteCenter(skeletonEnemy.sprite);
            skeletonEnemy.Position(pos.X, pos.Y);
            skeletonEnemy.Scale(scale.X, scale.Y);
            _enemies.Add(skeletonEnemy);
        }
Ejemplo n.º 13
0
        public void AddZombie(Vector2f pos, Vector2f scale)
        {
            var zombieEnemy = enemyZombie.Clone();

            zombieEnemy.sprite.Origin = SpriteUtils.GetSpriteCenter(zombieEnemy.sprite);
            zombieEnemy.Position(pos.X, pos.Y);
            zombieEnemy.Scale(scale.X, scale.Y);
            _enemies.Add(zombieEnemy);
        }
Ejemplo n.º 14
0
        public void AddGhost(Vector2f pos, Vector2f scale)
        {
            var ghostEnemy = enemyGhost.Clone();

            ghostEnemy.sprite.Origin = SpriteUtils.GetSpriteCenter(ghostEnemy.sprite);
            ghostEnemy.Position(pos.X, pos.Y);
            ghostEnemy.Scale(scale.X, scale.Y);
            _enemies.Add(ghostEnemy);
        }
Ejemplo n.º 15
0
        public IEnumerator SetJacketCoroutine(string path)
        {
            UnityWebRequest www = UnityWebRequestTexture.GetTexture("file://" + path);

            yield return(www.SendWebRequest());

            Texture2D tex = DownloadHandlerTexture.GetContent(www);

            selectedJacket.sprite = SpriteUtils.CreateCentered(tex);
        }
Ejemplo n.º 16
0
        protected override IEnumerator LoadCellFullyCoroutine(CellDataBase cellDataBase)
        {
            string          path = level.GetRealPath(chart.ImagePath);
            UnityWebRequest www  = UnityWebRequestTexture.GetTexture("file://" + path);

            yield return(www.SendWebRequest());

            Texture2D tex = DownloadHandlerTexture.GetContent(www);

            image.sprite = SpriteUtils.CreateCentered(tex);
        }
Ejemplo n.º 17
0
        public SpriteBackground(Sprint4 game) : base(game)
        {
            SpriteUtils.SetDefaultProperties(this, "Sprites/Background");

            //this.Info.scale = 1.5f;
            this.Info.layer        = 0;
            this.Info.scale        = 1f;
            this.Info.numFrames    = 1;
            this.Info.spriteWidth  = 515;
            this.Info.paralaxLayer = 0.6f;
        }
Ejemplo n.º 18
0
 public virtual void Update(GameTime gameTime)
 {
     if (this.current != null)
     {
         SpriteUtils.UpdateAnimation(this.Info);
         SpriteUtils.MoveSprite(this);
     }
     else
     {
         Console.WriteLine("[Animate] current is null");
     }
 }
Ejemplo n.º 19
0
    public void Init(int p_playerId)
    {
        if (m_mouseParent)
        {
            m_cursor = Instantiate(m_mousePrefab, m_mouseParent.transform);
        }
        else
        {
            m_cursor = Instantiate(m_mousePrefab);
        }

        m_uiCursor = Instantiate(m_uiCursorPrefab, m_uiCanvas.transform).GetComponent <UICursor>();

        m_mouse = m_cursor.GetComponent <PlayerMouse>();
        m_mouse.useHardwarePointerPosition = false;
        m_mouse.playerId = p_playerId;
        m_rewiredPlayer  = Rewired.ReInput.players.GetPlayer(p_playerId);

        if (Player.m_players.Count > 0)
        {
            m_player = Player.GetPlayerFromId(p_playerId);
        }

        m_mouse.leftButton.actionName  = "UIInteract1";
        m_mouse.rightButton.actionName = "UIInteract3";
        //m_mouse.middleButton.actionName = "UIInteract3";
        m_mouse.wheel.yAxis.actionName = "UIWheelY";

        float sens = (float)Game.m_options.LoadOptionInt("Sensitivity" + "_" + p_playerId, 100).GetInt() / 50f;
        float size = (float)Game.m_options.LoadOptionInt("CursorSize" + "_" + p_playerId, 100).GetInt() / 200f;

        m_mouse.pointerSpeed            = sens;
        m_uiCursor.transform.localScale = new Vector3(size, size, size);

        List <PlayerMouse> mice = Game.m_rewiredEventSystem.PlayerMice;

        mice.Add(m_mouse);
        Game.m_rewiredEventSystem.PlayerMice = mice;

        ChangeMode(m_useUICoordinatesOnly ? CursorModes.CURSOR : CursorModes.LINE, true);

        m_mouse.ScreenPositionChangedEvent += OnScreenPositionChanged;
        m_mouse.screenPosition              = new Vector2(Screen.width / 2, Screen.height / 2 + 1);

        string cursorSprite = Game.m_options.Get("CursorSprite", p_playerId).GetString();
        Sprite sprite       = SpriteUtils.LoadSpriteFromFile(Application.dataPath + "/Data/Cursors/" + cursorSprite + ".png");

        if (sprite != null)
        {
            SetCursorImage(sprite);
        }
    }
Ejemplo n.º 20
0
        /*
         *  Mushroom is a different sprite in that it is hidden behind a block before it is shown.
         *  it is added to the main sprite collection when you call MushroomAppear().
         *
         *  if you want the mushroom to be instantly visible, add it to the sprite collection
         *  as normal. It will be still if you do this unless you call Move();
         */
        public SpriteMushroom(Sprint4 game, String path) : base(game)
        {
            this.Info.layer        = 0.5f;
            this.Info.harmfulIndex = -1;

            if (path.Contains("oneupshroom"))
            {
                this.oneUp = true;
            }

            SpriteUtils.SetDefaultProperties(this, path);
            this.Info.bounce = true;
        }
Ejemplo n.º 21
0
    void CreateSprite()
    {
        Texture2D tex = SpriteUtils.LoadTexture("Images/" + mImageFilename);

        if (tex == null)
        {
            return;
        }

        int    w      = tex.width > 140 ? 140 : tex.width;
        int    h      = tex.height > 140 ? 140 : tex.height;
        Sprite sprite = SpriteUtils.CreateSpriteFromTexture2D(tex, 0, 0, w, h);

        mSpriteRenderer.sprite = sprite;
    }
Ejemplo n.º 22
0
        // damage - placeDelay - bombTimer
        public Bomb(float dmg, float bombTimer, int currentBombType)
        {
            this.Damage = dmg;
            //this.PlaceSpeed = placeDelay;
            this.IgnitionDuration = bombTimer;
            CurrentBombType       = currentBombType;

            // Loading default bomb texture
            this.ProjectileSprite = SpriteLoader.LoadSprite(Resources.bomb, new IntRect(0, 0, 64, 64));
            this.Origin           = SpriteUtils.GetSpriteCenter(ProjectileSprite);

            // Loading explosion texture
            this.ExplosionSprite = SpriteLoader.LoadSprite(Resources.explosionSmall, new IntRect(0, 0, 64, 64));
            this.Texture         = ExplosionSprite.Texture;
        }
Ejemplo n.º 23
0
 public Flamethrower(IMediator mediator) : base(mediator)
 {
     this.Name             = "FlameThrower";
     this.MagazineSize     = 200;
     this.Ammo             = 200;
     this.Damage           = 10;
     this.ProjectileSpeed  = 500;
     this.AttackSpeed      = 20;
     this.ReloadDuration   = 2000;
     this.Projectiles      = new List <Projectile>();
     this.SpreadAmount     = 50;
     this.CanShoot         = true;
     this.ProjectileSprite = new Sprite(TextureHolder.GetInstance().Get(TextureIdentifier.Bullet));
     this.Texture          = TextureHolder.GetInstance().Get(TextureIdentifier.Flamethrower);
     this.Origin           = new Vector2f(SpriteUtils.GetSpriteCenter(this).X, 3f);
 }
Ejemplo n.º 24
0
        public void InitializePlayersInfo(bool loadImages = true)
        {
            string login1 = battle.Player1.Name;
            string login2 = battle.Player2.Name;

            MyLoginText.text       = login1;
            OpponentLoginText.text = login2;

            if (loadImages)
            {
                MyAvatar.sprite = SpriteUtils.TextureToSprite(GameManager.Instance.Avatar);
                PlayerHelper.GetAvatar(login2,
                                       texture => OpponentAvatar.sprite = SpriteUtils.TextureToSprite(texture),
                                       Debug.Log);
            }
        }
Ejemplo n.º 25
0
    void Update()
    {
        var carPositions   = SpriteUtils.GetWolrdPositions(carSpriteRenderer);
        var floorPositions = SpriteUtils.GetWolrdPositions(floorSpriteRenderer);

        if (carPositions.TopRight.x >= floorPositions.Center.x)
        {
            floor = Instantiate(floor, floor.transform.position + new Vector3(floorPositions.TopRight.x - floorPositions.TopLeft.x, 0), Quaternion.identity);
            floorSpriteRenderer = floor.GetComponent <SpriteRenderer>();
            floors.Enqueue(floor);
            if (floors.Count > 2)
            {
                Destroy(floors.Dequeue());
            }
        }
    }
Ejemplo n.º 26
0
 public AssaultRifle(IMediator mediator) : base(mediator)
 {
     this.Name             = "AK-47";
     this.MagazineSize     = 45;
     this.Ammo             = 45;
     this.Damage           = 25;
     this.ProjectileSpeed  = 2000;
     this.AttackSpeed      = 90;
     this.ReloadDuration   = 800;
     this.Projectiles      = new List <Projectile>();
     this.SpreadAmount     = 50;
     this.CanShoot         = true;
     this.ProjectileSprite = new Sprite(TextureHolder.GetInstance().Get(TextureIdentifier.Bullet));
     this.Texture          = TextureHolder.GetInstance().Get(TextureIdentifier.GunAk47);
     this.Origin           = new Vector2f(SpriteUtils.GetSpriteCenter(this).X, 3f);
 }
Ejemplo n.º 27
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            if (this.current != null)
            {
                Vector2   position = new Vector2(this.Info.x, this.Info.y);
                Rectangle source   = new Rectangle(this.Info.currentFrame * this.Info.spriteWidth / 2, 0, this.Info.spriteWidth / 2, this.Info.spriteHeight / 2);

                spriteBatch.Draw(
                    this.current,
                    position,
                    source,
                    Color.White,
                    0f,
                    new Vector2(0, 0),
                    this.Info.scale,
                    this.Info.spriteEffects,
                    this.Info.layer);

                if (this is ICollidable)
                {
                    Rectangle hitbox = SpriteUtils.GetHitbox(this);
                    this.hitboxT = new Texture2D(this.game.GraphicsDevice, hitbox.Width, hitbox.Height);
                    Color[] data = new Color[hitbox.Width * hitbox.Height];
                    for (int i = 0; i < data.Length; i++)
                    {
                        data[i] = this.Info.collisionColor;
                    }
                    this.hitboxT.SetData(data);

                    /*spriteBatch.Draw(hitboxT,
                     *  new Rectangle(hitbox.Left - this.game.CameraX, hitbox.Top, hitbox.Width, hitbox.Height),
                     *  new Rectangle(hitbox.Left, hitbox.Top, hitbox.Width, hitbox.Height),
                     *  Color.White,
                     *  0f,
                     *  new Vector2(0, 0),
                     *  SpriteEffects.None,
                     *  0f);//*/
                }
            }
            else
            {
                Console.WriteLine("[Draw] current is null");
            }
        }
Ejemplo n.º 28
0
        private void splitTextureAtlasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.ShowNewFolderButton = true;
            dlg.Description         = "Select a folder to save the exported frames...";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Sprite[] sprites = SpriteUtils.BuildSprites(data.Texture, data.Build);
                foreach (Sprite sprite in sprites)
                {
                    string frameFileName = $"{sprite.SymbolData.Name}_{sprite.FrameData.Index}.png";
                    string framePath     = Path.Combine(dlg.SelectedPath, frameFileName);
                    sprite.Image.Save(framePath, ImageFormat.Png);
                }
                Process.Start("explorer.exe", dlg.SelectedPath);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Loads data of currently logged in user and displays them.
        /// </summary>
        private void Load()
        {
            if (GameManager.Instance.IsInTrial)
            {
                PlayerNameText.text = TRIAL_PLAYER_NAME;
                FractionText.text   = TRIAL_FRACTION_TEXT;
            }
            else
            {
                PlayerNameText.text = GameManager.Instance.UserName;
                FractionText.text   = GameManager.Instance.IsOnline ? GameManager.Instance.Fraction.GetReadableName() : OFFLINE_FRACTION_TEXT;
            }

            int money = GameManager.Instance.Money;

            MoneyText.text           = money != -1 ? money.ToString() : "N/A";
            PlayerAvatarImage.sprite = SpriteUtils.TextureToSprite(GameManager.Instance.Avatar);
            RecountOnlineFriends();
        }
Ejemplo n.º 30
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            UserArrowControlled user = new UserArrowControlled(Default.GetUserTankSetting(Game, RightUserPosition), Default.GetMissileSetting(Game));

            MapInfo.user = user;
            tanks.Add(user);
            if (isTwoPLayer)
            {
                tanks.Add(new UserWASDControlled(Default.GetUserTankSetting(Game, LeftUserPosition), Default.GetMissileSetting(Game)));
            }

            MapInfo.Init(SpriteUtils.GetStaticMap(Game));

            //Configure Utils
            Collisions.Tanks = tanks;

            base.LoadContent();
        }