- Unreal Development Kit Game Programming with UnrealScript:Beginner's Guide
- Rachel Cordone
- 233字
- 2021-08-27 11:59:11
Time for action – Examining inheritance
- We can see an example of this by taking a look at the class tree in UnCodeX, under Actor | Inventory | Weapon | UDKWeapon. Expanding UTWeapon we can see the different types of weapons provided as examples in the UDK:
We can see that
UTBeamWeapon
(like the plasma gun we start with when running the game),UTWeap_RocketLauncher
, andUTWeap_ShockRifleBase
are amongst our weaponry. Each of these behaves differently, but all of them have common functionality. - Clicking on
UTWeapon
, we can see some of its variables./** Initial ammo count if in weapon locker */ var int LockerAmmoCount; /** Max ammo count */ var int MaxAmmoCount; /** Holds the amount of ammo used for a given shot */ var array<int> ShotCost;
What just happened?
Things like MaxAmmoCount
and ShotCost
are common to all of the weapons, so instead of having to duplicate the variables to all of the subclasses, they're declared in all of the weapons' parent class, UTWeapon
. Indeed, if we look at UTWeapon
's subclasses like UTWeap_RocketLauncher
, we won't find MaxAmmoCount
or any of UTWeapon
's other variables declared in any of them.
Speaking of weapons, I think it's time we started having a little fun with our code. AwesomeActor has been good to us so far, but he doesn't really do a lot besides sit there and send out log messages. Let's make a weapon.
- Learning AngularJS Animations
- Android NDK Game Development Cookbook
- Effective STL中文版:50條有效使用STL的經驗(雙色)
- 微服務分布式架構基礎與實戰:基于Spring Boot + Spring Cloud
- 分布式系統與一致性
- 微軟互聯網信息服務(IIS)最佳實踐 (微軟技術開發者叢書)
- Istio服務網格技術解析與實踐
- 單片微機原理及應用
- FreeSWITCH Cookbook
- Spring Security 3.x Cookbook
- Mastering Quantum Computing with IBM QX
- USB應用開發寶典
- 筆記本電腦維修技能實訓
- Learning Less.js
- The Reinforcement Learning Workshop