调整和改编赛车游戏——更多的想法

更多的想法

游戏现在已经运行得很好了,如果你已通过最终的测试它就可以发布了。但即使您可能还没有全部完成,你也可能要尝试更多的想法或思考未来的扩展。我发现自己经常重用现有的引擎来测试新的游戏构思。使用您已经熟悉的现有引擎比从头开始更容易。

本节的内容是关于我在游戏开发时甚至在开发前的一些额外构思。

更多汽车

有更多的车辆模型是我的愿望之一,但由于我不是一个模型设计师,也没有我认识的模型设计师有很多时间为我的小赛车游戏创建一些车辆模型,我只有几个专为赛车游戏制作的三维汽车模型。通过改变汽车的纹理改变汽车的外观相对容易,starter kit中有三个不同的汽车纹理,还有一些代码能动态地改变汽车的颜色,但它们都使用相同的基本几何体。

本章最后展示的改编版本Speedy Racer Game,有另一个汽车模型(从互联网上下载的免费版本),但有不同类型的汽车将使游戏更有趣,尤其是每辆汽车都有不同的速度,加速度,刹车等参数。对于多人游戏,有不同的汽车会更有趣,使每个玩家都可以选择自己最喜欢的汽车类型。

但是,在第12章中你看到商业赛车游戏有很多汽车会耗费了大量的金钱来开发,同时也要花很长时间让这些车表现优秀。希望社会中能找到办法导入新的车型,一段时间后会有足够多的游戏改编版本,从这些改编版本中找到汽车模型去制作更好的改编版本。

渲染汽车的非常具体,例如,Model类中使用专有的RenderCar方法只用来渲染汽车。如果你有一个以上的车型将很难更新这个方法,或许实现通用的Render方法会更好。

在线排行榜

实现对Web服务的调用并从那获得前10名在线排行榜可能问题不大。你可以在Highscore类中添加这些代码,你可以重用Rocket Commander的大多数现有代码。

在您可以使用网络服务前您必须添加System.Web.Services引用,这只适用于Windows平台。你要添加到Highscore类的所有网络服务代码必须在Xbox 360平台上被禁用。

Highscore[] onlineHighscores = new Highscore[10];
Thread onlineGetHighscoreThread = null;

/// <summary>
/// Get online highscores
/// </summary>
/// <param name="onlyThisHour">Only this hour</param>
private void GetOnlineHighscores(bool onlyThisHour)
{
  // Clear all online highscores and wait for a new update!
  for (int num = 0; num < onlineHighscores.Length; num++)
  {
    onlineHighscores[num].name = "-";
    onlineHighscores[num].level = "";
    onlineHighscores[num].points = 0;
  } // for (num)
  // Stop any old threads
  if (onlineGetHighscoreThread != null)
    onlineGetHighscoreThread.Abort();

  // Ask web service for highscore list! Do this asyncronly,
  // it could take a while and we don't want to wait for it to complete.
  onlineGetHighscoreThread = new Thread(new ThreadStart(
    // Anoymous delegates, isn't .NET 2.0 great? ^^
    delegate
    {
      // See notes above
      try
      {
        string ret = new www.xnaracinggame.com.
          RacingGameService().GetTop10Highscores(onlyThisHour);
        // Now split this up and build the online highscore with it.
        string[] allHighscores = ret.Split(new char[] { ',' });
        for (int num = 0; num < allHighscores.Length &&
          num < onlineHighscores.Length; num++)
          {
          string[] oneHighscore =
            allHighscores[num].Split(new char[] { ':' });
          onlineHighscores[num] = new Highscore(
            oneHighscore[0].Trim(), oneHighscore[2],
            Convert.ToInt32(oneHighscore[1]));
        } // for (num)
      } // try
  catch { } // ignore any exceptions!
    }));

  onlineGetHighscoreThread.Start();
} // GetOnlineHighscores(onlyThisHour)

为了此代码正常工作您需要在RacingGameService类的指定位置运行一个网络服务编写网络服务本身不难,但实现一个漂亮的网站将数据显示给访问者要做大量的工作。也许这项工作会在以后进行。

