コード例 #1
0
        public Farmer(GameWorld gameWorldRef, GamePlayer playerRef, Vector2 position)
            : base("farmer_ss", 48, 48, 8, gameWorldRef, playerRef, position, AnimationSpeed)
        {
            CharSelect = GameGraphics.GetTexture("char_select");
            Speed = WalkingSpeed;
            SelectionGroup = GroupMapper.FarmerGroup;
            Animation.DrawOffset = new Vector2(-24, -38);

            Animation.AddAnimation("seeding", 0, 8 * 48, 48, 48, 72, 0.1f);
            Animation.AddAnimation("spreading", 0, 9 * 48, 48, 48, 64, 0.1f);

            SelectBounds = new Rectangle((int)position.X - -16,
                (int)position.Y - 40, 50, 50);

            _capacityStatusLine = new StatusLine(StatusLineType.Yellow);
            _capacityStatusLineOffset = new Vector2(-13, -45);

            #region Setting Entity Properties
            MaxHealth = 50;
            MaxDefense = 5;
            MaxAttack = 3;

            Health = MaxHealth;
            Defense = MaxDefense;
            Attack = MaxAttack;

            #endregion

            #region Adding Possible Actions

            IAction action = new GoToFarmAction(this, playerRef);
            Actions.Add(action);

            IAction action2 = new SeedAction(this, playerRef);
            Actions.Add(action2);

            IAction action3 = new SpreadAction(this, playerRef);
            Actions.Add(action3);

            IAction action4 = new GatherAction(this, playerRef);
            Actions.Add(action4);

            IAction action5 = new CarryToHouseAction(this, playerRef);
            Actions.Add(action5);

            IAction action6 = new ReturnFromBuildingToFarmAction(this, playerRef);
            Actions.Add(action6);

            #endregion
        }
コード例 #2
0
        protected CreatureBase(string animationIdentifier, 
            int frameWidth, int frameHeight, int frames,
            GameWorld gameWorldRef, GamePlayer playerRef, Vector2 position, float animationSpeed)
        {
            PlayerRef = playerRef;
            GameWorldRef = gameWorldRef;
            _mapRef = gameWorldRef.Map ;

            // walking animation is unified in all creatures
            #region setting appropriate walking animation
            AnimationSet = GameGraphics.GetTexture(animationIdentifier);
            Animation = new SpriteAnimation(AnimationSet.SourceTexture);

            Animation.AddAnimation("Walk_E", 0, frameHeight * 0, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_N", 0, frameHeight * 1, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_NE", 0, frameHeight * 2, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_NW", 0, frameHeight * 3, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_S", 0, frameHeight * 4, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_SE", 0, frameHeight * 5, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_SW", 0, frameHeight * 6, frameWidth, frameHeight, frames, animationSpeed);
            Animation.AddAnimation("Walk_W", 0, frameHeight * 7, frameWidth, frameHeight, frames, animationSpeed);

            Animation.AddAnimation("Idle_E", 3 * frameWidth, frameHeight * 0, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_N", 3 * frameWidth, frameHeight * 1, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_NE", 3 * frameWidth, frameHeight * 2, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_NW", 3 * frameWidth, frameHeight * 3, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_S", 3 * frameWidth, frameHeight * 4, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_SE", 3 * frameWidth, frameHeight * 5, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_SW", 3 * frameWidth, frameHeight * 6, frameWidth, frameHeight, 1, 0.2f);
            Animation.AddAnimation("Idle_W", 3 * frameWidth, frameHeight * 7, frameWidth, frameHeight, 1, 0.2f);

            CurrentAnimation = "Idle_SE";

            Animation.IsAnimating = true;

            #endregion

            Position = position;
            _currentMoveDir = Vector2.Zero;
            _previousMovDir = Vector2.Zero;
            Distination = position;

            HealthStatusLine = new StatusLine(StatusLineType.Green);
            _healthStatusLineOffset = new Vector2(-13, -50);

            Actions = new ActionManager();
        }