public override void MouseClick(GameObject hitEntity, Vector3 hitPoint, Player player) { base.MouseClick(hitEntity, hitPoint, player); if (player == null) { return; } if (player.IsNPC == true) { return; } if (isSelected == false) { return; } bool isGround = hitEntity.CompareTag(Tags.GROUND); if (isGround == false) { return; } if (hitPoint == GlobalAssets.InvalidPoint) { return; } float x = hitPoint.x; float y = hitPoint.y + player.SelectedEntity.transform.position.y; // Ensures rallyPoint stays on top of the surface it is on float z = hitPoint.z; Vector3 pointClicked = new Vector3(x, y, z); UpdateRallyPointPosition(pointClicked); }
public virtual void MouseClick(GameObject hitGameObject, Vector3 hitPoint, Player player) { if (isSelected == false) { return; } if (hitGameObject == null) { return; } bool isGround = hitGameObject.CompareTag(Tags.GROUND); if (isGround == true) { return; } Destructible hitEntity = hitGameObject.GetComponentInParent<Destructible>(); if (hitEntity == null) { return; } if (hitEntity == this) { return; } bool readyToAttack = IsAbleToAttack(); if (readyToAttack == false) { ChangeSelection(hitEntity, player); return; } if (hitEntity.MaxHitPoints == 0) { ChangeSelection(hitEntity, player); return; } Player hitEntityOwner = hitEntity.Owner; if (hitEntityOwner != null) { bool samePlayer = Owner.PlayerId == hitEntityOwner.PlayerId; if (samePlayer == true) { ChangeSelection(hitEntity, player); return; } } SetAttackTarget(hitEntity); }
private void ChangeSelection(Selectable otherEntity, Player player) { if (otherEntity == this) { return; } SetSelection(false); if (player.SelectedEntity != null) { player.SelectedEntity.SetSelection(false); } player.SelectedEntity = otherEntity; playingArea = Hud.GetPlayingArea(); otherEntity.SetSelection(true); }
public bool IsOwnedByPlayer(Player player) { if (Owner == null) { return false; } return Owner.Equals(player); }