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


C# MyEntity.GetPosition方法代码示例

本文整理汇总了C#中MinerWars.AppCode.Game.Entities.MyEntity.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MyEntity.GetPosition方法的具体用法?C# MyEntity.GetPosition怎么用?C# MyEntity.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MinerWars.AppCode.Game.Entities.MyEntity的用法示例。


在下文中一共展示了MyEntity.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: mineDetector_OnEntityPositionChange

        private void mineDetector_OnEntityPositionChange(MyEntityDetector sender, MyEntity entity, Vector3 newposition)
        {
            if (sender.Closed)
                return;

            if (entity == MySession.PlayerShip)
            {
                if (m_beepCue == null || !m_beepCue.Value.IsPlaying)
                {
                    m_beepCue = MyAudio.AddCue2D(MySoundCuesEnum.SfxHudAlarmDamageA);
                }

                float distance = (entity.GetPosition() - sender.GetPosition()).Length();

                if (distance < m_mineStartRadius)
                {
                    uint mineId = 0;
                    for (int i = 0; i < m_mines.GetLength(0); i++)
                    {
                        if (m_mines[i, 1] == sender.Parent.EntityId.Value.NumericValue)
                        {
                            mineId = m_mines[i, 0];
                        }
                    }
                    ExplodeMine(mineId);
                    sender.Off();
                    sender.Parent.MarkForClose();
                }

            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:31,代码来源:MyMinesField.cs

示例2: Load

 public override void Load(MyMissionBase sender)
 {
     base.Load(sender);
     m_ship = m_shipId.HasValue ? MyScriptWrapper.GetEntity(m_shipId.Value) : MyScriptWrapper.GetEntity(m_shipName);
     m_trajectory = new MyLine(m_ship.GetPosition(), MyScriptWrapper.GetEntity(m_targetId).GetPosition());
     
     if (m_isShip)
     {
         MyScriptWrapper.PrepareMotherShipForMove(m_ship);
     }
     m_shipMoving = true;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:12,代码来源:MyMovingEntity.cs

示例3: MoveMotherShipForwardDest

 bool MoveMotherShipForwardDest(MyEntity entity, float speed, Vector3 destination)
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
     {
         MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
         return false;
     }
     return true;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MyChineseTransportMission.cs

示例4: MoveMotherShip

        void MoveMotherShip(MyEntity entity, Vector3 destination, List<uint> AdditionalStuffToMove) //helps to move even non prefab entities with the ship, like thruster particles and spawnpoints
        {
            MyScriptWrapper.Move(entity, destination);

            Vector3 delta = destination - entity.GetPosition();

            foreach (var item in AdditionalStuffToMove)
            {
                MyEntity Item = MyScriptWrapper.GetEntity(item);
                if (Item != null)
                {
                    MyScriptWrapper.Move(Item, Item.GetPosition() + delta);
                }
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:15,代码来源:MyLaikaMission.cs

示例5: MoveMotherShipForward

 bool MoveMotherShipForward(MyEntity entity, float speed, Vector3 destination, List<uint> AdditionalStuffToMove) //helps to move even non prefab entities with the ship, like thruster particles and spawnpoints
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
     {
         //Render.MyRender.ClearEnhancedStats();
         MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS); // recalculate position
         foreach (var item in AdditionalStuffToMove)
         {
             MyEntity Item = MyScriptWrapper.GetEntity(item);
             if (Item != null)
             {
                 MyScriptWrapper.Move(Item, Item.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
             }
         }
         //MyScriptWrapper.GetEntity((uint)EntityID.CrashingMothershipSmoke).SetPosition(MyScriptWrapper.GetEntity((uint)EntityID.CrashingMothershipSmoke).GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
         //Render.MyRender.ClearEnhancedStats();
         return false;
     }
     return true;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:21,代码来源:MyLaikaMission.cs

示例6: CanSee

 /// <summary>
 /// Chceck if ship can see target
 /// </summary>
 /// <param name="position">Target position</param>
 /// <param name="target">Target entity.</param>
 /// <returns>True, if bot can see position.</returns>
 public static MyEntity CanSee(MyEntity source, MyEntity target)
 {
     return CanSee(source, target.GetPosition(), target);
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MyEnemyTargeting.cs

示例7: CanSeeTarget

        public bool CanSeeTarget(MyEntity target)
        {
            bool canSeeTarget = true;
            if (MyFakes.ENABLE_BOTS_FOV_WHEN_RADAR_JAMMER)
            {
                MySmallShip smallShipTarget = target as MySmallShip;
                if (smallShipTarget != null && !smallShipTarget.IsHologram && smallShipTarget.HasRadarJammerActive())
                {
                    float distanceSqr = (GetPosition() - GetPosition()).LengthSquared();
                    float rangeOfViewSqr = smallShipTarget.IsHiddenFromBots() ? MyAIConstants.BOT_FOV_RANGE_HIDDEN : MyAIConstants.BOT_FOV_RANGE;
                    float targetRange = Vector3.Dot(WorldMatrix.Forward, target.GetPosition() - GetPosition());

                    canSeeTarget =
                        targetRange <= rangeOfViewSqr &&
                        Vector3.Dot(WorldMatrix.Forward, Vector3.Normalize(target.GetPosition() - GetPosition())) >= MyAIConstants.BOT_FOV_COS;
                }
            }
            return canSeeTarget;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:19,代码来源:MySmallShipBot.cs

示例8: AddSeenEnemy

        public void AddSeenEnemy(MyEntity enemy)
        {
            if (enemy != null)
            {
                Debug.Assert(!enemy.Closed);

                if (LeaderLostEnabled && Leader != null && Vector3.DistanceSquared(Leader.GetPosition(), enemy.GetPosition()) > MyAIConstants.FAR_LEADER_DISTANCE_SQR)
                    return;

                MyBotDesire desire = null;
                foreach (var item in m_desires)
                {
                    if (item.DesireType == BotDesireType.SEE_ENEMY && item.GetEnemy() == enemy)
                    {
                        desire = item;
                        break;
                    }
                }

                if (desire == null)
                {
                    desire = new MySeeEnemyDesire(enemy);
                    AddDesire(desire);
                }
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:26,代码来源:MySmallShipBot.cs

示例9: DoDamageInternal


//.........这里部分代码省略.........
                return;
            }


            if (isPlayerShip && (MyGuiScreenGamePlay.Static.IsCheatEnabled(MyGameplayCheatsEnum.PLAYER_SHIP_INDESTRUCTIBLE)))
            {
                damage = empDamage = 0;
            }

            if (MyFakes.TEST_MISSION_GAMEPLAY && (damage != 10000 || damageType != MyDamageType.Explosion))
            {
                damage = empDamage = healthDamage = 0;
            }

            if (isPlayerShip)
            {
                if (damageType != MyDamageType.Unknown)
                {
                    damage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerMultiplicator;
                }
            }

            //how much armor absorbs damage (0.0 no absorbtion, 1.0 full absorbtion)
            float armorReduction = m_armorProperties.HasValue ? m_armorProperties.Value.Resistance : 0;

            if (ammoType == MyAmmoType.Piercing)
            {
                armorReduction *= MyAmmoConstants.ArmorEffectivityVsPiercingAmmo; // Armor effectivity is lower against piercing ammo
            }

            //actual damage armor absorbed
            float armorDamage = Math.Min(ArmorHealth, damage);

            //update armor health value
            ArmorHealth -= armorDamage;

            //calculate actual damage to the ship (decrease it by the absorbed damage by armor)
            float shipDamage = damage - armorDamage * armorReduction;


            if (this == MySession.PlayerShip)
            {
                if (MySession.Static.Player.Medicines[(int)MyMedicineType.HEALTH_ENHANCING_MEDICINE].IsActive())
                    healthDamage *= MyMedicineConstants.HEALTH_ENHANCING_MEDICINE_DAMAGE_MULTIPLIER;

                if (damageType == MyDamageType.Radioactivity || damageType == MyDamageType.Sunwind)
                {
                    // activate if not active
                    if (!MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].IsActive())
                    {
                        MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].ActivateIfInInventory(Inventory);
                    }
                    // if active, modify health damage
                    if (MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].IsActive())
                    {
                        healthDamage *= MyMedicineConstants.ANTIRADIATION_MEDICINE_RADIATION_DAMAGE_MULTIPLIER;
                    }
                }

                if (damageSource == null || (damageSource != this && MyFactions.GetFactionsRelation(damageSource, this) == MyFactionRelationEnum.Enemy))
                {
                    healthDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                    shipDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                    empDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                }

                if (MySession.Static != null)
                {
                    if (!MySession.Static.Player.IsDead())
                    {
                        MySession.Static.Player.AddHealth(-healthDamage, damageSource);
                    }
                }

                if (damageType == MyDamageType.Radioactivity || damageType == MyDamageType.Sunwind)
                {
                    m_radiationLastDamage = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                    //PlayGeigerBeeping();
                    if (healthDamage >= MySmallShipConstants.WARNING_RADIATION_DAMAGE_PER_SECOND * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS)
                    {
                        m_radiationCriticalLastDamage = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                        //PlayRadiationWarning();
                    }
                }
            }

            DisableByEMP(TimeSpan.FromSeconds(MySmallShipConstants.EMP_SMALLSHIP_DISABLE_DURATION_MULTIPLIER * empDamage));

            if (isPlayerShip)
            {
                if (damageSource != null)
                {
                    MyHud.SetDamageIndicator(damageSource, damageSource.GetPosition(), shipDamage);
                }
            }

            base.DoDamageInternal(healthDamage, shipDamage, empDamage, damageType, ammoType, damageSource, justDeactivate);

            UpdateDamageEffect();
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:101,代码来源:MySmallShip.cs

示例10: CanSee

 public MyEntity CanSee(MyEntity target)
 {
     return MyEnemyTargeting.CanSee(this, target.GetPosition(), target);
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:4,代码来源:MySmallShip.cs

示例11: MoveMotherShipForwardDest

        bool MoveMotherShipForwardDest(MyEntity entity, Vector3 velocity, Vector3 destination)
        {
            if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
            {
                MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);

                return false;
            }
            return true;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MySlaverBaseMission.cs

示例12: MoveAndRotateObject

        /// <summary>
        /// Moves and Rotates entity
        /// </summary>
        /// <param name="newPosition"></param>
        /// <param name="newOrientation"></param>
        /// <param name="entity"></param>
        public static void MoveAndRotateObject(Vector3 newPosition, Matrix newOrientation, MyEntity entity)
        {
            BoundingSphere sphere = new BoundingSphere(newPosition + entity.LocalVolumeOffset, entity.WorldVolume.Radius);

            if (MyMwcSectorConstants.SECTOR_SIZE_FOR_PHYS_OBJECTS_BOUNDING_BOX.Contains(sphere) == MinerWarsMath.ContainmentType.Contains)
            {
                Matrix entityBeforeMoveOrientation = entity.GetWorldRotation();
                Vector3 entityBeforeMovePosition = entity.GetPosition();

                if (entityBeforeMovePosition != newPosition || entityBeforeMoveOrientation != newOrientation)
                {
                    // Move object
                    bool moveSuccesfull = entity.MoveAndRotate(newPosition, newOrientation);
                    Vector3 currentPosition = entity.GetPosition();
                    Matrix currentOrientation = entity.GetWorldRotation();

                    if (moveSuccesfull)
                    {
                        //entity.UpdateWorldMatrix();
                        //  Play movement or rotation sounds
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if (entityBeforeMovePosition != currentPosition)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveStep);
                            }

                            if (entityBeforeMoveOrientation != currentOrientation)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectRotateStep);
                            }

                            m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyEditorConstants.DELAY_OBJECT_MOVEMENT_SOUND_IN_MILLIS;
                        }

                        MyEditor.Static.RecheckAllColidingEntitesAndClearNonColiding();//check all coliding entites to see if any went out of collision state
                        
                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("CheckAllCollidingObjectsForEntity");

                        // This was taking up to 170ms for 800 prefabs, so its replaced by void CheckCollisions(IEnumerable<MyEntity> entities) in HandleInput().
                        //MyEditor.Static.CheckAllCollidingObjectsForEntity(entity);//check all colliding state of entity after move

                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); 
                    }
                    else
                    {
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if ((entityBeforeMovePosition != currentPosition) || (entityBeforeMoveOrientation != currentOrientation))
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveInvalid);
                                m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + 1000;
                            }
                        }
                    }

                }
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:65,代码来源:MyEditorGizmo.cs

