SetMomentaryTurnToPosition() public method

public SetMomentaryTurnToPosition ( Vec3 pos ) : void
pos Vec3
return void
示例#1
0
        void UpdateTurnToPositionForUnits(Vec3 turnToPosition)
        {
            //Character
            Character character = ControlledObject as Character;

            if (character != null)
            {
                character.SetTurnToPosition(turnToPosition);
            }

            //Turret
            Turret turret = ControlledObject as Turret;

            if (turret != null)
            {
                turret.SetMomentaryTurnToPosition(turnToPosition);
            }

            //Tank
            Tank tank = ControlledObject as Tank;

            if (tank != null)
            {
                tank.SetNeedTurnToPosition(turnToPosition);
            }
        }
示例#2
0
        void TickTask()
        {
            ControlKeyRelease(GameControlKeys.Fire1);
            ControlKeyRelease(GameControlKeys.Fire2);

            if (targetTask != null)
            {
                Vec3 targetPos = targetTask.Position;

                Turret turret = ControlledObject as Turret;
                if (turret != null)
                {
                    //to consider speed of the target
                    if (turret.MainGun != null)
                    {
                        BulletType bulletType = turret.MainGun.Type.NormalMode.BulletType;
                        if (bulletType.Velocity != 0)
                        {
                            float flyTime = (targetPos - ControlledObject.Position).LengthFast() /
                                            bulletType.Velocity;

                            if (targetTask.PhysicsModel != null && targetTask.PhysicsModel.Bodies.Length != 0)
                            {
                                Body targetBody = targetTask.PhysicsModel.Bodies[0];
                                targetPos += targetBody.LinearVelocity * flyTime;
                            }
                        }
                    }

                    turret.SetMomentaryTurnToPosition(targetPos);
                }

                ControlKeyPress(GameControlKeys.Fire1, 1);
                ControlKeyPress(GameControlKeys.Fire2, 1);
            }
        }