Beispiel #1
0
        public override bool Interact(string verb, IAdventurePlayer player)
        {
            if (!player.Inventory.GetItems().Any(x => x.ItemId.Equals(ItemId)))
            {
                var msg = new Display($"You are not carrying a {ItemId}!");
                msg.Do(player);
                return(true);
            }

            verb = verb.ToLower();
            var interaction = Interactions.FirstOrDefault(c => c.IsMatch(verb) && c.ShouldExecute());

            if (interaction != null)
            {
                if (interaction.Verbs.Contains("light"))
                {
                    if (IsActive)
                    {
                        var msg = new Display($"Your{ItemId} is already lit!");
                        msg.Do(player);
                        return(true);
                    }
                }

                foreach (var action in interaction.RegisteredInteractions)
                {
                    action.Do(player, this);
                }

                return(true);
            }

            return(false);
        }
Beispiel #2
0
 public Hireling(World world, int snoId, TagMap tags)
     : base(world, snoId, tags)
 {
     //this.Attributes[GameAttribute.TeamID] = 2;
     Interactions.Add(new HireInteraction());
     Interactions.Add(new InventoryInteraction());
 }
Beispiel #3
0
        public override bool Interact(string verb, IAdventurePlayer player)
        {
            verb = verb.ToLower();
            var interaction = Interactions.FirstOrDefault(c => c.IsMatch(verb) && c.ShouldExecute());

            if (interaction != null)
            {
                if (interaction.Verbs.Contains("use"))
                {
                    var success = Game.Dungeon.TryGetLocation(Location.FissureWest, out var fissureWest);

                    if (success)
                    {
                        interaction.RegisteredInteractions
                        .Add(new AddToLocation(ItemFactory.GetInstance(Game, Item.CrystalBridge), fissureWest));
                    }
                }

                foreach (var action in interaction.RegisteredInteractions)
                {
                    action.Do(player, this);
                }

                return(true);
            }

            return(false);
        }
        public async static Task ShowInStoreLocation(IDialogContext context, string productId, string storeId)
        {
            var collection = DbSingleton.GetDatabase().GetCollection <Store>(AppSettings.StoreCollection);

            //get store
            var query_id = Builders <Store> .Filter.Eq("_id", ObjectId.Parse(storeId));

            var entity = collection.Find(query_id).ToList();

            var store   = entity[0];
            var message = "O produto encontra-se no ";

            await Interactions.SendMessage(context, "Vou verificar a localização do produto dentro da loja. Aguarde.", 0, 4000);

            for (int i = 0; i < store.ProductsInStock.Count(); i++)
            {
                if (store.ProductsInStock[i].ProductId.ToString().Equals(productId))
                {
                    message += "no corredor " + store.ProductsInStock[i].InStoreLocation.Corridor + ", ";
                    message += "da secção " + store.ProductsInStock[i].InStoreLocation.Section + " e na ";
                    message += "prateleira " + store.ProductsInStock[i].InStoreLocation.Shelf + "";
                    break;
                }
            }

            await Interactions.SendMessage(context, message, 0, 0);
        }
Beispiel #5
0
    IEnumerator SelectingItem()
    {
        float waitTime = 1.5f;
        float counter  = 0f;

        if (CurrentGameObject.tag.Equals("LoadButton") || CurrentGameObject.name.Equals("ShoppingList"))
        {
            waitTime = 1f;
        }
        while (counter < waitTime)
        {
            counter += Time.deltaTime;
            LoadingBar.fillAmount            = (counter / waitTime);
            LoadingCircle.transform.position = this.transform.position;
            yield return(null); //Don't freeze Unity
        }
        LoadingBar.fillAmount = 0f;
        if (this.itemSelection == "Selection")
        {
            Interactions.SelectObject(CurrentGameObject);
        }
        else if (this.itemSelection == "UI_selection")
        {
            Interactions.SelectUIObject(CurrentGameObject);
        }
        else if (this.itemSelection == "LoadButton")
        {
            Interactions.SelectUIObject(CurrentGameObject);
        }
    }
Beispiel #6
0
        public Artisan(World world, int snoId, TagMap tags)
            : base(world, snoId, tags)
        {
            this.Attributes[GameAttribute.MinimapActive] = true;

            Interactions.Add(new CraftInteraction());
        }
Beispiel #7
0
        /// <summary>Load Quest progress</summary>
        internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
            : this(log, template, record)
        {
            m_saved = true;
            if (template.HasObjectOrSpellInteractions)
            {
                if (Interactions == null ||
                    template.ObjectOrSpellInteractions
                    .Count() != Interactions.Count())
                {
                    Interactions = new uint[template.ObjectOrSpellInteractions.Length];
                }
                for (int index = 0; index < Template.ObjectOrSpellInteractions.Length; ++index)
                {
                    QuestInteractionTemplate spellInteraction = Template.ObjectOrSpellInteractions[index];
                    if (spellInteraction != null && spellInteraction.IsValid)
                    {
                        log.Owner.SetQuestCount(Slot, spellInteraction.Index,
                                                (byte)Interactions[index]);
                    }
                }
            }

            UpdateStatus();
        }
Beispiel #8
0
 public Interactions GetInteractions()
 {
     return(Interactions
            .Create()
            .For(Tree.Basement.DrillingMachine)
            .Add(Verbs.Use, UseDrillingMachineScript(), Game.Ego)
            .For(Game.Ego)
            .Add(Verbs.Walk, WalkScript())
            .Add(Verbs.Open, OpenScript())
            .Add(Verbs.Close, CloseScript())
            .Add(Verbs.Use, OpenScript())
            .Add(Verbs.Look, LookScript())
            .Add(Verbs.Talk, TalkScript())
            .For(Tree.InventoryItems.Hammer)
            .Add(Verbs.Use, UseHammerScript(), Game.Ego)
            .For(Tree.InventoryItems.DrawerKey)
            .Add(Verbs.Use, UseDrawerKeyScript(), Game.Ego)
            .For(Tree.InventoryItems.Screwdriver)
            .Add(Verbs.Use, UseScrewdriverScript(), Game.Ego)
            .For(Tree.InventoryItems.Paperclip)
            .Add(Verbs.Use, UsePaperclipScript(), Game.Ego)
            .For(Tree.InventoryItems.Paperclips)
            .Add(Verbs.Use, UsePaperclipScript(), Game.Ego)
            .For(Tree.InventoryItems.Scissors)
            .Add(Verbs.Use, UseScissorsScript(), Game.Ego));
 }
