|
Post by LEgend on Apr 23, 2018 16:46:09 GMT
So trying to list cards and i dont think i understand this pooler system fully i tried to go back to the tutorial but not fully getting it
basically i copied this from handview - and i know what its trying to do i think its trying to dequeue from the pooler but it might not be there or something because well when i played the card i didnt add it back to the queue - i dont really want to dequeue and queue though so i removed that - but just curious
1. what does the pooler actually do / used for - is it denoting the deck in a way? is it just storing some cards in memory or something?
2. i just wanted to show the buff as a card - have any suggestions to do this? do i need to instantiate or something i tried was new cardview() but that doesnt work cause it has monobehavior -
what i was thinking to do was 1.create cardView - 2.attach the card (which is AS a buff)
3.add the cardview to a list 4.display the list in a scrollrect
void LoadCardsViewer(List<Card> cards)
{
//var boardView = GetComponent<BoardView>();
foreach (var card in cards) {
//var cardView = boardView.cardPooler.Dequeue().GetComponent<CardView>();
cardView.Flip(true);
cardView.card = card;
cardView.transform.ResetParent(GridTransform);
cardView.gameObject.SetActive(true);
loadedCards.Add(cardView);
transformcardList.Add(cardView.transform);
}
}
thanks for always being patient!
|
|
|
Post by Legend on Apr 24, 2018 4:39:12 GMT
2.attach the card (which is AS a buff)
actually its a card i didnt mean to make it confusing
|
|
|
Post by Legend on Apr 24, 2018 12:40:20 GMT
here is what i think - the pooling scripts help create the gameobject of the prefab when needed it has something to do with the enqueue and dequeue functions. i am not entirely sure yet how it actually gets there cause it looks pretty complicated but i believe thats the just...and i created another notification for calling the buff window for the minion/player - i know what the issue was - the boardview - get component should be getocmponent in parent because the drawcardsviewer is actually in the same object as the boardview...so makes sense.
|
|
|
Post by Admin on Apr 24, 2018 14:36:01 GMT
Sounds like you got it... but I'll confirm for you. Yes, the "Pooler" is responsible for maintaining instantiated copies of a prefab. If you need an instance and one doesn't exist, it will create one for you. If you are done with an instance you can return it to the pooler (via enqueue) so it can be reused again later (via dequeue). The reason for a pooling system is that instantiating a complex object like a gameobject prefab can be "expensive" so many games will see better performance by reusing objects instead of continuously creating and destroying them.
|
|
|
Post by Legend on Apr 24, 2018 18:10:54 GMT
Awesome thanks! I got it almost there just gotta figure out how to get that card to actually display the card information instead of instantiate the default garbage info...and get that card in the rect scroll view
|
|
|
Post by Legend on Apr 24, 2018 21:16:07 GMT
ahh heck i know what my issue is -
the buff system never actually copied the card contents over - when the card is cast from the action it uses the standard constructor which doesnt pass anything along so the buff name cost etc doesnt get added to that buff...
this is going to be difficult to figure out - i copied it like the damageaction but clearly that wont work since that doesnt actually use any 'card' information within the action so i cant attach information from the card to the buff that i need to.
if you have anyyyyy recommendations im all ears on this one :S
|
|
|
Post by Admin on Apr 25, 2018 1:12:20 GMT
I'm not sure I understand exactly what you are doing, but to help you learn, I would recommend that you try to recreate everything necessary for the application of a targeted damage spell, except that you will make it add to the stat instead of remove from it, and the targeted stat might be something like a minion's attack stat instead of its hit points. I wouldn't worry about needing to be able to remove buffs at this point.
Once you've mastered the first part, then you might look at ways to make the system more flexible. For example, instead of merely applying the stat change to the targeted card, you could also append an "applied buff marker" ability of some sort onto the target. This would copy the stats from the spell card so you know stuff like "I added 6 to this card's attack", so that later a different spell could look for those markers and "undo" them if needed.
|
|
|
Post by Legend on Apr 25, 2018 3:21:41 GMT
so i have all that stuff working and such but it adds a BUFF to the LIST<BUFF> that the minion has... the problem is that the buff doesnt have the card information like - cost name etc cause i assign the data through the ability as below
"id": "Card10", "type": "Spell", "name": "Buffthing", "text": "boost attack buff", "cost": 1, "target": { "allowed": { "alliance": "Any", "zone": "Active" }, "preferred": { "alliance": "Enemy", "zone": "Active" } }, "abilities": [{ "action": "BuffAction", "info": 2, "stat": "attack", "duration": 3, "targetSelector": { "type": "ManualTarget" } }]
-----
#region IAbility public void Load(IContainer game, Ability ability) { var targetSelector = ability.GetAspect<ITargetSelector>(); var cards = targetSelector.SelectTargets(game); targets = new List<IEnchantable>(); foreach (Card card in cards) { var enchantable = card as IEnchantable; if (enchantable != null) targets.Add(enchantable); } buff= new Buff(); buff.amount = Convert.ToInt32(ability.userInfo); buff.duration = Convert.ToInt32(ability.duration); buff.stat = ability.stat; } #endregion
stat is a string duration how long userinfo is the amount to boost
so that my dilema - because this load doesnt pass card data i cant add that data when i create the buff - because of the gameaction design it just calls the no overloaded constructer so i cant pass the data in there....the only thing i can think of so far is to add a prepareplaycard and that shoould get me the card info which i might be able to apply to the buff which is going to be added to the list of the minion upon play.
hope that clears things up a bit.
basically playing spells dont allow overloads and abilities dont pass the card to the action is my issue.
|
|
|
Post by Legend on Apr 25, 2018 4:44:11 GMT
should i understand it that when an action is taken place like the damageaction that the damaction is called the card it will assign the passed variables to the Global variable ... but spells and minions with abilities (spells are just cards with abilities anyways) will fire that first constructor which does nothing i think (maybe it lets the notifications take action i guess) and then the load function will will carry on from there?
here is what i need some logic like this
public class BuffAction: GameAction, IAbilityLoader { public Buff buff;
#region Constructors public BuffAction() { buff = cardthatwasplayed as Buff; }
that would take the card that was just played and set as Buff (Buff inherits from Card) then load would take care of the rest
|
|
|
Post by Legend on Apr 25, 2018 5:01:11 GMT
ummm alll good you are a genius in the design man
you actually have Card within the ability.
all that - problem solved....
buff = new buff(); buff.name = ability.card.name; buff.cost = ability.card.cost;
all i need to do is assign derp - thanks!
|
|