示例13: GetRotationAndPosition

        /// <summary>
        /// This method calculates new object position when its being rotated - in case only one object is selected and rotated
        /// only rotation is changed, but for multiple selected object, rotation is calculated based on the objects selected center
        /// </summary>
        static void GetRotationAndPosition(MyEntity entity, Matrix rotation, out Vector3 newPosition, out Matrix newRotation)
        {
            Matrix entityOrientation = entity.GetWorldRotation();
            Vector3 entityPosition = entity.GetPosition();
            Vector3 gizmoPosition = Position;

            if (ActivePivot == PivotType.OBJECT_CENTER)
            {
                //gizmoPosition = entityPosition;
            }

            Matrix localRot = Matrix.Identity;
            localRot.Forward = entityOrientation.Forward;
            localRot.Up = entityOrientation.Up;
            localRot.Right = entityOrientation.Right;
            m_localRight = MyMwcUtils.Normalize(m_localRight);
            localRot.Translation = entityPosition - gizmoPosition;

            Matrix rot = localRot * rotation;
            newPosition = rot.Translation + gizmoPosition;
            entityOrientation.Forward = rot.Forward;
            entityOrientation.Up = rot.Up;
            entityOrientation.Right = rot.Right;
            entityOrientation.Translation = Vector3.Zero;
            newRotation = entityOrientation;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:30,代码来源:MyEditorGizmo.cs

示例14: MoveMotherShipForward

 void MoveMotherShipForward(MyEntity entity, float speed)
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:5,代码来源:MyChineseTransportMission.cs

示例15: IsRenderingInsideEntity

        public static bool IsRenderingInsideEntity(MyEntity entity)
        {
            if (entity == MySession.PlayerShip)
            {
                var isMainRenderInsidePlayerShip = Static.CameraAttachedTo ==
                                                   MyCameraAttachedToEnum.PlayerMinerShip &&
                                                   !MySecondaryCamera.Instance.IsCurrentlyRendering;

                var isSecondaryRenderInsidePlayerShip = MySecondaryCamera.Instance.IsInsidePlayerShip &&
                                                        MySecondaryCamera.Instance.IsCurrentlyRendering;

                return isMainRenderInsidePlayerShip || isSecondaryRenderInsidePlayerShip;
            }

            var squaredDistanceToCamera = Vector3.DistanceSquared(entity.GetPosition(), MyCamera.Position);

            var closeEnoughToCamera = squaredDistanceToCamera < 0.0001f;

            return closeEnoughToCamera;
        }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:20,代码来源:MyGuiScreenGamePlay.cs


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