Beispiel #9
0
    // Start is called before the first frame update
    void Start()
    {
        notif       = this.transform.Find("Notif").gameObject;
        originalPos = notif.GetComponent <RectTransform>().anchoredPosition;
        //Debug.Log(notif + ""+notif.GetComponent<RectTransform>().anchoredPosition);

        finalPos = new Vector3(-originalPos.x, originalPos.y);

        notifName      = this.transform.Find("Notif").Find("Content").Find("Name").GetComponent <TextApparition>();
        notifDesc      = this.transform.Find("Notif").Find("Content").Find("ScrollArea").Find("DescContainer").Find("Desc").GetComponent <TextApparition>();
        notifScrollbar = this.transform.Find("Notif").Find("Content").Find("ScrollArea").Find("DescContainer").Find("Scrollbar").GetComponent <Scrollbar>();

        playerInteractions = GameObject.FindObjectOfType <Interactions>();
        //playerEventsCheck = playerInteractions.GetComponent<EventsCheck>();
        //playerMemory = playerInteractions.GetComponent<PlayerMemory>();
        //stickerDisplay = CanvasManager.CManager.GetCanvas("Dialogue").transform.Find("Nouvelle Etiquette").GetComponent<NewStickerDisplay>();
        //playerRigidBody = playerInteractions.GetComponent<Rigidbody2D>();
        gameCam   = GameObject.FindObjectOfType <CameraFollow>();
        CM        = CanvasManager.CManager;
        PauseMenu = CM.GetCanvas("Pause").gameObject;

        MoveIndicator = this.transform.Find("MoveIndic").gameObject;
        if (GameSaveSystem.gameToLoad)
        {
            Destroy(this);
        }
    }
Beispiel #10
0
        public override void Interact(Player player, Interactions interaction)
        {
            if (interaction == Interactions.Close || interaction == Interactions.Open)
            {
                _spriteRenderer.sprite = interaction == Interactions.Close ? _closed : _open;

                _isOpen = !_isOpen;
            }
            else if (interaction == Interactions.Drop)
            {
                //do nothing
            }
            else if (interaction == Interactions.Flush)
            {
                //Play sound
                _audioSource.PlayOneShot(_flush);
            }
            else if (interaction == Interactions.Flush_Cat)
            {
                if (player.IsPickedUpInteractableMurderable())
                {
                    _audioSource.PlayOneShot(_flush);
                    player.KillCat();
                    EvSys.Instance().AddMessage("Flushed Cat: <color=green> -1 to Cats</color>");
                }
            }
        }
        public virtual InteractionProperties Clone(ICloneManager cloneManager)
        {
            var clone = new InteractionProperties();

            Interactions.Each(x => clone.AddInteraction(x.Clone(cloneManager)));
            return(clone);
        }
Beispiel #12
0
        public async Task <InteractionResponseModel> UpdateInteraction(InteractionUpdateRequestModel interactionUpdateRequestModel, int id)
        {
            var dbInteraction = await _interactionsRepository.GetByIdAsync(id);

            if (dbInteraction == null)
            {
                throw new Exception("No Client Exist");
            }
            var interaction = new Interactions
            {
                Id       = dbInteraction.Id,
                ClientId = interactionUpdateRequestModel.ClientId == 0 ? dbInteraction.ClientId : interactionUpdateRequestModel.ClientId,
                EmpId    = interactionUpdateRequestModel.EmpId == 0 ? dbInteraction.EmpId : interactionUpdateRequestModel.EmpId,
                IntType  = interactionUpdateRequestModel.type == 0 ? dbInteraction.IntType : interactionUpdateRequestModel.type,
                IntDate  = interactionUpdateRequestModel.Date == null ? dbInteraction.IntDate : interactionUpdateRequestModel.Date,
                Remarks  = interactionUpdateRequestModel.Remarks == null ? dbInteraction.Remarks : interactionUpdateRequestModel.Remarks,
            };
            var updatedInteraction = await _interactionsRepository.UpdateAsync(interaction);

            var response = new InteractionResponseModel
            {
                Id       = updatedInteraction.Id,
                ClientId = updatedInteraction.ClientId,
                EmpId    = updatedInteraction.EmpId,
                type     = updatedInteraction.IntType,
                Date     = updatedInteraction.IntDate,
                Remarks  = updatedInteraction.Remarks,
            };

            return(response);
        }
Beispiel #13
0
 public Interactions GetInteractions()
 {
     return(Interactions
            .Create()
            .For(Game.Ego)
            .Add(Verbs.Look, LookScript()));
 }
