浏览代码

Adding ability to revive friends in inputs

Right-clicking on a fallen ally would make PC to run over to the dead ally and execute Revive action. If we're right-clicking an enemy - we would do a melee attack instead.
/main
sorcerer_king 3 年前
当前提交
ae2d3e69
共有 1 个文件被更改,包括 32 次插入10 次删除
  1. 42
      Assets/BossRoom/Scripts/Client/ClientInputSender.cs

42
Assets/BossRoom/Scripts/Client/ClientInputSender.cs


/// 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_AttackClickRequest;
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_AttackClickRequest = null;
m_ClickRequest = null;
}
}

if (Input.GetMouseButtonDown(1))
{
m_AttackClickRequest = Input.mousePosition;
m_ClickRequest = Input.mousePosition;
}
}

正在加载...
取消
保存