更多Shader和特效

在游戏中包含更多的shader和特效始终是一件好事,至少从玩家的角度看,因为游戏看上去更酷,与几年前的游戏有更多不同,那时许多游戏采用类似的渲染技术,看上去都很类似。

你可以很容易插入的一个shader是来自与Rocket Commander的视差映射,但要使用视差映射代替标准的法线映射,你需要在材质上应用高程图。

但是,添加类似于XNA Shooeter游戏的特效和特效系统也很不错(见图14-19)。您目前没有特效用于汽车爆炸或撞上东西。

14-19
图 14-19

欲了解更多post screen shader的例子可回到第8章看一下。赛车游戏将极大地受益于HDR渲染,特别是如果你改变光照情况并驱车通过隧道时。

第8章讨论过的每像素运动模糊效果也比目前的全屏post screen 效果更好,但显然也难得多。

我一直在改进赛车游戏改编版本过程中做的主要一件事就是改变PostScreenMenu和PostScreenGlow类的颜色校正因素和基本着色代码。无需改变所有的纹理就能使整场游戏有一个截然不同的表现。

更多的游戏模式

更多的游戏模式也很有趣。我不是一个真正的赛车游戏专家,但实现一个或多个通用的游戏模式也许是有趣的,您能经常在商业赛车游戏中发现不同的游戏模式:

  • 挑战最好成绩:这是这个游戏目前的模式。它也可以扩展到更多的玩家,你需要添加一些人工智能赛车作为对手。

  • 争先模式:对于这个游戏模式你显然需要一辆以上的汽车和一个以上的驾驶员。这是大多数赛车游戏的主要游戏模式。目前这是不可能的,因为你没有多人模式,也没有代码处理其他车辆。即使有一些人工智能代码您仍需改进车辆的碰撞代码,因为现在你会和赛道上的其他车辆发生碰撞。

  • 实践模式:一些赛车游戏的特殊模式,在进入竞争前让您熟悉赛道。您可以训练技能和试驾赛道的某些部分,但这个游戏模式只有在你在竞争模式中失败是才有意义,这并不是游戏的主要部分。

  • 时间轨迹:您必须在规定时限内完成赛道或某些地区。这对于初学者来说更难,因为比起只是完成赛道和挑战最高分,挑战时间难得多。

  • 绕障碍模式或驾驶课模式:你必须在规定时限绕过放置在路上的路障并尽量避免撞翻它们。还可能是在道路的规定一侧或按道路指示行驶。

  • 技巧模式:这是一个更受欢迎的游戏模式,特别是在街道赛车游戏中。玩技巧意味着你要漂移你的车,通过曲线下滑,甚至跳过赛道的某些部分。如赛道狂飙之类的游戏中你必须完成其他种类的技巧。您要完成环形轨道,但赛道狂飙中大多数高级模式部分会使它更加难以完成。

  • 碰撞模式:有些游戏把重点放在撞毁汽车和尽可能快的破坏您的车上。乍一听很有趣,但我在进一步深入了解前就放弃了这种游戏。

  • 给汽车添加武器,或者至少添加有特殊功能的道具。许多街机赛车游戏实现了这个想法,有许多不同的游戏模式都来自与这一想法。在多人游戏中这个想法很不错,每个人都互相争斗而道具可以帮助您摧毁你的敌人或把他们推到一边让您领先。这种游戏模式最典型的例子是马里奥赛车,Wacky Wheels、Micro Machine等。

  • 实现自己的构思或将现有的构思混合到赛车游戏中。你甚至可以把赛车部分完全去除并添加一些完全不同的东西。尽情发挥你的想象。

多人模式

如果你和一些朋友在局域网或在互联网上共同进行游戏,那么刚才讨论的游戏模式会变得有趣得多。由于Xbox 360不支持网络代码,多人模式只能工作在PC上。

在实现网络的基本代码后,主要的变化在Player中,要允许这个类的多个实例。您还需要处理玩家列表并在多人消息的帮助下更新每个玩家的数据。仅此一点就可以写一本书,因为多人游戏有许多议题,而且有许多方式能实现这些代码。

