本文整理汇总了C#中GameEntity.GetPos方法的典型用法代码示例。如果您正苦于以下问题:C# GameEntity.GetPos方法的具体用法?C# GameEntity.GetPos怎么用?C# GameEntity.GetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEntity
的用法示例。
在下文中一共展示了GameEntity.GetPos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateState
public override void UpdateState(GameEntity unit)
{
base.UpdateState(unit);
if (_unitToAttack == null || _unitToAttack.IsDead())
{
unit.GetStateMachine().ChangeState(new RestState());
return;
}
Vector3 unitToAttackPos = _unitToAttack.GetPos();
// As the unit must move towards a dynamic position.
unit.MoveTo(unitToAttackPos);
float extra = _unitToAttack is GameBuilding ? GameBuilding.EXTRA_ATTACK_DIST : 0.0f;
float attackRange = unit.GetAttackRange() + extra;
// Is the unit within attacking distance of the unit to attack?
float distance = Vector3.Distance(unitToAttackPos, unit.GetPos());
if (distance < (attackRange - ARRIVE_THRESHOLD))
{
// Start attacking the other object.
unit.GetStateMachine().ChangeState(new AttackState(_unitToAttack));
}
}
示例2: UnitClicked
private static void UnitClicked(GameEntity clickedGameUnit)
{
if (clickedGameUnit.GetTeam() != 0)
{
Debug.Log("Clicked on enemy");
SetStateForAllSelected(new ChaseState(clickedGameUnit));
}
else
{
// For now just move the selected units towards the clicked unit.
SetStateForAllSelected(new MoveState(clickedGameUnit.GetPos()));
}
}
示例3: ChaseState
public ChaseState(GameEntity unitToAttack)
: base(unitToAttack.GetPos())
{
_unitToAttack = unitToAttack;
}
示例4: DamageEnemy
public virtual void DamageEnemy(GameEntity gameEntity)
{
gameEntity.TakeDamage(this.GetDamage());
Vector3 towards = gameEntity.GetPos() - this.GetPos();
SetDir(towards);
_timeSinceLastAttack = 0.0f;
}