Post by Legend on Mar 17, 2018 4:09:49 GMT
Hello
anyone have any recommendation on this code and converting it to be used into the CCG tutorial game - what i mean to say is recommendation on where to start with converting this code - for instance implementing and testing bits and pieces of it
basically it should for the most part if a minion is selected create an arrow and if its a card it will actually drag the card make it small and let you drop on to a target.
thanks!
daniel
#region on pointer drag
void OnPointerDragTargetSelectState()
{
if (Input.mousePosition == last_mouse_pos) return;
last_mouse_pos = Input.mousePosition;
RaycastHit[] hit = ObjectsHit( new string[]{"Creatures", "Terrain"} );
if (null == hit)
return;
foreach(RaycastHit rch in hit)
{
if (rch.transform.position != tvData.character_targets.SourcePosition && LayerMask.LayerToName(rch.transform.gameObject.layer) == "Creatures")
{
tvData.Instance.arrow_being_dragged.SetDestination( rch.transform.position );
return;
}
}
tvData.Instance.arrow_being_dragged.SetDestination( hit[0].point );
}
void OnPointerDragCardTargetSelectState()
{
if (Input.mousePosition == last_mouse_pos) return;
last_mouse_pos = Input.mousePosition;
RaycastHit[] hit = ObjectsHit( new string[]{"Creatures"} );
if (hit.Length == 0)
{
tvData.Instance.arrow_being_dragged?.SetDestination(tvData.Instance.arrow_being_dragged.transform.position);
return;
}
foreach(RaycastHit rch in hit)
{
if ( LayerMask.LayerToName(rch.transform.gameObject.layer) == "Creatures" )
{
tvCharacter character = rch.transform.GetComponentInParent<tvCharacter>();
if (null != character && tvData.ActiveCardTargetting.available_targets.Contains(character))
{
tvData.Instance.arrow_being_dragged.SetDestination( rch.transform.position );
tvData.Instance.arrow_being_dragged.target = character;
return;
}
tvData.Instance.arrow_being_dragged.target = null;
}
}
}
#endregion
#region on pointer drag
void OnPointerDragTargetSelectState()
{
if (Input.mousePosition == last_mouse_pos) return;
last_mouse_pos = Input.mousePosition;
RaycastHit[] hit = ObjectsHit( new string[]{"Creatures", "Terrain"} );
if (null == hit)
return;
foreach(RaycastHit rch in hit)
{
if (rch.transform.position != tvData.character_targets.SourcePosition && LayerMask.LayerToName(rch.transform.gameObject.layer) == "Creatures")
{
tvData.Instance.arrow_being_dragged.SetDestination( rch.transform.position );
return;
}
}
tvData.Instance.arrow_being_dragged.SetDestination( hit[0].point );
}
void OnPointerDragCardTargetSelectState()
{
if (Input.mousePosition == last_mouse_pos) return;
last_mouse_pos = Input.mousePosition;
RaycastHit[] hit = ObjectsHit( new string[]{"Creatures"} );
if (hit.Length == 0)
{
tvData.Instance.arrow_being_dragged?.SetDestination(tvData.Instance.arrow_being_dragged.transform.position);
return;
}
foreach(RaycastHit rch in hit)
{
if ( LayerMask.LayerToName(rch.transform.gameObject.layer) == "Creatures" )
{
tvCharacter character = rch.transform.GetComponentInParent<tvCharacter>();
if (null != character && tvData.ActiveCardTargetting.available_targets.Contains(character))
{
tvData.Instance.arrow_being_dragged.SetDestination( rch.transform.position );
tvData.Instance.arrow_being_dragged.target = character;
return;
}
tvData.Instance.arrow_being_dragged.target = null;
}
}
}
#endregion