コード例 #1
0
        public override bool CanInteract(GameObject with)
        {
            if (owner.ContainsFeed)
            {
                return(false);
            }

            FarmPlayer player = with as FarmPlayer;

            if (player == null)
            {
                return(false);
            }

            if (player.Inventory.HasItemInHands)
            {
                AnimalFeedItem feedItem = player.Inventory.ItemInHands as AnimalFeedItem;

                if (feedItem != null)
                {
                    if (feedItem.FeedType == owner.FeedType)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
コード例 #2
0
 public AnimationComponent(FarmPlayer player, CharaterAnimator animator, string animation)
 {
     this.player   = player;
     this.animator = animator;
     animator.ChangeAnimation(animation);
     DrawOrder = 1;
 }
コード例 #3
0
        protected override void DoInteract(GameObject with, GameTime gameTime)
        {
            FarmPlayer player = with as FarmPlayer;

            owner.InsertFeed(player.Inventory.ThrowItem() as AnimalFeedItem);

            IsInteracting = false;
        }
コード例 #4
0
        public HoeInteractionComponent(KhvGame game)
        {
            this.game = game;
            var gameplay = game.GameStateManager.States.FirstOrDefault(c => c is GameplayScreen) as GameplayScreen;

            player                 = gameplay.World.Player;
            OnInteractionBegin    += HoeInteractionComponent_OnInteractionBegin;
            OnInteractionFinished += HoeInteractionComponent_OnInteractionFinished;
        }
コード例 #5
0
        public PlayerInventory(FarmPlayer player)
        {
            this.player = player;

            DrawOrder = 0;

            items = new List <Item>();
            tools = new List <Tool>();
        }
コード例 #6
0
        public ItemWidget(KhvGame khvGame, GameObject owner, WidgetManager owningManager, string name)
            : base(khvGame, owner, owningManager, name)
        {
            FarmPlayer player = owner as FarmPlayer;

            inventory = player.Components.GetComponent <PlayerInventory>();

            Initialize();
        }
コード例 #7
0
        public ExclamationMarkDrawer(KhvGame game, FarmPlayer farmPlayer)
        {
            this.farmPlayer = farmPlayer;

            DrawOrder = 3;

            texture = game.Content.Load <Texture2D>(Path.Combine("Entities", "exclamation"));
            size    = new Size(texture.Width, texture.Height);
        }
コード例 #8
0
        protected override void DoInteract(GameObject with, GameTime gameTime)
        {
            FarmPlayer player = with as FarmPlayer;

            MessageBoxComponent messageComponent = player.Components.GetComponent(
                c => c is MessageBoxComponent) as MessageBoxComponent;

            messageComponent.DrawMessage(string.Format("Safkaa viela siilossa {0} yksikkoa.", owner.FeedContained), 100 * 10);

            IsInteracting = false;
        }
コード例 #9
0
        public override void Initialize()
        {
            base.Initialize();
            World = new FarmWorld(Game);
            World.Initialize();

            camera = new Camera(Vector2.Zero, Game.GraphicsDevice.Viewport);
            FarmPlayer player = World.WorldObjects.GetGameObject <FarmPlayer>(p => p is FarmPlayer);

            camera.Follow(player);
        }
コード例 #10
0
        private void Collider_OnCollision(object sender, CollisionEventArgs result)
        {
            FarmPlayer player = result.CollidingObject as FarmPlayer;

            if (player == null)
            {
                timers.RemoveAllTimers();

                brain.PushState(Idle);
                brain.PushState(ChangeDirection);
            }
        }
コード例 #11
0
ファイル: FarmWorld.cs プロジェクト: siquel/FarmGameProject
        public override void Initialize()
        {
            MapManager   = new MapManager(Game, Path.Combine("cfg", "mengine.cfg"));
            WorldObjects = new GameObjectManager(null);
            WorldObjects.EnableBackgroundTransfers();

            Player = new FarmPlayer(Game, this, PlayerIndex.One);
            Player.Initialize();
            WorldObjects.AddGameObject(Player);

            MapManager.ChangeMap("farm");
        }
コード例 #12
0
        public MessageBoxComponent(KhvGame game, FarmPlayer player)
        {
            this.player = player;

            DrawOrder = 1;
            font      = game.Content.Load <SpriteFont>("arial");

            currentMessage = string.Empty;

            exclamationMarkDrawer = player.Components.GetComponent(
                c => c is ExclamationMarkDrawer) as ExclamationMarkDrawer;
        }
コード例 #13
0
        protected override void DoInteract(GameObject with, GameTime gameTime)
        {
            if (owner.HasFeed)
            {
                FarmPlayer player = with as FarmPlayer;

                if (!player.Inventory.HasItemInHands)
                {
                    player.Inventory.AddToInventory(owner.GetFeed());
                }
            }
            else
            {
                MessageBoxComponent interactorMessageComponent = with.Components.GetComponent(
                    c => c is MessageBoxComponent) as MessageBoxComponent;

                interactorMessageComponent.DrawMessage("Siilossa ei ole safkaa!", 100 * 25);
            }

            IsInteracting = false;
        }