Ejemplo n.º 1
0
        /// <summary>
        /// A very verbose asset drawer.
        /// </summary>
        /// <param name="b"></param>
        /// <param name="npc"></param>
        /// <param name="position"></param>
        /// <param name="sourceRectangle"></param>
        /// <param name="color"></param>
        /// <param name="alpha"></param>
        /// <param name="origin"></param>
        /// <param name="scale"></param>
        /// <param name="effects"></param>
        /// <param name="layerDepth"></param>
        public override void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
        {
            //Class1.ModMonitor.Log(sourceRectangle.ToString());
            Vector2 generalOffset = new Vector2(0, 1 * Game1.tileSize); //Puts the sprite at the correct positioning.

            position -= new Vector2(0, 0.25f * Game1.tileSize);
            float smallOffset = 0.001f;
            float tinyOffset  = 0.0001f;
            //Class1.ModMonitor.Log((position - generalOffset).ToString());
            float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)npc.DefaultPosition.X * 20.0)) / 4.0));

            this.body.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bodyColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset);
            this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.eyeColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 1));
            this.hair.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.hairColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 2));

            if (num > 0.0f)
            {
                Vector2 shirtOffset = new Vector2((1 * Game1.tileSize) / 4, (1 * Game1.tileSize) / 4);
                this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, new Vector2(0.5f, 1), scale * Game1.pixelZoom + num, effects, layerDepth + smallOffset + (tinyOffset * 3));
            }
            else
            {
                this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 3));
            }
            this.pants.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bottomsColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 4));
            this.shoes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shoesColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 5));
            foreach (var accessory in this.accessories)
            {
                accessory.draw(b, npc, position - generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + 0.0006f);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Use this to add a new npc into the game.
 /// </summary>
 /// <param name="loc">The game location to add the npc to.</param>
 /// <param name="npc">The extended npc to add to the location.</param>
 public void addNewNPCToLocation(GameLocation loc, ExtendedNPC npc)
 {
     this.moddedNPCS.Add(npc);
     npc.defaultLocation = loc;
     npc.currentLocation = loc;
     loc.addCharacter(npc);
 }
 /// <summary>
 /// A very verbose asset drawer.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="npc"></param>
 /// <param name="position"></param>
 /// <param name="sourceRectangle"></param>
 /// <param name="color"></param>
 /// <param name="alpha"></param>
 /// <param name="origin"></param>
 /// <param name="scale"></param>
 /// <param name="effects"></param>
 /// <param name="layerDepth"></param>
 public void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
 {
     //DEFINITELY FIX THIS PART. Something is wrong with how these two functions handle the drawing of my npc to the scene.
     //this.draw(b, position, layerDepth);
     b.Draw(this.currentSprite.sprite.Texture, position, this.currentSprite.sprite.sourceRect, color, 0.0f, origin, scale, effects, layerDepth);
     //b.Draw(this.Sprite.Texture, npc.getLocalPosition(Game1.viewport) + new Vector2((float)(this.sprite.spriteWidth * Game1.pixelZoom / 2), (float)(this.GetBoundingBox().Height / 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(this.Sprite.SourceRect), Color.White * alpha, this.rotation, new Vector2((float)(this.sprite.spriteWidth / 2), (float)((double)this.sprite.spriteHeight * 3.0 / 4.0)), Math.Max(0.2f, this.scale) * (float)Game1.pixelZoom, this.flip || this.sprite.currentAnimation != null && this.sprite.currentAnimation[this.sprite.currentAnimationIndex].flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.991f : (float)this.getStandingY() / 10000f));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Add a npc to a location.
 /// </summary>
 /// <param name="loc">The game location to add an npc to.</param>
 /// <param name="npc">The extended npc to add to the location.</param>
 /// <param name="tilePosition">The tile position at the game location to add the mpc to.</param>
 public void addNewNPCToLocation(GameLocation loc, ExtendedNPC npc, Vector2 tilePosition)
 {
     this.moddedNPCS.Add(npc);
     npc.defaultLocation = loc;
     npc.currentLocation = loc;
     npc.position.Value  = tilePosition * Game1.tileSize;
     loc.addCharacter(npc);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Use this to completly remove and npc from the game as it is removed from the location and is no longer tracked.
 /// </summary>
 /// <param name="npc">The npc to remove from the location.</param>
 public void removeFromLocationAndTrackingList(ExtendedNPC npc)
 {
     if (npc.currentLocation != null)
     {
         npc.currentLocation.characters.Remove(npc);
     }
     this.moddedNPCS.Remove(npc);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Used to spawn a custom npc just as an example. Don't keep this code.
        /// GENERATE NPC AND CALL THE CODE
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveEvents_LoadChar(object sender, EventArgs e)
        {
            ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null));
            MerchantNPC merch  = new MerchantNPC(new List <Item>()
            {
                new StardewValley.Object(475, 999)
            }, myNpc3);

            npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch, new Vector2(2, 23));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc.
 /// </summary>
 /// <param name="npc"></param>
 public void setLeft(ExtendedNPC npc)
 {
     if (npc.characterRenderer == null)
     {
         return;
     }
     else
     {
         npc.characterRenderer.setLeft();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// A very verbose asset drawer.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="npc"></param>
 /// <param name="position"></param>
 /// <param name="sourceRectangle"></param>
 /// <param name="color"></param>
 /// <param name="alpha"></param>
 /// <param name="origin"></param>
 /// <param name="scale"></param>
 /// <param name="effects"></param>
 /// <param name="layerDepth"></param>
 public override void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
 {
     this.body.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     this.hair.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     this.eyes.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     this.shirt.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     this.pants.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     this.shoes.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     foreach (var accessory in this.accessories)
     {
         accessory.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
     }
 }
Ejemplo n.º 9
0
        private void SaveEvents_LoadChar(object sender, EventArgs e)
        {
            string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS", "Characters", "RainMan");

            assetManager.addPathCreateDirectory(new KeyValuePair <string, string>("characters", path));
            Texture2D tex = ModHelper.Content.Load <Texture2D>(Path.Combine(getShortenedDirectory(path).Remove(0, 1), "character.png"));

            ModMonitor.Log("PATH???: " + path);
            ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(Path.Combine(path, "character.png")), null, new Vector2(14, 14) * Game1.tileSize, 2, "b2");

            Game1.getLocationFromName("BusStop").addCharacter(myNpc3);
            myNpc3.SetMovingDown(true);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// A very verbose asset drawer.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="npc"></param>
 /// <param name="position"></param>
 /// <param name="sourceRectangle"></param>
 /// <param name="color"></param>
 /// <param name="alpha"></param>
 /// <param name="origin"></param>
 /// <param name="scale"></param>
 /// <param name="effects"></param>
 /// <param name="layerDepth"></param>
 public virtual void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the npc's portrait to be this portrait texture.
 /// </summary>
 /// <param name="npc"></param>
 public void setCharacterPortraitFromThis(ExtendedNPC npc)
 {
     npc.Portrait = this.portrait;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Wrapper for a draw function that accepts rectangles to be null.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="extendedNPC"></param>
 /// <param name="vector21"></param>
 /// <param name="v1"></param>
 /// <param name="white"></param>
 /// <param name="rotation"></param>
 /// <param name="vector22"></param>
 /// <param name="v2"></param>
 /// <param name="spriteEffects"></param>
 /// <param name="v3"></param>
 public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 position, Rectangle?v1, Color white, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float v3)
 {
     this.draw(b, extendedNPC, position, new Rectangle(0, 0, 16, 32), white, rotation, origin, scale, spriteEffects, v3);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// A very verbose asset drawer.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="npc"></param>
 /// <param name="position"></param>
 /// <param name="sourceRectangle"></param>
 /// <param name="color"></param>
 /// <param name="alpha"></param>
 /// <param name="origin"></param>
 /// <param name="scale"></param>
 /// <param name="effects"></param>
 /// <param name="layerDepth"></param>
 public virtual void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
 {
     this.currentAnimation.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Wrapper for a draw function that accepts rectangles to be null.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="extendedNPC"></param>
 /// <param name="vector21"></param>
 /// <param name="v1"></param>
 /// <param name="white"></param>
 /// <param name="rotation"></param>
 /// <param name="vector22"></param>
 /// <param name="v2"></param>
 /// <param name="spriteEffects"></param>
 /// <param name="v3"></param>
 public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 vector21, Rectangle?v1, Color white, float rotation, Vector2 vector22, float v2, SpriteEffects spriteEffects, float v3)
 {
     this.draw(b, extendedNPC, vector21, v1, white, rotation, vector22, v2, spriteEffects, v3);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Sets the npc's portrait to be this portrait texture.
 /// </summary>
 /// <param name="npc"></param>
 public void setCharacterSpriteFromThis(ExtendedNPC npc)
 {
     npc.Sprite = this.sprite;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Generate a basic npc based off of all all of the NPC data here.
        /// </summary>
        /// <param name="gender"></param>
        /// <param name="minNumOfAccessories"></param>
        /// <param name="maxNumOfAccessories"></param>
        public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories, StandardColorCollection DrawColors = null)
        {
            Seasons myseason = Seasons.spring;

            if (Game1.currentSeason == "spring")
            {
                myseason = Seasons.spring;
            }
            if (Game1.currentSeason == "summer")
            {
                myseason = Seasons.summer;
            }
            if (Game1.currentSeason == "fall")
            {
                myseason = Seasons.fall;
            }
            if (Game1.currentSeason == "winter")
            {
                myseason = Seasons.winter;
            }

            List <AssetSheet> bodyList      = new List <AssetSheet>();
            List <AssetSheet> eyesList      = new List <AssetSheet>();
            List <AssetSheet> hairList      = new List <AssetSheet>();
            List <AssetSheet> shirtList     = new List <AssetSheet>();
            List <AssetSheet> shoesList     = new List <AssetSheet>();
            List <AssetSheet> pantsList     = new List <AssetSheet>();
            List <AssetSheet> accessoryList = new List <AssetSheet>();

            //Get all applicable parts from this current asset manager
            foreach (var assetManager in this.assetPool)
            {
                var body = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.body);
                foreach (var piece in body)
                {
                    bodyList.Add(piece);
                }

                var eyes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.eyes);
                foreach (var piece in eyes)
                {
                    eyesList.Add(piece);
                }

                var hair = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.hair);
                foreach (var piece in hair)
                {
                    hairList.Add(piece);
                }

                var shirt = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shirt);
                foreach (var piece in shirt)
                {
                    shirtList.Add(piece);
                }

                var pants = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.pants);
                foreach (var piece in pants)
                {
                    pantsList.Add(piece);
                }

                var shoes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shoes);
                foreach (var piece in shoes)
                {
                    shoesList.Add(piece);
                }

                var accessory = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.accessory);
                foreach (var piece in accessory)
                {
                    accessoryList.Add(piece);
                }
            }


            Random r      = new Random(System.DateTime.Now.Millisecond);
            int    amount = 0;

            amount = r.Next(minNumOfAccessories, maxNumOfAccessories + 1); //Necessary since r.next returns a num between min and (max-1)

            int bodyIndex  = 0;
            int eyesIndex  = 0;
            int hairIndex  = 0;
            int shirtIndex = 0;
            int pantsIndex = 0;
            int shoesIndex = 0;

            if (bodyList.Count != 0)
            {
                bodyIndex = r.Next(0, bodyList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough body templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }

            if (eyesList.Count != 0)
            {
                eyesIndex = r.Next(0, eyesList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough eyes templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }

            if (hairList.Count != 0)
            {
                hairIndex = r.Next(0, hairList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough hair templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }

            if (shirtList.Count != 0)
            {
                shirtIndex = r.Next(0, shirtList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough shirt templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }

            if (pantsList.Count != 0)
            {
                pantsIndex = r.Next(0, pantsList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough pants templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }

            if (shoesList.Count != 0)
            {
                shoesIndex = r.Next(0, shoesList.Count - 1);
            }
            else
            {
                Class1.ModMonitor.Log("Error: Not enough shoes templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error);
                return(null);
            }
            List <int> accIntList = new List <int>();

            if (accessoryList.Count != 0)
            {
                for (int i = 0; i < amount; i++)
                {
                    int acc = r.Next(0, accessoryList.Count - 1);
                    accIntList.Add(acc);
                }
            }

            //Get a single sheet to pull from.
            AssetSheet bodySheet;
            AssetSheet eyesSheet;
            AssetSheet hairSheet;
            AssetSheet shirtSheet;
            AssetSheet shoesSheet;
            AssetSheet pantsSheet;

            bodySheet  = bodyList.ElementAt(bodyIndex);
            eyesSheet  = eyesList.ElementAt(eyesIndex);
            hairSheet  = hairList.ElementAt(hairIndex);
            shirtSheet = shirtList.ElementAt(shirtIndex);
            pantsSheet = pantsList.ElementAt(pantsIndex);
            shoesSheet = shoesList.ElementAt(shoesIndex);


            List <AssetSheet> accessorySheet = new List <AssetSheet>();

            foreach (var v in accIntList)
            {
                accessorySheet.Add(accessoryList.ElementAt(v));
            }
            if (DrawColors == null)
            {
                DrawColors = new StandardColorCollection();
            }
            var         render = generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, DrawColors);
            ExtendedNPC npc    = new ExtendedNPC(new Sprite(getDefaultSpriteImage(bodySheet)), render, new Microsoft.Xna.Framework.Vector2(0, 0) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender));

            return(npc);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Use this simply to remove a single npc from a location.
 /// </summary>
 /// <param name="loc"></param>
 /// <param name="npc"></param>
 public void removeCharacterFromLocation(GameLocation loc, ExtendedNPC npc)
 {
     loc.characters.Remove(npc);
 }