作为一个小例子,看一下图14-20,此图显示了一些多人网络类。游戏类保存玩家列表。每个玩家从其他玩家处接收消息并将所有接受到的消息添加在一个内部列表中。而通过Message类和MessageType枚举加载消息。

14-20
图 14-20

转载于:https://www.cnblogs.com/AlexCheng/archive/2010/10/17/2120183.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vehicle physics package suitable for wide range of vehicles. Realistic, easy to use and heavily customizable. Wheel Controller 3D, a custom in-house wheel solution, has been used for wheel physics while the rest of the system had been written from the ground up. General features: • Fast vehicle setup with quick start video or included manual. • Seven vehicle prefabs of different types are included: sports car, sedan, 8x8 truck, monster truck, tank, city bus and semi with trailer. • Suitable for wide range of applications. • Runs on both desktop and mobile devices. • Uses custom in-house wheel solution – Wheel Controller 3D – for 3D ground detection and high level of customizability. • Per-wheel surface detection based on terrain textures or object tags. Different friction curves and effects for each surface. • Suspend option for inactive vehicles which minimizes impact on performance while keeping basic functionality. • Character vehicle changer that works with any character controller / game object, including other vehicles. • Helper scripts such as analog and digital gauge controllers, camera and vehicle changers, center of mass and downforce adjusters, etc. Vehicle Physics Details: Engine • Realistic engine power and torque calculation with adjustable power curve and RPM range. • Functional forced induction. Transmission • Gear ratios and final gear ratio. • Dynamic shift point based on load. • Three transmission types: Automatic, Automatic Sequential and Manual. • Manual transmission supports both sequential and H-pattern shifting. • Center differential: Open, Limited Slip, Locking or Equal. Axles • Geometry settings for each axle: Steering Angle, Pro/Anti Ackermann Steering, Toe, Camber, Caster and Anti-roll Bar. • Adjustable power, braking and handbrake distribution. • Per-axle differentials: Open, Limited Slip, Locking and Equal. • Supports solid axle (check Monster Truck in the demo). Damage • Optimized queue-based mesh deformation that spreads processing over multiple frames. • Damage influences vehicle performance and handling. Audio • All audio sources are set up automatically. • Sound can be adjusted through Audio Mixer for all vehicles or though inbuilt mixer for each vehicle and each effect individually. • Engine, forced induction, gear change, suspension, surface, skid, crash, air brake, horn and blinker sounds. Effects • Vehicle light system with low beam, high beam, stop and brake lights, blinkers. • Can be used with any number of lights of any type and/or emissive materials. • Persistent and well optimized mesh-based skidmarks. • Exhaust particle effects based on engine state. • Per-wheel dust and smoke particle effects based on surface the wheel is on. Input • Desktop input using standard input manager with mouse steering option. • Mobile input through on-screen steering wheel and pedals or tilt controls. Trailer • Trailer is a vehicle in itself meaning all the effects that work on a vehicle work on a trailer too. • Trailer gets input routed from the vehicle it is attached to which results in functional lights, braking, damage and even steering if needed. • Built-in attach / detach functionality where any vehicle can attach any trailer with correct tag. Fuel • Fuel consumption calculation using engine’s efficiency. • Readouts in l/100km, km/l and US mpg. UI • Universal analog and digital gauge controllers and lights for use in dashboard or HUD. Code • Modular code structure for easy modification and upgrading. • C# source code with XML comments on all public members. • Tooltip explanations for all visible variables. Compatible With Complete Terrain Shader and IK Driver Vehicle Controller European Truck and Trailer and Super Car models provided by GAME READY 3D MODELS . Try it out: Windows 64bit MacOS X 64bit Android (mobile scene) More info: Website Unity Forums YouTube Class Reference Changelog Note: Wheel Controller 3D is included with this asset and its price has been factored in. If you already own WC3D check the upgrade options. If you have any questions. problems or suggestions you can contact us at nwhcoding@gmail.com. Support is free and we always answer within a few hours.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值