예제 #1
0
        public Character(List <string> data, int x, int y, Location loc) : base(loc)
        {
            drawToolInteractBox      = true;
            interactBoxTexture       = Game1.content.Load <Texture2D>("spriteSheets/simplebox");
            interactToolBoxRectangle = FindInteractToolBoxRectangle();
            interactBoxRectangle     = FindInteractBoxRectangle();

            velocityX = 0;
            velocityY = 0;

            curSprite = "";
            speed     = 0.15f;

            events = new List <Event>();

            spriteFactory = Game1.CreateAnimationFactory(data[2], data[3]);
            float frameDuration = float.Parse(data[4]);

            for (int i = 5; i < data.Count; i++)
            {
                var   indexes         = data[i].Split(',');
                int[] animationFrames = new int[indexes.Count() - 1];
                for (int j = 0; j < indexes.Count() - 1; j++)
                {
                    animationFrames[j] = Int32.Parse(indexes[j + 1]);
                }
                spriteFactory.Add(indexes[0], new SpriteSheetAnimationData(animationFrames, frameDuration, (animationFrames.Count() > 1)));
            }
            curSprite       = "down_idle";
            facingDirection = Direction.Down;
            sprite          = Game1.CreateAnimatedSprite(spriteFactory, curSprite);
            collisionBox    = MakeCollisionBoundingBox();
            posX            = x;
            posY            = y;
        }
예제 #2
0
파일: Plant.cs 프로젝트: kirbunkle/potion
        public Plant(Rectangle pos, Seed seed, Location loc) : base(loc)
        {
            posX                 = pos.X;
            posY                 = pos.Y;
            spriteFactory        = Game1.CreateAnimationFactory(seed.SpriteName(), seed.AnimationName());
            plantAnimationFrames = seed.PlantAnimationFrames();
            plantSchedule        = seed.PlantSchedule();

            if (plantAnimationFrames.Count() != plantSchedule.Count())
            {
                throw new Exception(seed.Name() + " item has mismatching animation frames and schedule");
            }

            for (int i = 0; i < plantAnimationFrames.Count(); i++)
            {
                spriteFactory.Add(i.ToString(), new SpriteSheetAnimationData(new[] { plantAnimationFrames[i] }, isLooping: false));
            }
            curSprite    = 0;
            curDate      = 0;
            sprite       = Game1.CreateAnimatedSprite(spriteFactory, curSprite.ToString());
            collisionBox = MakeCollisionBoundingBox();
            datePlanted  = Game1.gameDateTime.DaysSinceStart;
            cropYield    = seed.CropYield();
        }