Exemplo n.º 1
0
        public PartyTurnActor()
        {
            MoveAction     moveAction     = new MoveAction(m_activeActions);
            RotateAction   rotateAction   = new RotateAction(m_activeActions);
            RestAction     restAction     = new RestAction();
            InteractAction interactAction = new InteractAction();
            SelectNextInteractiveObjectAction selectNextInteractiveObjectAction = new SelectNextInteractiveObjectAction();

            m_actions = new BaseAction[4][];
            for (Int32 i = 0; i < m_actions.Length; i++)
            {
                m_actions[i]     = new BaseAction[11];
                m_actions[i][0]  = moveAction;
                m_actions[i][1]  = rotateAction;
                m_actions[i][6]  = restAction;
                m_actions[i][2]  = interactAction;
                m_actions[i][10] = selectNextInteractiveObjectAction;
                m_actions[i][3]  = new MeleeAttackAction(i);
                m_actions[i][4]  = new RangedAttackAction(i);
                m_actions[i][9]  = new CastSpellAction(i);
                m_actions[i][5]  = new ConsumeItemAction(i);
                m_actions[i][8]  = new DefendAction(i);
                m_actions[i][7]  = new EquipAction(i);
            }
        }
Exemplo n.º 2
0
 public void UpdateMaterials()
 {
     if (!_init)
     {
         return;
     }
     try
     {
         lock (materialLocker)
         {
             _materialList.Clear();
             List <CastSpellAction> castSpellList = CastSpellAction.GetCastSpellActionList(Branch);
             if (castSpellList != null)
             {
                 foreach (CastSpellAction ca in castSpellList)
                 {
                     if (ca.IsRecipe && ca.RepeatType != CastSpellAction.RepeatCalculationType.Craftable)
                     {
                         foreach (Ingredient ingred in ca.Recipe.Ingredients)
                         {
                             _materialList[ingred.ID] = _materialList.ContainsKey(ingred.ID)
                                                                         ? _materialList[ingred.ID] +
                                                        (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0)
                                                                         : (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         PBLog.Warn(ex.ToString());
     }
 }
        public void UpdateMaterials()
        {
            try
            {
                lock (MaterialList)
                {
                    MaterialList.Clear();
                    List <CastSpellAction> castSpellList =
                        CastSpellAction.GetCastSpellActionList(CurrentProfile.Branch);
                    if (castSpellList != null)
                    {
                        foreach (CastSpellAction ca in castSpellList)
                        {
                            if (ca.IsRecipe)
                            {
                                foreach (var ingred in ca.Recipe.Ingredients)
                                {
                                    MaterialList[ingred.ID] = MaterialList.ContainsKey(ingred.ID) ?
                                                              MaterialList[ingred.ID] + (ca.CalculatedRepeat > 0 ?
                                                                                         (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0) :

                                                              (ca.CalculatedRepeat > 0 ? (int)ingred.Required * (ca.CalculatedRepeat - ca.Casted) : 0);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            { Err(ex.ToString()); }
        }
Exemplo n.º 4
0
    //Comprueba si la carta que se ha jugado es un hechizo y si lo es lo lanza
    void OnPeformPlayCard(object sender, object args)
    {
        var action = args as PlayCardAction;
        var spell  = action.card as Spell;

        if (spell != null)
        {
            var reaction = new CastSpellAction(spell);
            container.AddReaction(reaction);
        }
    }
Exemplo n.º 5
0
        private void toolStripAddBtn_Click(object sender, EventArgs e)
        {
            List<IPBComposite> compositeList = new List<IPBComposite>();
            // if the tradeskill tab is selected
            if (MainTabControl.SelectedTab == TradeSkillTab)
            {
                TradeSkillListView tv = TradeSkillTabControl.SelectedTab as TradeSkillListView;
                if (tv.TradeDataView.SelectedRows == null)
                    return;

                DataGridViewSelectedRowCollection rowCollection = tv.TradeDataView.SelectedRows;
                foreach (DataGridViewRow row in rowCollection)
                {
                    TradeSkillRecipeCell cell = (TradeSkillRecipeCell)row.Cells[0].Value;
                    Recipe recipe = PB.TradeSkillList[tv.TradeIndex].Recipes[cell.RecipeID];
                    int repeat;
                    int.TryParse(toolStripAddNum.Text, out repeat);
                    CastSpellAction.RepeatCalculationType repeatType = CastSpellAction.RepeatCalculationType.Specific;
                    switch (toolStripAddCombo.SelectedIndex)
                    {
                        case 1:
                            repeatType = CastSpellAction.RepeatCalculationType.Craftable;
                            break;
                        case 2:
                            repeatType = CastSpellAction.RepeatCalculationType.Banker;
                            break;
                    }
                    CastSpellAction ca = new CastSpellAction(recipe, repeat, repeatType);
                    compositeList.Add(ca);
                }
            }
            else if (MainTabControl.SelectedTab == ActionsTab)
            {
                if (ActionGridView.SelectedRows != null)
                {
                    foreach (DataGridViewRow row in ActionGridView.SelectedRows)
                    {
                        IPBComposite pa = (IPBComposite)Activator.CreateInstance(row.Tag.GetType());
                        compositeList.Add(pa);
                    }
                }
            }
            copyAction = CopyPasteOperactions.Copy;
            foreach (IPBComposite composite in compositeList)
            {
                if (ActionTree.SelectedNode == null)
                    AddToActionTree(composite, null);
                else
                    AddToActionTree(composite, ActionTree.SelectedNode);
            }
            // now update the CanRepeatCount. 
            PB.UpdateMaterials();
            RefreshTradeSkillTabs();
        }
Exemplo n.º 6
0
        //TODO: OnValidatePlayCard - if the card is a spell and it has a target selector, make sure there are targets available (?)

        private void OnPerformPlayCard(object sender, object args)
        {
            var action       = (PlayCardAction)args;
            var playerSystem = Container.GetSystem <PlayerSystem>();

            if (action.Card.Data.Type == CardType.Spell)
            {
                playerSystem.ChangeZone(action.Card, Zones.None);
                var spellAction = new CastSpellAction(action.Card);
                Container.AddReaction(spellAction);
            }
        }
Exemplo n.º 7
0
        private void ToolStripAddBtnClick(object sender, EventArgs e)
        {
            var compositeList = new List <IPBComponent>();

            // if the tradeskill tab is selected
            if (MainTabControl.SelectedTab == TradeSkillTab)
            {
                var tv = TradeSkillTabControl.SelectedTab as TradeSkillListView;

                if (tv != null)
                {
                    DataGridViewSelectedRowCollection rowCollection = tv.TradeDataView.SelectedRows;
                    foreach (DataGridViewRow row in rowCollection)
                    {
                        var    cell   = (TradeSkillRecipeCell)row.Cells[0].Value;
                        Recipe recipe = ProfessionbuddyBot.Instance.TradeSkillList[tv.TradeIndex].KnownRecipes[cell.RecipeID];
                        int    repeat;
                        int.TryParse(toolStripAddNum.Text, out repeat);
                        var repeatType = CastSpellAction.RepeatCalculationType.Specific;
                        switch (toolStripAddCombo.SelectedIndex)
                        {
                        case 1:
                            repeatType = CastSpellAction.RepeatCalculationType.Craftable;
                            break;

                        case 2:
                            repeatType = CastSpellAction.RepeatCalculationType.Banker;
                            break;
                        }

                        var ca = new CastSpellAction(recipe, repeat, repeatType);
                        compositeList.Add(ca);
                    }
                }
            }
            else if (MainTabControl.SelectedTab == ActionsTab)
            {
                compositeList.AddRange(
                    from DataGridViewRow row in ActionGridView.SelectedRows
                    select(IPBComponent) Activator.CreateInstance(row.Tag.GetType()));
            }
            _copyAction = CopyPasteOperactions.Copy;
            foreach (IPBComponent composite in compositeList)
            {
                AddToActionTree(composite, ActionTree.SelectedNode);
            }
            // now update the CanRepeatCount.
            ProfessionbuddyBot.Instance.UpdateMaterials();
            RefreshTradeSkillTabs();
        }
Exemplo n.º 8
0
        private void ActionGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (ActionGrid.SelectedObject is CastSpellAction && ((CastSpellAction)ActionGrid.SelectedObject).IsRecipe)
            {
                CastSpellAction ca = (CastSpellAction)ActionGrid.SelectedObject;
                PB.UpdateMaterials();
                RefreshTradeSkillTabs();
                RefreshActionTree(typeof(CastSpellAction));
            }
            else
            {
                ActionTree.SuspendLayout();
                UdateTreeNode(ActionTree.SelectedNode, null, null, false);
                ActionTree.ResumeLayout();
            }

            if (PB.CodeWasModified)
                PB.GenorateDynamicCode();
        }