示例#1
0
        public void ApplyUse(IInteractionComponent interactor)
        {
            if (state == States.Closed)
            {
                Open();
                return;
            }

            switch (interactor.CurrentItem)
            {
            case null:
                var newMilk = Instantiate(milkPrefab).GetComponent <Milk>();
                if (!interactor.ReceiveItem(newMilk))
                {
                    Destroy(newMilk.gameObject);
                    return;
                }
                GameManager.House.AddTemporaryItem(newMilk);
                break;

            case Milk _:
                var milk = interactor.RemoveItem();
                milk.Destroy();
                break;
            }
            Close();
        }
示例#2
0
        public InteractionTypes Use(IInteractionComponent interactor)
        {
            switch (state)
            {
            case States.Empty:
                if (interactor.CurrentItem != null)
                {
                    return(InteractionTypes.Place);
                }
                return(InteractionTypes.None);

            case States.HasItem:
                if (interactor.CurrentItem != null)
                {
                    return(item.CanCombine(interactor.CurrentItem.Ingredient));
                }
                return(InteractionTypes.Grab);

            default:
                Debug.LogError("invalid state: " + state);
                break;
            }

            return(InteractionTypes.None);
        }
示例#3
0
        public void ApplyUse(IInteractionComponent interactor)
        {
            switch (state)
            {
            case States.None:
                if (interactor.CurrentItem is Cup c && !c.HasCoffee)
                {
                    state = States.Operating;
                    TakeCup((Cup)interactor.RemoveItem());
                    GameManager.Gameplay.DisablePlayerInput();
                }
                break;

            case States.Ready:
                if (interactor.ReceiveItem(heldCup))
                {
                    heldCup.gameObject.SetActive(true);
                    heldCup.AddCoffee(true);
                    cupVisual.gameObject.SetActive(false);
                    heldCup = null;
                    state   = States.None;
                }
                break;
            }
        }
示例#4
0
        public void ApplyUse(IInteractionComponent interactor)
        {
            switch (state)
            {
            case States.Empty:
                if (interactor.CurrentItem == null)
                {
                    return;
                }
                Set(interactor.RemoveItem());
                break;

            case States.HasItem:
                if (interactor.CurrentItem != null)
                {
                    item.Combine(interactor.CurrentItem.Ingredient);
                    return;
                }
                if (interactor.ReceiveItem(item))
                {
                    item  = null;
                    state = States.Empty;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#5
0
        public InteractionTypes Use(IInteractionComponent interactor)
        {
            switch (state)
            {
            case States.None:
                if (heldCup == null && interactor.CurrentItem is Cup c && !c.HasCoffee)
                {
                    GameManager.Camera.Zoom(zoomTransform);
                    return(InteractionTypes.Place);
                }
                break;

            case States.Ready:
                if (interactor.CurrentItem == null)
                {
                    return(InteractionTypes.Grab);
                }
                break;

            default:
                return(InteractionTypes.None);
            }

            return(InteractionTypes.None);
        }
示例#6
0
 public override void Use(IInteractionComponent interactor)
 {
     if (!CanDrink(interactor))
     {
         return;
     }
     GameManager.Data.HadCoffee = true;
     Empty();
 }
示例#7
0
文件: Cow.cs 项目: Aspekt1024/Coffee
        public InteractionTypes Use(IInteractionComponent interactor)
        {
            if (!hasSpoken)
            {
                hasSpoken = true;
                GameManager.UI.ShowDialogue("Cow", "Yes?");
            }

            return(InteractionTypes.None);
        }
        public void TestInvalidInit()
        {
            var map    = LanguageMap.EnglishUS("test");
            var resp   = new ResponsePattern(new CharacterString("test"));
            var choice = new IInteractionComponent[] { new InteractionComponent("test") };

            Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, null, null, null));
            Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, null, map, null));
            Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(resp, null, map, map));
            Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, choice, map, map));
        }
示例#9
0
文件: Door.cs 项目: Aspekt1024/Coffee
 public void ApplyUse(IInteractionComponent interactor)
 {
     if (state == States.Closed)
     {
         Open();
     }
     else
     {
         Close();
     }
 }
示例#10
0
        public override InteractionTypes Use(IInteractionComponent interactor)
        {
            var currentDay = GameManager.Data.Day;
            var canLeave   = GameManager.Data.HadCoffee;
            var text       = canLeave ? GetSuccessText(currentDay) : GetFailureText(currentDay);

            GameManager.UI.ShowDialogue("Door", text);

            if (canLeave)
            {
                return(base.Use(interactor));
            }

            return(InteractionTypes.None);
        }
示例#11
0
        public InteractionTypes Use(IInteractionComponent interactor)
        {
            if (state == States.Closed)
            {
                return(InteractionTypes.Open);
            }

            switch (interactor.CurrentItem)
            {
            case null:
                return(InteractionTypes.Grab);

            case Milk _:
                return(InteractionTypes.Place);

            default:
                return(InteractionTypes.None);
            }
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (player.Inventory.HasToolSelected)
            {
                Tool selectedTool = player.Inventory.SelectedTool;
                IInteractionComponent interactionComponent = selectedTool.Components.GetComponent(
                    c => c is IInteractionComponent) as IInteractionComponent;

                // ei pitäs olla null ikinä
                if (interactionComponent != null && interactionComponent.IsInteracting)
                {
                    foreach (RenderMatrix l_render in m_renderList)
                    {
                        Texture2D texture = m_tx[l_render.Folder];
                        Rectangle?source  = m_rect[l_render.Folder][l_render.File];

                        if (l_render.Folder == 2)
                        {
                            texture = selectedTool.Texture ?? texture;
                            source  = null;
                        }

                        spriteBatch.Draw(
                            texture,
                            l_render.Location,
                            source,
                            m_color * l_render.Alpha,
                            l_render.Rotation,
                            l_render.Pivot,
                            l_render.Scale,
                            l_render.Effects,
                            /*(float)l_render.ZOrder*/ 0.0f
                            );
                    }
                    return;
                }
            }
            base.Draw(spriteBatch);
        }
示例#13
0
 public override InteractionTypes CanUse(IInteractionComponent interactor)
 {
     return(CanDrink(interactor) ? InteractionTypes.Drink : InteractionTypes.None);
 }
示例#14
0
 private bool CanDrink(IInteractionComponent interactor)
 {
     return(IsReady && interactor.CurrentItem is Cup cup && cup == this);
 }
示例#15
0
 public abstract InteractionTypes CanUse(IInteractionComponent interactor);
示例#16
0
文件: Milk.cs 项目: Aspekt1024/Coffee
 public override void Use(IInteractionComponent interactor)
 {
 }
示例#17
0
文件: Milk.cs 项目: Aspekt1024/Coffee
 public override InteractionTypes CanUse(IInteractionComponent interactor) => InteractionTypes.None;
示例#18
0
 public abstract void Use(IInteractionComponent interactor);
示例#19
0
文件: Door.cs 项目: Aspekt1024/Coffee
 public virtual InteractionTypes Use(IInteractionComponent interactor)
 {
     return(InteractionTypes.Open);
 }
示例#20
0
文件: Cow.cs 项目: Aspekt1024/Coffee
 public void ApplyUse(IInteractionComponent interactor)
 {
 }