|
Post by Legend on Mar 21, 2018 15:09:56 GMT
Hello I was wondering if you had any tutorials on drag and drop and line tutorials for these - i am currently trying drag to attack first as you have the controller already for that and to start i should just be able to add the UI parts of it but ive only started with a private vector3 startpoint so far..
ive seen a recommendation to use dotween to do this - looking at your Animation namespace i see that you have some stuff but i dont think drawing stuff but that might actually be in a different namespace ? any suggestions would be great!
|
|
|
Post by Admin on Mar 21, 2018 20:49:01 GMT
I haven't added anything for drawing an arrow. Outside of the very most basic and necessary visual indicators to actually play the game, I tend to leave all asset related material up to the reader to implement. A long time ago I looked here... forum.unity.com/threads/implement-a-drag-and-drop-script-with-c.130515/...to get started with drag and drop. There is a video there that shows a sort of UI interface that could be helpful in understanding the basics. Once you know how to plug into the proper events and get screen coordinates properly, it shouldn't be too hard to create some other UI element that can be placed based on a start drag event, and stretch based on drag updates and the current mouse position. For just getting started you could even do a simple sliced image that rotates and expands its width as needed to fill the space between the two points.
|
|
|
Post by Legend on Mar 21, 2018 21:15:33 GMT
thanks for the tutorial -
i used that and your attackcontroller but a little stuck so working on it still
public void OnDrag(PointerEventData eventData) { var handler = stateMachine.currentState as IDragHandler; if (handler != null) handler.OnDrag(eventData);
}
i added a class
private class OnDragState : BaseControllerState, IDragHandler { public void OnDrag(PointerEventData eventData) { Debug.Log(eventData.pointerCurrentRaycast.worldPosition); } }
so far im not getting a debug output so i have to look into why.
|
|
|
Post by Legend on Mar 22, 2018 14:02:36 GMT
k so i figured it out somewhat - when i try to drag it over to the object it actually goes to the center - i believe it has something to do with the camera
eventData.pointerCurrentRaycast.worldPosition;
basically i can drag it all around and the arrow follows mee but when the i hover over actual hero it changes the position automatically to the camera point.. whether i let go or not
|
|
|
Post by Legend on Mar 22, 2018 15:04:16 GMT
got it - in case someone needs it
if (dragging) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 rayPoint = ray.GetPoint(distance); }
thats the ondrag portion
and the if statement to allow the begin drag portion
var attacker = owner.attacker as ICombatant; var attackerHP = owner.attacker as IDestructable;
if (attacker.remainingAttacks > 0 && owner.attacker.ownerIndex == 0 && attacker.remainingAttacks> 0 && attackerHP.hitPoints > 0) {
|
|
|
Post by Admin on Mar 22, 2018 15:23:39 GMT
Glad you are making progress! Keep it up!
A quick tip... your "if" statement for allowing drag will only work in a single-player version of the game. If you want to be able to support multi-player then you should check to make sure that the ownerIndex matches the current player's index, and that the current player is a local user.
See "Match" class for the "Player CurrentPlayer" property. See "Player" class for the "ControlModes mode" and "int index" fields.
Also, if the attacker hit points have been dropped to zero, then the DeathSystem should already have reaped the unit before player input should be allowed, so you probably don't need that check.
|
|
|
Post by Legend on Mar 22, 2018 21:24:25 GMT
Ahh thankyou! - i will modify that to be appropriate - think i did that somewhere else as well - ill have to check that part out too ---alsoo i think i ll need that match part for highlighting the playable cards....its a bit confusing cause i have to update the cardview script then i think either the handview or the card system to subscribe to the on mana change even system to update the highlighting sprite (Disable or enable it ) within the cardview.....just trying to figure that out cause the handview isnt part of the player so i might have to do a getmatch to get the current player within the handview - or something
anyways hope this works
|
|
|
Post by Admin on Mar 22, 2018 22:24:22 GMT
You shouldn't have to worry about all the rules that make a card playable or not, such as having to watch mana on your own.
Check out the "BattlefieldCardView" to see how I highlight minions. Then do something similar on the card's in the player's hand. For example, simply observe the same "Idle State" notifications, then check the "CardSystem" for playable cards instead of the "AttackSystem" for valid attackers. Does that make sense?
|
|
|
Post by Legend on Mar 23, 2018 4:27:57 GMT
I see what you are putting down! had to change my code up a bit instead of a sprite renderer which didnt work so well in this 3d view i used a sprite swap like u did with the active and inactive.
pretty much almost one for one with what you did with the attack system...thanks for the direction!
andddd btw fixed : owner.gameContainer.GetMatch().currentPlayerIndex
the hp part is actually needed - i made a tweak to the game to have multiple 'heroes' and they stay on the battlefield - its mainly there for them.
I remember what i changed - i added an if statement for the ethereal so it wouldnt update on the opponents turn due to it was changing the mana when he was playing spells and such
planning to have 2 seperate mana things in any case judging from what you said and what i gathered i think i did this right
if (container.GetMatch().CurrentPlayer.mode == ControlModes.Local) instead of container.GetMatch().currentPlayerIndex == 0
this will affect the local player which is what i want ... actually in the process of this i just figured i would go ahead and implement what i was going to do which was have another mana and text field for the opponent in the manaview -
seems to work - think im getting the idea i hope...and hope this helps others if i am doing it correctly
if (container.GetMatch().CurrentPlayer.mode == ControlModes.Local) this.PostNotification(ValueChangedNotification, mana); if (container.GetMatch().CurrentPlayer.mode == ControlModes.NPC || container.GetMatch().CurrentPlayer.mode == ControlModes.Remote) this.PostNotification(OpponentValueChangedNotification, mana);
on to secrets! ill make a new post for that one in case that helps anyone out there. mmine will be a bit different as i am going to be playing on my opponenets hero(ES) as well unlike hearthstone
|
|
|
Post by Admin on Mar 23, 2018 13:32:03 GMT
Awesome, thanks for sharing, and if you make a playable game I would love to see it!
|
|