Beispiel #14
0
 public Interactions GetInteractions()
 {
     return(Interactions
            .Create()
            .For(Tree.InventoryItems.Flashlight)
            .Add(Verbs.Use, UseFlashlightScript(), Game.Ego)
            .For(Tree.InventoryItems.Hammer)
            .Add(Verbs.Use, AttackScript(), Game.Ego)
            .For(Tree.InventoryItems.Crowbar)
            .Add(Verbs.Use, AttackScript(), Game.Ego)
            .For(Tree.InventoryItems.Scissors)
            .Add(Verbs.Use, AttackScript(), Game.Ego)
            .For(Tree.InventoryItems.Paperclips)
            .Add(Verbs.Use, GivePaperclipsScript(), Game.Ego)
            .Add(Verbs.Give, GivePaperclipsScript(), Game.Ego)
            .For(Tree.InventoryItems.Paperclip)
            .Add(Verbs.Use, GivePaperclipScript(), Game.Ego)
            .Add(Verbs.Give, GivePaperclipScript(), Game.Ego)
            .For(Tree.InventoryItems.Hazelnuts)
            .Add(Verbs.Use, FeedScript(), Game.Ego)
            .Add(Verbs.Give, FeedScript(), Game.Ego)
            .For(Tree.InventoryItems.BatonWithString)
            .Add(Verbs.Use, UseBatonWithStringScript(), Game.Ego)
            .For(Tree.InventoryItems.Baton)
            .Add(Verbs.Use, UseBatonScript(), Game.Ego)
            .For(Game.Ego)
            .Add(Verbs.Look, LookScript())
            .Add(Verbs.Talk, TalkScript())
            .Add(Verbs.Pick, PickScript()));
 }
Beispiel #15
0
        public override void Interact(Player player, Interactions interaction)
        {
            if (interaction == Interactions.Close || interaction == Interactions.Open)
            {
                Vector3 angles = _transform.localEulerAngles;
                if (_spriteRenderer.flipY)
                {
                    angles.z += _isOpen ? 90.0f : -90.0f;
                }
                else
                {
                    angles.z += _isOpen ? -90.0f : 90.0f;
                }

                _transform.localEulerAngles = angles;

                _isOpen = !_isOpen;
                Neighbor.Instance().RedoPath();
            }
            else if (interaction == Interactions.Drop)
            {
                if (!_isOpen)
                {
                    Interact(player, Interactions.Open);
                }
            }
        }
Beispiel #16
0
 protected override Interactions GetInteractions()
 {
     return(Interactions
            .Create()
            .For(Game.Ego)
            .Add(Verbs.Look, LookScript()));
 }
