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); }
public AnimationComponent(FarmPlayer player, CharaterAnimator animator, string animation) { this.player = player; this.animator = animator; animator.ChangeAnimation(animation); DrawOrder = 1; }
protected override void DoInteract(GameObject with, GameTime gameTime) { FarmPlayer player = with as FarmPlayer; owner.InsertFeed(player.Inventory.ThrowItem() as AnimalFeedItem); IsInteracting = false; }
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; }
public PlayerInventory(FarmPlayer player) { this.player = player; DrawOrder = 0; items = new List <Item>(); tools = new List <Tool>(); }
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(); }
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); }
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; }
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); }
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); } }
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"); }
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; }
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; }