当前位置: 首页>>代码示例>>C#>>正文


C# GameEntity.GetPos方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:Zopherus,项目名称:FBLA-Game,代码行数:26,代码来源:ChaseState.cs

示例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()));
     }
 }
开发者ID:Zopherus,项目名称:FBLA-Game,代码行数:13,代码来源:InteractionMgr.cs

示例3: ChaseState

 public ChaseState(GameEntity unitToAttack)
     : base(unitToAttack.GetPos())
 {
     _unitToAttack = unitToAttack;
 }
开发者ID:Zopherus,项目名称:FBLA-Game,代码行数:5,代码来源:ChaseState.cs

示例4: DamageEnemy

 public virtual void DamageEnemy(GameEntity gameEntity)
 {
     gameEntity.TakeDamage(this.GetDamage());
     Vector3 towards = gameEntity.GetPos() - this.GetPos();
     SetDir(towards);
     _timeSinceLastAttack = 0.0f;
 }
开发者ID:Zopherus,项目名称:FBLA-Game,代码行数:7,代码来源:GamePlayer.cs


注:本文中的GameEntity.GetPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。