Beispiel #17
0
 static public void CreateNew()
 {
     Instance         = new World();
     Instance.AllNPCs = NPCs.GenerateNPCs();
     Traits.GenerateTraits(Instance.AllNPCs);
     Interactions.GenerateInteractions(Instance.AllNPCs);
 }
        private async Task CheckForUpdates()
        {
            // 1 API call
            if (!(await _autoInstallerService.CheckForUpdate())
                .Out(out var release))
            {
                _loggerService.Info($"Is update available: {release != null}");
                return;
            }

            _loggerService.Success($"Update available: {release.TagName}");
            Settings.IsUpdateAvailable = true;

            var result = await Interactions.ShowMessageBoxAsync("An update is ready to install for WolvenKit. Exit the app and install it?", "Update available");

            switch (result)
            {
            case WMessageBoxResult.OK:
            case WMessageBoxResult.Yes:
                if (await _autoInstallerService.Update())     // 1 API call
                {
                }
                break;
            }
        }
 public static void ExceptionRoutine(System.Windows.Threading.DispatcherUnhandledExceptionEventArgs args, Action closeAction)
 {
     args.Handled = true;
     try
     {
         if (args.Exception.GetType() == typeof(WarningException))
         {
             Interactions.Warningpopup(args.Exception.Message);
         }
         else if (args.Exception.GetType() == typeof(ErrorException))
         {
             Interactions.Errorpopup(args.Exception.Message);
         }
         else
         {
             UnkownErrorDialog errorDialog = new UnkownErrorDialog(args.Exception.ToString());
             if (errorDialog.ShowDialog() != true)
             {
                 return;
             }
             closeAction();
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
Beispiel #20
0
 private void MyInteractionsOnInteractionRemoved(object sender, InteractionEventArgs e)
 {
     using (Trace.Main.scope())
     {
         try
         {
             Context.Send(s =>
             {
                 using (Trace.Main.scope("MyInteractionsOnInteractionRemoved"))
                 {
                     try
                     {
                         // Remove from interactions list
                         var interaction = GetInteractionViewModel(e.Interaction);
                         if (interaction != null)
                         {
                             Interactions.Remove(interaction);
                         }
                     }
                     catch (Exception ex)
                     {
                         Trace.Main.exception(ex, ex.Message);
                     }
                 }
             }, null);
         }
         catch (Exception ex)
         {
             Trace.Main.exception(ex, ex.Message);
         }
     }
 }
 private bool OnSelectCard(Interactions.SelectCards interactionObj)
 {
     Console.WriteLine(interactionObj.Message);
     Debug.Assert(Program.ActiveInteraction == null);
     Program.ActiveInteraction = interactionObj;
     return true;
 }
Beispiel #22
0
        internal Bird(IReadonlyAdventureGame game, params string[] nouns) : base(game, nouns)
        {
            ItemId            = Item.Bird;
            Name              = "little *bird* singing cheerfully";
            PluralName        = "little *birds* singing cheerfully";
            IsPortable        = true;
            IsActive          = true;
            MustBeContainedIn = Item.Cage;
            Slots             = 0;

            PreventTakeItemId = Item.Rod;
            PreventTakeText   = "The *bird* was unafraid when you entered, but as you approach " +
                                "it becomes disturbed and you cannot catch it.";

            var free = new ItemInteraction(Game, "use", "free", "release");

            free.RegisteredInteractions.Add(new Display("You open the cage and the bird flies out."));
            free.RegisteredInteractions.Add(new RemoveFromInventory());
            free.RegisteredInteractions.Add(new AddToLocation(this));
            Interactions.Add(free);

            var catchInteraction = new ItemInteraction(Game, "catch", "capture", "trap");

            catchInteraction.RegisteredInteractions.Add(new AliasCommand(new Take(game, "take")));
            Interactions.Add(catchInteraction);
        }
Beispiel #23
0
        private static void SeedInteractions(AuthContext context)
        {
            if (context.Interactions.Any())
            {
                return;
            }

            var interactions = new Interactions[]
            {
                new Interactions
                {
                    Id = 1, InteractionName = "Like"
                },
                new Interactions
                {
                    Id = 2, InteractionName = "Reject"
                }
            };

            foreach (Interactions inter in interactions)
            {
                context.Add(inter);
            }
            context.SaveChanges();
        }
Beispiel #24
0
 public Interactions GetInteractions()
 {
     return(Interactions
            .Create()
            .For(Tree.InventoryItems.Flashlight)
            .Add(Verbs.Use, UseFlashlightScript(), Game.Ego)
            .For(Tree.InventoryItems.Drone)
            .Add(Verbs.Use, UseDroneScript(), Game.Ego)
            .For(Tree.InventoryItems.Baton)
            .Add(Verbs.Use, UseToolScript(), Game.Ego)
            .For(Tree.InventoryItems.BatonWithString)
            .Add(Verbs.Use, UseToolScript(), Game.Ego)
            .For(Tree.InventoryItems.Hammer)
            .Add(Verbs.Use, UseToolScript(), Game.Ego)
            .For(Tree.InventoryItems.Scissors)
            .Add(Verbs.Use, UseToolScript(), Game.Ego)
            .For(Game.Ego)
            .Add(Verbs.Look, OpenScript())
            .Add(Verbs.Open, OpenScript())
            .Add(Verbs.Push, OpenScript())
            .Add(Verbs.Pull, OpenScript())
            .Add(Verbs.Close, CloseScript())
            .Add(Verbs.Talk, TalkScript())
            .Add(Verbs.Use, OpenScript()));
 }
Beispiel #25
0
 // Use this for initialization
 void Start()
 {
     Planets    = GameObject.FindGameObjectsWithTag("Planet");
     BlackWhole = GameObject.FindGameObjectWithTag("Blackhole");
     sun        = GameObject.Find("Sun");
     flameOn    = GetComponent <Interactions>();
 }
Beispiel #26
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else if (instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        peterData  = new List <string>(peterFile.text.Split('\n'));
        edwardData = new List <string>(edwardFile.text.Split('\n'));
        jamesData  = new List <string>(jamesFile.text.Split('\n'));
        //leave game_log as strings for flexibilities, even though it only has ints for now
        game_log = new List <string>();
        game_log.Add("0");              // day count
        game_log.Add("50");             // cellmate perception, ranged 0~100
        game_log.Add("50");             // watcher perception, ranged 0~100
        game_log.Add("50");             // hunger level, ranged 0~100


        inter           = new Interactions();
        inter.objs      = new List <string>();
        inter.per_prefs = new List <string>();
    }
 // Update is called once per frame
 void Update()
 {
     text      = "";
     raycasted = custom_Cursor.GetRayCastObject();
     if (interaction != Interactions.None)
     {
         text = interaction.ToString() + " ";
         if (Input.GetMouseButton(1))
         {
             interaction = Interactions.None;
             custom_Cursor.SetCursorTexture(null);
         }
     }
     if (raycasted)
     {
         if (raycasted.gameObject.CompareTag("Interactable") || raycasted.gameObject.CompareTag("HighlightParent"))
         {
             text += raycasted.name;
         }
     }
     if (prevtext != text)
     {
         prevtext     = text;
         textbox.text = text;
     }
 }
Beispiel #28
0
            public override string ToString()
            {
                var sb = new StringBuilder();

                Interactions.ForEach(x => sb.AppendFormat("=>", x));
                return(sb.ToString());
            }
Beispiel #29
0
        internal Bottle(IReadonlyAdventureGame game, params string[] nouns) : base(game, nouns)
        {
            ItemId        = Item.Bottle;
            Name          = "small glass *bottle*";
            PluralName    = "small glass *bottles*";
            IsContainer   = true;
            IsPortable    = true;
            IsTransparent = true;

            var smash = new ItemInteraction(Game, "smash", "break");

            smash.RegisteredInteractions.Add(new Display("You smash the bottle and glass flies everywhere!"));
            smash.RegisteredInteractions.Add(new RemoveFromInventory());
            smash.RegisteredInteractions.Add(new AddToLocation(new BrokenGlass(Game)));
            Interactions.Add(smash);

            var fill = new ItemInteraction(Game, "fill");

            fill.RegisteredInteractions.Add(new Display("You reach down and fill the bottle with water."));
            fill.RegisteredInteractions.Add(new AddToItemContents(ItemFactory.GetInstance(Game, Item.PintOfWater)));
            Interactions.Add(fill);

            //var empty = new ItemInteraction(Game, "empty", "pour"););
            //Interactions.Add(empty);
        }
Beispiel #30
0
        /// <summary>
        /// Load Quest progress
        /// </summary>
        internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
            : this(log, template, record)
        {
            m_saved = true;

            // reset initial state

            if (template.HasObjectOrSpellInteractions)
            {
                if (Interactions == null ||
                    //template has been changed, probably due to a quest fix
                    template.ObjectOrSpellInteractions.Count() != Interactions.Count())
                {
                    Interactions = new uint[template.ObjectOrSpellInteractions.Length];
                }

                for (var i = 0; i < Template.ObjectOrSpellInteractions.Length; i++)
                {
                    var interaction = Template.ObjectOrSpellInteractions[i];

                    if (interaction == null || !interaction.IsValid)
                    {
                        continue;
                    }

                    log.Owner.SetQuestCount(Slot, interaction.Index, (byte)Interactions[i]);
                }
            }
            UpdateStatus();
        }
Beispiel #31
0
    //Called to reset the Player Stats
    public void ResetPlayer()
    {
        _playerHealth = _maxHealthValue;
        _healthBar.GetComponent <Image>().fillAmount = _playerHealth / _maxHealthValue;

        _currSpecialAmount = 0;
        _specialBar.GetComponent <Image>().fillAmount = _currSpecialAmount / _MaxSpecialAmount;


        _currPlayerSpeed = _playerSpeed;
        StopAllCoroutines();
        _doingSomething   = false;
        _invincible       = false;
        _blinkin          = false;
        _inMenu           = false;
        _inCutscene       = false;
        _movingHealth     = false;
        _movingSpecial    = false;
        _bossCutsceneInit = false;
        _myRenderer.SetActive(true);

        if (reachCheckpoint == true)            //if the player has reached a checkpoint
        {
            transform.position = checkpointPos; //spawn player at checkpoint
            //disableRooms();
        }
        else
        {
            transform.position = _playerStartPos;  //else spawn player at players start position
        }
        _whatImDoing = Interactions.NONE;
        _myAnimations.Play("StandingIdle", 0);
    }
Beispiel #32
0
 public void OnEnter(Interactions.BaseInteraction io)
 {
     m_io = (Interactions.SelectCards)io;
     m_gameUI.RemoveAllContextButtons();
     m_gameUI.AddContextButton("略过", ContextButton_OnSkip);
     GameApp.Service<PopupDialog>().PushMessageBox(m_io.Message);
 }
Beispiel #33
0
        public virtual void OnRespondBack(Interactions.BaseInteraction io, object result)
        {
            if (m_recording == null)
            {
                return;
            }

            if (io is Interactions.TacticalPhase)
            {
                var tp = io as Interactions.TacticalPhase;
                var r = (Interactions.TacticalPhase.Result)result;
                switch (r.ActionType)
                {
                    case Interactions.BaseInteraction.PlayerAction.Pass:
                        m_recording.WriteLine("pa");
                        break;
                    case Interactions.BaseInteraction.PlayerAction.PlayCard:
                        m_recording.WriteLine("pl:" + (r.Data as CardInstance).Guid.ToString());
                        break;
                    case Interactions.BaseInteraction.PlayerAction.ActivateAssist:
                        m_recording.WriteLine("ac:" + (r.Data as CardInstance).Guid.ToString());
                        break;
                    case Interactions.BaseInteraction.PlayerAction.CastSpell:
                        m_recording.WriteLine("ca:" + (r.Data as Behaviors.ICastableSpell).Host.Guid.ToString() + ":" + (r.Data as Behaviors.ICastableSpell).Host.Behaviors.IndexOf(r.Data as Behaviors.ICastableSpell));
                        break;
                    case Interactions.BaseInteraction.PlayerAction.Sacrifice:
                        m_recording.WriteLine("sa:" + (r.Data as CardInstance).Guid.ToString());
                        break;
                    case Interactions.BaseInteraction.PlayerAction.Redeem:
                        m_recording.WriteLine("re:" + (r.Data as CardInstance).Guid.ToString());
                        break;
                    case Interactions.BaseInteraction.PlayerAction.AttackCard:
                        m_recording.WriteLine("atc:" + (r.Data as CardInstance[])[0].Guid.ToString() + ":" + (r.Data as CardInstance[])[1].Guid.ToString());
                        break;
                    case Interactions.BaseInteraction.PlayerAction.AttackPlayer:
                        m_recording.WriteLine("atp:" + ((r.Data as object[])[0] as CardInstance).Guid.ToString() + ":" + tp.Game.Players.IndexOf((r.Data as object[])[1] as Player).ToString());
                        break;
                }
            }
            else if (io is Interactions.SelectCards)
            {
                m_recording.WriteLine(result != null
                                      ? (result as IIndexable<CardInstance>).Aggregate("se", (s, c) => s + ":" + c.Guid.ToString())
                                      : "se:null");
            }
            else if (io is Interactions.MessageBox)
            {
                m_recording.WriteLine("me:" + result.ToString());
            }
            else if (io is Interactions.SelectNumber)
            {
                var si = result as int?;
                m_recording.WriteLine("sn:" + (si == null ? "null" : si.ToString()));
            }
            else if (io is Interactions.SelectCardModel)
            {
                m_recording.WriteLine("sc:" + (result == null ? "null" : (io as Interactions.SelectCardModel).Candidates.IndexOf(result as ICardModel).ToString()));
            }
        }
        internal void NeedInteraction(Behaviors.IBehavior user, int ticket, bool compulsory, Interactions.IQuickInteraction io)
        {
            if (io == null)
            {
                throw new ArgumentNullException("io");
            }

            AddInteractionCondition(user, ticket, compulsory, io, null);
        }
 public void RemoteEnterInteraction(Interactions.BaseInteraction io)
 {
     System.Diagnostics.Debug.Assert(m_remoteInteraction == null);
     m_remoteInteraction = io;
     if (m_interactionMessageQueue.Count != 0)
     {
         var msg = m_interactionMessageQueue.Dequeue();
         ProcessInteractionMessage(msg);
     }
 }
        public override bool OnTurnStarted(Interactions.NotifyPlayerEvent io)
        {
            if (GameApp.Service<Services.GameUI>().UIState is Services.UIStates.PlayerTransition)
            {
                (GameApp.Service<Services.GameUI>().UIState as Services.UIStates.PlayerTransition).OnTurnStarted(io);
                return true;
            }

            return false;
        }
        public override bool OnCardPlayCanceled(Interactions.NotifyCardEvent io)
        {
            if (!String.IsNullOrEmpty(io.Message))
            {
                GameApp.Service<Services.PopupDialog>().PushMessageBox(io.Message, () => io.Respond());
                return true;
            }

            return false;
        }
 public override bool OnTurnEnded(Interactions.NotifyPlayerEvent io)
 {
     var nextPid = io.Game.NextActingPlayer.Index;
     if ((io.Game.Controller as XnaUIController).Agents[nextPid] is LocalPlayerAgent)
     {
         GameApp.Service<Services.GameUI>().EnterState(new Services.UIStates.PlayerTransition(), io);
         return true;
     }
     return false;
 }
 private void ProcessRespondPlayCard(Interactions.BaseInteraction io, object result)
 {
     var tacticalPhaseIo = (Interactions.TacticalPhase)io;
     var tacticalPhaseResult = (Interactions.TacticalPhase.Result)result;
     var index = tacticalPhaseIo.PlayCardCandidates.IndexOf((CardInstance)tacticalPhaseResult.Data);
     EnqueueOutboxMessage(
         "<Message><Type>Game</Type><Time>{1}</Time><Game><Action>PlayCard</Action><PlayCardIndex>{0}</PlayCardIndex></Game></Message>"
         , index
         , DateTime.Now);
 }
Beispiel #40
0
 public void OnEnter(Interactions.BaseInteraction io)
 {
     m_io = (Interactions.TacticalPhase)io;
     m_gameUI.RemoveAllContextButtons();
     if (m_io.CanPass)
     {
         m_gameUI.AddContextButton("结束", ContextButton_OnPass);
     }
     m_castFromCards = m_io.CastSpellCandidates.Select(spell => spell.Host).Distinct().ToArray();
 }
		private bool OnNotified(Interactions.NotifyGameEvent interactionObj)
		{
			switch (interactionObj.Notification)
			{
				default:
					break;
			}

			interactionObj.Respond();
			return false;
		}
        public override void OnRespondBack(Interactions.BaseInteraction io, object result)
        {
            base.OnRespondBack(io, result);

            if (m_NetworkClient == null)
            {
                return;
            }

            if (io is Interactions.TacticalPhase)
            {
                var tacticalPhaseResult = (Interactions.TacticalPhase.Result)result;

                // queue
                m_NetworkClient.LocalLeaveInteraction(tacticalPhaseResult.ActionType, io, result);

                // if the response is AttackCard, AttackPlayer, Pass
                // Flush Outbox message queue
                if (tacticalPhaseResult.ActionType == Interactions.BaseInteraction.PlayerAction.AttackCard
                    || tacticalPhaseResult.ActionType == Interactions.BaseInteraction.PlayerAction.AttackPlayer
                    || tacticalPhaseResult.ActionType == Interactions.BaseInteraction.PlayerAction.Pass
                    )
                    m_NetworkClient.FlushOutboxQueue();

            }
            else if (io is Interactions.SelectCards
                || io is Interactions.SelectNumber
                || io is Interactions.MessageBox)
            {
                // queue
                if (io is Interactions.SelectCards)
                {
                    var selectCardsResult = result as IIndexable<CardInstance>;
                    m_NetworkClient.LocalLeaveInteraction(Interactions.BaseInteraction.PlayerAction.SelectCards, io, result);
                }
                else if (io is Interactions.SelectNumber)
                {
                    var selectCardsResult = result as int?;
                    m_NetworkClient.LocalLeaveInteraction(Interactions.BaseInteraction.PlayerAction.SelectNumber, io, result);
                }
                else
                {
                    throw new NotImplementedException();
                }

                throw new NotImplementedException();
                //if (io.Game.RunningCommand.ExecutionPhase != Commands.CommandPhase.Condition)
                //{
                //    // means the command will never be canceled
                //    // flush
                //    m_NetworkClient.FlushOutboxQueue();
                //}
            }
        }
 public void LocalLeaveInteraction(Interactions.BaseInteraction.PlayerAction action, Interactions.BaseInteraction io, object result)
 {
     Action<Interactions.BaseInteraction, object> processRespondAction;
     if (m_outboxActionloopups.TryGetValue(action, out processRespondAction))
     {
         processRespondAction(io, result);
     }
     else
     {
         throw new NotImplementedException("The method for {0} has not been implemented.");
     }
 }
        public void OnTurnStarted(Interactions.BaseInteraction io)
        {
            var onTurnStarted = io as Interactions.NotifyPlayerEvent;

            GameApp.Service<PopupDialog>().PopTopDialog();
            GameApp.Service<PopupDialog>().PushMessageBox(onTurnStarted.Player.Name + "'s turn", UI.ModalDialogs.MessageBox.ButtonFlags.OK, 1, (btn) =>
            {
                if (onTurnStarted != null && onTurnStarted.Notification == "OnTurnStarted")
                {
                    onTurnStarted.Respond();
                    GameApp.Service<GameUI>().LeaveState();
                }
            });
        }
        protected override bool OnNotified(Interactions.NotifyGameEvent interactionObj)
        {
            switch (interactionObj.Notification)
            {
                case "OnInitiativeCommandEnd":
                    m_agents[Game.ActingPlayer.Index].OnInitiativeCommandEnd();
                    break;
                case "OnInitiativeCommandCanceled":
                    m_agents[Game.ActingPlayer.Index].OnInitiativeCommandCanceled();
                    break;
                default:
                    break;
            }

            interactionObj.Respond();
            return false;
        }
 public override void OnMessageBox(Interactions.MessageBox io)
 {
     // translate from Interactions.MessageBox.Button to UI.ModalDialogs.MessageBox.ButtonFlags
     UI.ModalDialogs.MessageBox.ButtonFlags buttons = 0;
     if ((io.Buttons & Interactions.MessageBoxButtons.OK) != 0)
     {
         buttons |= UI.ModalDialogs.MessageBox.ButtonFlags.OK;
     }
     if ((io.Buttons & Interactions.MessageBoxButtons.Cancel) != 0)
     {
         buttons |= UI.ModalDialogs.MessageBox.ButtonFlags.Cancel;
     }
     if ((io.Buttons & Interactions.MessageBoxButtons.Yes) != 0)
     {
         buttons |= UI.ModalDialogs.MessageBox.ButtonFlags.Yes;
     }
     if ((io.Buttons & Interactions.MessageBoxButtons.No) != 0)
     {
         buttons |= UI.ModalDialogs.MessageBox.ButtonFlags.No;
     }
     GameApp.Service<Services.PopupDialog>().PushMessageBox(io.Text, buttons, btn =>
     {
         // translate back...
         Interactions.MessageBoxButtons ibtn;
         switch (btn)
         {
             case UI.ModalDialogs.MessageBox.ButtonOK:
                 ibtn = Interactions.MessageBoxButtons.OK;
                 break;
             case UI.ModalDialogs.MessageBox.ButtonCancel:
                 ibtn = Interactions.MessageBoxButtons.Cancel;
                 break;
             case UI.ModalDialogs.MessageBox.ButtonYes:
                 ibtn = Interactions.MessageBoxButtons.Yes;
                 break;
             case UI.ModalDialogs.MessageBox.ButtonNo:
                 ibtn = Interactions.MessageBoxButtons.No;
                 break;
             default:
                 throw new ArgumentException("btn");
         }
         io.Respond(ibtn);
     });
 }
		private bool OnNotified(Interactions.NotifyPlayerEvent interactionObj)
		{
            switch (interactionObj.Notification)
            {
                case "OnPlayerPhaseChanged":
                    {
                        Console.WriteLine(">> ---Player {0}'s {1}---", interactionObj.Player.Name, interactionObj.Message);
                    }
                    break;
                case "OnPlayerLifeSubtracted":
                    Console.WriteLine(">> Player {0} suffers {1}.", interactionObj.Player.Name, interactionObj.Message);
                    break;
                default:
                    break;
            }

			interactionObj.Respond();
			return false;
		}
        protected override bool OnNotified(Interactions.NotifyCardEvent interactionObj)
        {
            switch (interactionObj.Notification)
            {
                case "OnCardDestroyed":
                    m_destroyedCards.Add(interactionObj.Card.Guid);
                    break;
                case "OnCardPlayCanceled":
                    if (m_agents[Game.ActingPlayer.Index].OnCardPlayCanceled(interactionObj))
                    {
                        return true;
                    }
                    break;
                default:
                    break;
            }

            interactionObj.Respond();
            return false;
        }
Beispiel #49
0
        public override void OnTacticalPhase(Interactions.TacticalPhase io)
        {
            var respond = m_playingBack.ReadLine().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            var verb = respond[0];
            var args = new int[respond.Length - 1];
            for (int i = 1; i < respond.Length; ++i)
            {
                args[i - 1] = Int32.Parse(respond[i]);
            }

            switch (verb)
            {
                case "pa":
                    io.RespondPass();
                    break;
                case "pl":
                    io.RespondPlay(io.PlayCardCandidates.First(c => c.Guid == args[0]));
                    break;
                case "ac":
                    io.RespondActivate(io.ActivateAssistCandidates.First(c => c.Guid == args[0]));
                    break;
                case "sa":
                    io.RespondSacrifice(io.SacrificeCandidates.First(c => c.Guid == args[0]));
                    break;
                case "re":
                    io.RespondRedeem(io.RedeemCandidates.First(c => c.Guid == args[0]));
                    break;
                case "ca":
                    io.RespondCast(io.CastSpellCandidates.First(c => c.Host.Guid == args[0] && c.Host.Behaviors[args[1]] == c));
                    break;
                case "atc":
                    io.RespondAttackCard(io.AttackerCandidates.First(c => c.Guid == args[0]), io.DefenderCandidates.First(c => c.Guid == args[1]));
                    break;
                case "atp":
                    io.RespondAttackPlayer(io.AttackerCandidates.First(c => c.Guid == args[0]), io.Game.Players[args[1]]);
                    break;
                default:
                    throw new NotSupportedException(String.Format("Unrecognized verb {0}", verb));
            }
        }
        protected override bool OnNotified(Interactions.NotifyPlayerEvent interactionObj)
        {
            switch (interactionObj.Notification)
            {
                case "OnTurnEnded":
                    if (m_agents[Game.ActingPlayer.Index].OnTurnEnded(interactionObj))
                    {
                        return true;
                    }
                    break;
                case "OnTurnStarted":
                    if (m_agents[Game.ActingPlayer.Index].OnTurnStarted(interactionObj))
                    {
                        return true;
                    }
                    break;
                default:
                    break;
            }

            interactionObj.Respond();
            return false;
        }
        private bool OnNotified(Interactions.NotifyCardEvent interactionObj)
        {
            switch (interactionObj.Notification)
            {
                case "OnCardDrawn":
                    Console.WriteLine(">> Player {0} drew card {1}", interactionObj.Card.Owner.Name, interactionObj.Card.Model.Name);
                    break;
                case "OnCardPlayed":
                    Console.WriteLine(">> Player {0} played card {1} onto the battlefield.", interactionObj.Card.Owner.Name, interactionObj.Card.Model.Name);
                    break;
                case "OnCardPlayCanceled":
                    Console.WriteLine(">> Player {0} canceled playing card {1}: {2}", interactionObj.Card.Owner.Name, interactionObj.Card.Model.Name, interactionObj.Message);
                    break;
                case "OnCardDestroyed":
                    Console.WriteLine(">> Player {0} card {1} is Destroyed", interactionObj.Card.Owner.Name, interactionObj.Card.Model.Name);
                    break;
                default:
                    throw new ArgumentException(string.Format("Argument {0} is illegal.", interactionObj.Notification));
            }

            interactionObj.Respond();
            return false;
        }
Beispiel #52
0
 public override void OnSelectCards(Interactions.SelectCards io)
 {
     var respond = m_playingBack.ReadLine().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
     if (respond[0] == "se")
     {
         if (respond[1] == "null")
         {
             io.Respond(null);
         }
         else
         {
             CardInstance[] cards = new CardInstance[respond.Length - 1];
             for (int i = 1; i < respond.Length; ++i)
             {
                 cards[i - 1] = io.Candidates.First(c => c.Guid == Int32.Parse(respond[i]));
             }
             io.Respond(cards.ToIndexable());
         }
     }
     else
     {
         throw new NotSupportedException(String.Format("Unrecognized verb {0}", respond[0]));
     }
 }
 /// <summary>
 /// Adds and interaction to the plotsurface that adds functionality that responds 
 /// to a set of mouse / keyboard events. 
 /// </summary>
 /// <param name="i">the interaction to add.</param>
 public void AddInteraction(Interactions.Interaction i)
 {
     interactions_.Add(i);
 }
 /// <summary>
 /// Remove a previously added interaction
 /// </summary>
 /// <param name="i">interaction to remove</param>
 public void RemoveInteraction(Interactions.Interaction i)
 {
     interactions_.Remove(i);
 }
 protected override bool OnNotified(Interactions.NotifySpellEvent interactionObj)
 {
     interactionObj.Respond();
     return false;
 }
            private void OnInteraction(Interactions.BaseInteraction io, IEnumerable<Choice> choices)
            {
                ++CurrentBranchDepth;

                if (!ChoiceMade)
                {
                    var mainPhase = io as Interactions.TacticalPhase;
                    PendingBranch firstBranch = null;

                    foreach (var choice in choices)
                    {
                        if (mainPhase != null && choice is KillBranchChoice)
                        {
                            continue;
                        }

                        var branch = ForkBranch(choice);

                        if (mainPhase != null)
                        {
                            // create save point
                            branch.Root = io.Game.Clone();
                            branch.Depth = CurrentBranchDepth;
                            branch.Order = Math.Max(choice.Order, CurrentBranchOrder);

                            if (choice is PlayCardChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondPlay(
                                    mainPhase.PlayCardCandidates[(choice as PlayCardChoice).CardIndex]);
                            }
                            else if (choice is ActivateAssistChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondActivate(
                                    mainPhase.ActivateAssistCandidates[(choice as ActivateAssistChoice).CardIndex]);
                            }
                            else if (choice is CastSpellChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondCast(
                                    mainPhase.CastSpellCandidates[(choice as CastSpellChoice).SpellIndex]);
                            }
                            else if (choice is SacrificeChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondSacrifice(
                                    mainPhase.SacrificeCandidates[(choice as SacrificeChoice).CardIndex]);
                            }
                            else if (choice is RedeemChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondRedeem(
                                    mainPhase.RedeemCandidates[(choice as RedeemChoice).CardIndex]);
                            }
                            else if (choice is AttackCardChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondAttackCard(
                                    mainPhase.AttackerCandidates[(choice as AttackCardChoice).AttackerIndex],
                                    mainPhase.DefenderCandidates[(choice as AttackCardChoice).DefenderIndex]);
                            }
                            else if (choice is AttackPlayerChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondAttackPlayer(
                                    mainPhase.AttackerCandidates[(choice as AttackPlayerChoice).AttackerIndex],
                                    mainPhase.Game.Players[(choice as AttackPlayerChoice).PlayerIndex]);
                            }
                            else if (choice is PassChoice)
                            {
                                branch.Response = mainPhase.CompiledRespondPass();
                            }
                        }

                        if (firstBranch == null)
                        {
                            firstBranch = branch;
                        }
                        else
                        {
                            if (m_pendingBranches.Count < BatchSize)
                            {
                                m_pendingBranches.Add(branch);
                            }
                            else
                            {
                                m_sandbox.StartBranch(branch);
                            }
                        }
                    }

                    if (firstBranch != null)
                    {
                        m_currentBranch = firstBranch;
                    }
                }

                if (ChoiceMade)
                {
                    var nextChoice = NextChoice;
                    nextChoice.Make(io);
                    CurrentBranchOrder = Math.Max(nextChoice.Order, CurrentBranchOrder);
                }
                else
                {
                    // no choice generated
                    System.Diagnostics.Debug.Assert(io is Interactions.TacticalPhase);
                    (io as Interactions.TacticalPhase).RespondAbort();
                }
            }
Beispiel #57
0
 public override void OnSelectNumber(Interactions.SelectNumber io)
 {
     var respond = m_playingBack.ReadLine().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
     if (respond[0] == "sn")
     {
         io.Respond(respond[1] == "null" ? (int?)null : Int32.Parse(respond[1]));
     }
     else
     {
         throw new NotSupportedException(String.Format("Unrecognized verb {0}", respond[0]));
     }
 }
Beispiel #58
0
 public override void OnSelectCardModel(Interactions.SelectCardModel io)
 {
     var respond = m_playingBack.ReadLine().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
     if (respond[0] == "sc")
     {
         io.Respond(respond[1] == "null" ? (ICardModel)null : io.Candidates[Int32.Parse(respond[1])]);
     }
     else
     {
         throw new NotSupportedException(String.Format("Unrecognized verb {0}", respond[0]));
     }
 }
Beispiel #59
0
 public override void OnMessageBox(Interactions.MessageBox io)
 {
     var respond = m_playingBack.ReadLine().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
     if (respond[0] == "me")
     {
         io.Respond((Interactions.MessageBoxButtons)Enum.Parse(typeof(Interactions.MessageBoxButtons), respond[1]));
     }
     else
     {
         throw new NotSupportedException(String.Format("Unrecognized verb {0}", respond[0]));
     }
 }
        private void AddInteractionCondition(Behaviors.IBehavior user, int ticket, bool compulsory, Interactions.IQuickInteraction io, Func<Interactions.IQuickInteraction> deferredIO)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            CheckInPrerequisite();

            foreach (var cond in m_interactionConditions)
            {
                if (cond.m_user == user && cond.m_ticket == ticket)
                {
                    throw new InvalidOperationException("Interaction condition with the same ticket has already been registered for the behavior.");
                }
            }

            m_interactionConditions.Add(new InteractionCondition
            {
                m_user = user,
                m_ticket = ticket,
                m_compulsory = compulsory,
                m_io = io,
                m_deferredIO = deferredIO,
                m_result = null
            });
        }