/// raycast in FixedUpdate, because raycasts done in Update won't work reliably.
/// This nullable vector will be set to a screen coordinate when an attack click was made.
/// </summary>
private System . Nullable < Vector3 > m_Attack ClickRequest ;
private System . Nullable < Vector3 > m_ClickRequest ;
public override void NetworkStart ( )
{
}
}
if ( m_AttackClickRequest ! = null )
if ( m_ClickRequest ! = null )
if ( Physics . Raycast ( Camera . main . ScreenPointToRay ( m_AttackClickRequest . Value ) , out hit ) & & GetTargetObject ( ref hit ) ! = 0 )
if ( Physics . Raycast ( Camera . main . ScreenPointToRay ( m_ClickRequest . Value ) , out hit ) & & GetTargetObject ( ref hit ) ! = 0 )
//these two actions will queue one after the other, causing us to run over to our target and take a swing.
//if we have clicked on an enemy:
// - two actions will queue one after the other, causing us to run over to our target and take a swing.
//if we have clicked on a fallen friend - we will revive him
var chase_data = new ActionRequestData ( ) ;
chase_data . ActionTypeEnum = ActionType . GENERAL_CHASE ;
chase_data . Amount = ActionData . ActionDescriptions [ ActionType . TANK_BASEATTACK ] [ 0 ] . Range ;
var hit_data = new ActionRequestData ( ) ;
hit_data . ShouldQueue = true ; //wait your turn--don't clobber the chase action.
hit_data . ActionTypeEnum = ActionType . TANK_BASEATTACK ;
m_NetworkCharacter . ClientSendActionRequest ( ref hit_data ) ;
//TODO fixme: there needs to be a better way to check if target is a PC or an NPC
bool isTargetingNPC = hit . transform . gameObject . layer = = LayerMask . GetMask ( "PCs" ) ;
if ( isTargetingNPC )
{
var hit_data = new ActionRequestData ( ) ;
hit_data . ShouldQueue = true ; //wait your turn--don't clobber the chase action.
hit_data . ActionTypeEnum = ActionType . TANK_BASEATTACK ;
m_NetworkCharacter . ClientSendActionRequest ( ref hit_data ) ;
}
else
{
//proceed to revive the target if it's in FAINTED state
var targetCharacterState = hit . transform . GetComponent < NetworkCharacterState > ( ) ;
if ( targetCharacterState . NetworkLifeState . Value = = LifeState . FAINTED )
{
var revive_data = new ActionRequestData ( ) ;
revive_data . ShouldQueue = true ;
revive_data . ActionTypeEnum = ActionType . GENERAL_REVIVE ;
m_NetworkCharacter . ClientSendActionRequest ( ref revive_data ) ;
}
}
}
else
{
}
m_Attack ClickRequest = null ;
m_ClickRequest = null ;
}
}
if ( Input . GetMouseButtonDown ( 1 ) )
{
m_Attack ClickRequest = Input . mousePosition ;
m_ClickRequest = Input . mousePosition ;
}
}