Test Complete 11.3 License

霹雳蚕豆 2018-05-01 01:40:10
哪里可以找到TC 11.3的License, 找了好几圈了,一无所获,谢谢
...全文
912 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
Polycom RealPresence 桌面是一个易于使用的视频协作应用程序, 为 PC 用户提供高清质量的音频, 视频和内容共享。与类似的专有应用程序不同, RealPresence 桌面是基于标准的, 并扩展了组织现有的视频启用网络, 使最终用户能够在办公室内或在路上使用相同的高质量体验。 END USER LICENSE AGREEMENT FOR POLYCOM® SOFTWARE IMPORTANT-READ CAREFULLY BEFORE USING THE SOFTWARE: This End-User License Agreement ("Agreement") is a legal agreement between you and/or any company you represent, “you” and either Polycom (Netherlands) B.V. (if you are located in Europe, Middle East, or Africa), Polycom Asia Pacific PTE Ltd. (if you are located in Asia Pacific), or Polycom, Inc. (if you are located in the rest of the world) (each referred to individually and collectively herein as “POLYCOM”), for the SOFTWARE PRODUCT (as defined below) licensed by POLYCOM or its suppliers. Unless otherwise agreed in writing by POLYCOM, by accepting these terms or by installing, downloading, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be and will be bound by the terms of this Agreement as a condition of your license and the terms and conditions of this Agreement will prevail over any inconsistent, conflicting, additional or preprinted terms. If you do not agree to the terms of this Agreement, your use is prohibited and you may not install or use the SOFTWARE PRODUCT. The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed (not sold) to you, and its use is subject to the terms of this Agreement. This is NOT a sale contract. DEFINITIONS “SOFTWARE PRODUCT” means computer software, including any software updates or upgrades thereto, and associated media, printed materials, and "online" or electronic documentation identified on an AUTHORIZED PURCHASE ORDER. “CONCURRENT USER” is a type of license and means the number of personal devices, endpoints, applications or any other authorized means of access that may concurrently use or access the SOFTWARE PRODUCT or one or more of the RealPresence® Clariti™ SOFTWARE PRODUCT components. “DEVICE” means the POLYCOM hardware product with which the SOFTWARE PRODUCT is supplied or, if this SOFTWARE PRODUCT is delivered as software only, on a device (including but not limited to minimum hardware or software requirements) outlined in the SOFTWARE PRODUCT supporting documentation. “AUTHORIZED PURCHASE ORDER” means an ordering document describing the type, duration and number of SOFTWARE PRODUCT licenses ordered by you through, and accepted by, an AUTHORIZED SELLER. “AUTHORIZED SELLER” means POLYCOM or any of POLYCOM’s distributors, resellers or other business partners authorized to resell POLYCOM products. “LICENSE ACTIVATION” means the date you enter the license key provided to you by an AUTHORIZED SELLER. I. DEMONSTRATION/LABORATORY/DEVELOPER LICENSE If you have received the SOFTWARE PRODUCT for purposes of evaluation (“Demonstration”) or you have purchased a Laboratory or Developer License then this SOFTWARE PRODUCT is licensed to you per the terms set forth below. A.Demonstration License. License Grant. Subject to the terms of this Demonstration License, POLYCOM grants you a limited, non- exclusive, non-transferable license, to install and use, on a DEVICE, the number and type of SOFTWARE PRODUCT licenses listed in your AUTHORIZED PURCHASE ORDER solely to evaluate its suitability for your personal or internal business requirements. Demonstration Period. Your Demonstration License is limited to sixty (60) calendar days from LICENSE ACTIVATION (“DEMONSTRATION PERIOD”). Limited Use Software. Portions of the full-use version of the SOFTWARE PRODUCT may be restricted. Full use of the SOFTWARE PRODUCT may be provided when a Standard Use or Subscription license key is purchased. If you have entered data into the SOFTWARE PRODUCT during the DEMONSTRATION PERIOD and your DEMONSTRATION PERIOD ends, you may not have access to your data. POLYCOM accepts no liability for any lost data due to an expiring Demonstration License. 3725-50000-001B Release 3/17/2016 B.Laboratory and Developer License. License Grant. Subject to the terms of this Laboratory and Developer License, POLYCOM grants you a limited, non-exclusive, non-transferable license to install and use, on a DEVICE, the number and type of SOFTWARE PRODUCT licenses listed in your AUTHORIZED PURCHASE ORDER solely to use and test the SOFTWARE PRODUCT in a non-production, evaluation, and personal or internal business environment. Laboratory and Developer License Period. Your Laboratory and Developer License begins upon LICENSE ACTIVATION and ends after the duration listed in your AUTHORIZED PURCHASE ORDER (“LABORATORY AND DEVELOPER LICENSE PERIOD”). C.Disclaimer of Warranty. NOTWITHSTANDING ANYTHING TO THE CONTRARY IN THIS AGREEMENT, THE SOFTWARE PRODUCT IS PROVIDED ONLY FOR EVALUATION PURPOSES ON AN "AS IS" BASIS. POLYCOM EXPRESSLY DISCLAIMS ALL WARRANTIES, REPRESENTATIONS AND CONDITIONS INCLUDING THE IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. D.Additional Terms. The following additional terms of the Agreement shall also apply to this Demonstration/Laboratory/Developer License: Sections IV. 1 (Restrictions), IV. 2 (Other Rights and Limitations), IV. 4 (Term, Termination and Survival), IV. 7 (Limitation of Liability), IV. 8 (Indemnity), IV. 9 (Disclaimer), IV. 10 (Export Controls), and IV. 11 (Miscellaneous). II. SUBSCRIPTION/TERM LICENSE If you have purchased a Subscription License then this SOFTWARE PRODUCT is licensed to you per the terms set forth below. A. Grant of License. Subject to the terms of this Agreement, and during the SUBSCRIPTION PERIOD, POLYCOM grants to you a non-exclusive, non-transferable (except as set forth herein) license to install and use, on a DEVICE, for personal or internal business purposes the number and type of SOFTWARE PRODUCT licenses listed in your AUTHORIZED PURCHASE ORDER . B.RealPresence One™ Definitions. “BURST” means a limited duration license, listed in your AUTHORIZED PURCHASE ORDER , allowing you to temporarily increase the number of SOFTWARE PRODUCT CONCURRENT CONNECTIONS licensed by you in your purchase order. “CONCURRENT CONNECTION” means a single audio or video communication endpoint in a multipoint conference call. A CONCURRENT CONNECTION is either a Standard Connection or a Universal Connection as those are defined in the SOFTWARE PRODUCT solution documentation. POINT TO POINT calls are not considered CONCURRENT CONNECTIONS and do not require a separate license. “GUEST” means a third party conference call participant invited to a conference call by a USER and who does not fit the definition of USER. GUESTS may not create or manage meetings on behalf of your company. “POINT TO POINT CALLS” means any call made directly between no more than two users on compatible devices that does not utilize POLYCOM’s multipoint bridging technology. POINT TO POINT CALLS may not have all of the same features and capabilities of a call made using a CONCURRENT CONNECTION. “SUBSCRIPTION PERIOD” means the period of time you have licensed the SOFTWARE PRODUCT, beginning upon LICENSE ACTIVATION and ending after the duration listed in your AUTHORIZED PURCHASE ORDER. "USER" means one individual employee, consultant, contractor, agent or student or one video conferencing device not assigned to a unique individual, within your company or legally recognized entity that is authorized by you to directly or indirectly use the SOFTWARE PRODUCT and to whom you have assigned a unique SOFTWARE PRODUCT user identification and password. A USER license is for an individual or single video conferencing device USER only and cannot be shared or used by more than one individual or multiple video conferencing devices not assigned to a unique individual. USER licenses may be reassigned to new USERs. You are not required to purchase a USER license for GUESTS; however, GUESTS do consume a CONCURRENT CONNECTION license. 3725-50000-001B Release 3/17/2016 C. Additional Terms. Except for Section I & III, all of the terms of this Agreement shall also apply to this Subscription License. III. STANDARD USE/PERPETUAL LICENSE If you have purchased a Standard Use License then this SOFTWARE PRODUCT is licensed to you per the terms set forth below. A. Grant of License. Subject to the terms of this Agreement, POLYCOM grants to you a non-exclusive, non- transferable (except as set forth herein), perpetual (unless otherwise terminated per the terms of this Agreement) license to install and use, on a DEVICE, for personal or internal business purposes the number and type of SOFTWARE PRODUCT licenses listed in your AUTHORIZED PURCHASE ORDER. B. Additional Terms. Except for Sections I & II, all of the terms of this Agreement shall also apply to this Standard Use License. IV. ADDITIONAL TERMS AND CONDITIONS 1. Restrictions 1.1You may use the SOFTWARE PRODUCT pursuant to the license grant above and subject to the following terms and the proprietary notices in the SOFTWARE PRODUCT or on the media upon which the SOFTWARE PRODUCT is provided. You are not permitted to lease, rent, distribute, assign, sell or sublicense the SOFTWARE PRODUCT, in whole or in part, or to use the SOFTWARE PRODUCT in a time-sharing, subscription service, service bureau, hosting or outsourcing arrangement or in any other unauthorized manner. Further, no license is granted to you in the human readable code of the SOFTWARE PRODUCT (source code). Except as expressly provided below, this License Agreement does not grant you any rights to patents, copyrights, trade secrets, trademarks, or any other rights in the SOFTWARE PRODUCT. You are solely responsible for use of the SOFTWARE PRODUCT by your agents, contractors, outsourcers, customers and suppliers and their compliance with this Agreement. 1.2You may not reverse engineer, decompile, modify or disassemble the SOFTWARE PRODUCT or otherwise reduce the SOFTWARE PRODUCT to human-perceivable form in whole or in part, except and only to the extent that such activity is expressly permitted by a third party license or applicable laws (in any instance where the law permits any such action, you agree to provide POLYCOM at least ninety (90) days advance written notice of your belief that such action is warranted and permitted and to provide POLYCOM with an opportunity to evaluate if the law’s requirements necessitate such action). The foregoing includes but is not limited to review of data structures or similar materials produced by SOFTWARE PRODUCT. The SOFTWARE PRODUCT is licensed as a single product. Its component parts may not be separated for use on more than one DEVICE. You may not use the SOFTWARE PRODUCT for any illegal purpose or conduct. 1.3You may not modify, translate or create derivative works of the SOFTWARE PRODUCT. 1.4You may not remove or obscure any proprietary notices, identification, label or trademarks on or in the SOFTWARE PRODUCT or the supporting documentation. 2.Other Rights and Limitations 2.1Back-up. Except as expressly provided for under this Agreement you may not copy the SOFTWARE PRODUCT; except, however, during the term of this Agreement you may keep or POLYCOM may provide one copy of the SOFTWARE PRODUCT and, if applicable, one copy of any previous version, for back-up purposes, only to be used in the event of and during a failure of the original. All copies of the SOFTWARE PRODUCT must be marked with the proprietary notices provided on the original SOFTWARE PRODUCT. You may not reproduce the supporting documentation accompanying the SOFTWARE PRODUCT. 2.2Software Transfer. If you have purchased a Standard Use license, you may permanently transfer all of your rights under this Agreement, solely in connection with transfer of the DEVICE, if applicable, provided you retain no copies, you transfer all of the SOFTWARE PRODUCT (including the media and printed materials, any upgrades or updates, and this Agreement), and the recipient agrees to the terms of this Agreement. If the SOFTWARE PRODUCT is an upgrade or update, any transfer must include all prior versions of the SOFTWARE PRODUCT. However, if the SOFTWARE PRODUCT is marked "Not for Resale" or "NFR", you may not resell it or otherwise transfer it for value. 3725-50000-001B Release 3/17/2016 2.3Copyright. All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, photographs, animations, video, audio, music, text, programs and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by POLYCOM or its suppliers. Title, ownership rights, and intellectual property rights in the SOFTWARE PRODUCT shall remain in POLYCOM or its suppliers. Title and related rights in the content accessed through the SOFTWARE PRODUCT is the property of such content owner and may be protected by applicable law. This Agreement gives you no rights in such content. 2.4Confidentiality. The SOFTWARE PRODUCT contains valuable proprietary information and trade secrets of POLYCOM and its suppliers that remain the property of POLYCOM. You shall protect the confidentiality of, and avoid disclosure and unauthorized use of, the SOFTWARE PRODUCT. 2.5Information. Using the SOFTWARE PRODUCT means you consent to the SOFTWARE PRODUCT’s transmission of device information (including but not limited to technical information about your device such as logs, statistics, device states, and IP addresses) to POLYCOM and/or POLYCOM partners. POLYCOM may use such device information, along with all technical information you provide to POLYCOM as part of your use of SOFTWARE PRODUCT or SUPPORT SERVICES, for its business purposes in accordance with POLYCOM’s Privacy Policy located at http://www.polycom.com/company/privacy-policy.html. POLYCOM has no obligation to store your data or information and POLYCOM shall not be liable for any data loss. 2.6Dual-Media Software. You may receive the SOFTWARE PRODUCT in more than one medium. Regardless of the type or size of medium you receive, you may use only one medium that is appropriate for your DEVICE. You may not use or install the other medium on another DEVICE. 2.7Reservation of Rights. POLYCOM and its suppliers reserve all rights in the SOFTWARE PRODUCT not expressly granted to you in this Agreement. 2.8Additional Obligations. You are responsible for all equipment and any third party fees (such as carrier charges, internet fees, or provider or airtime charges) necessary to access the SOFTWARE PRODUCT. 2.9Installation. You acknowledge that installation of the SOFTWARE PRODUCT and, as applicable, use of additional software features may involve a license key that may restrict installation of the SOFTWARE PRODUCT to the SOFTWARE PRODUCT licensed. POLYCOM may also embed algorithms in the SOFTWARE PRODUCT that periodically compare the SOFTWARE PRODUCT licenses enabled against the SOFTWARE PRODUCT licensed. You further acknowledge that the SOFTWARE PRODUCT requires activation on initial installation of the SOFTWARE PRODUCT and future events including, but not limited to, updates and changes to your hardware on which the SOFTWARE PRODUCT is installed. You acknowledge that the license key and internal controls in the SOFTWARE PRODUCT may not restrict usage to the licensed amounts and do not ensure compliance with this Agreement. 3.Support Services POLYCOM may provide you with support services, including support services related to the provisioning and availability of SOFTWARE PRODUCT updates and upgrades, related to the SOFTWARE PRODUCT ("SUPPORT SERVICES"). Unless otherwise agreed in writing by POLYCOM, Use of SUPPORT SERVICES and any supplemental software code provided to you as part of the SUPPORT SERVICES is governed by the terms and conditions of POLYCOM's Worldwide Service Program for End User Customers and the applicable Service Description. 4. Term, Termination and Survival This Agreement is in effect from the date of download of the SOFTWARE PRODUCT through the period in the applicable license grant as set forth above. This Agreement will terminate automatically if you fail to comply with any of the terms and conditions of this Agreement. POLYCOM shall have the right to audit your use of the SOFTWARE PRODUCT in conjunction with this Agreement, and you will provide reasonable assistance for this purpose. In the event of any termination, you must cease use of the SOFTWARE PRODUCT, and destroy all copies of the SOFTWARE PRODUCT and all of its component parts. You may terminate this Agreement at any time by destroying the SOFTWARE PRODUCT and all of its component parts. Termination of this Agreement shall not prevent POLYCOM or its suppliers from claiming any further damages. If you do not comply with any of the above restrictions, this license will terminate and you will be liable to POLYCOM and its suppliers for damages or losses 3725-50000-001B Release 3/17/2016 caused by your non-compliance. The waiver by POLYCOM of a specific breach or default shall not constitute the waiver of any subsequent breach or default. The following provisions shall survive the expiration or termination of this Agreement: Sections IV.1 (Restrictions), IV.2 (Other Rights and Limitations), IV.5 (Term, Termination and Survival), IV.7 (Limitation of Liability), IV.8 (Indemnity), IV.9 (Disclaimer), IV.10 (Export Controls), and IV.11 (Miscellaneous). 5. Upgrades If the SOFTWARE PRODUCT is labeled as an upgrade or update, you must be properly licensed to use the software identified by POLYCOM as being eligible for the upgrade or update in order to use the SOFTWARE PRODUCT. A SOFTWARE PRODUCT labeled as an upgrade or update replaces and/or supplements the software that formed the basis for your eligibility for the upgrade or update. You may use the resulting upgraded/updated SOFTWARE PRODUCT only in accordance with the terms of this Agreement. If the SOFTWARE PRODUCT is an upgrade or update of a component of a package of software programs that you licensed as a single product, the SOFTWARE PRODUCT may be used and transferred only as part of that single SOFTWARE PRODUCT package and may not be separated for use on more than one DEVICE. 6. Warranty and Warranty Exclusions 6.1Limited Warranty. Except as otherwise set forth in a Third Party License or in third party license terms set forth below, POLYCOM warrants that (a) the SOFTWARE PRODUCT will perform substantially in accordance with the accompanying documentation for a period of ninety (90) days from the date of shipment by POLYCOM or the SOFTWARE PRODUCT is initially downloaded by you, as applicable, and (b) any SUPPORT SERVICES provided by POLYCOM shall be substantially as described in applicable written materials provided to you by POLYCOM. This warranty is valid only for the original purchaser. POLYCOM DOES NOT WARRANT THAT YOUR USE OF THE SOFTWARE PRODUCT WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT ALL DEFECTS IN THE SOFTWARE PRODUCT WILL BE CORRECTED. YOU ASSUME FULL RESPONSIBILITY FOR THE SELECTION OF THE SOFTWARE PRODUCT TO ACHIEVE YOUR INTENDED RESULTS AND FOR THE INSTALLATION, USE AND RESULTS OBTAINED FROM THE SOFTWARE PRODUCT. IF THE SOFTWARE PRODUCT DOES NOT OPERATE AS WARRANTED ABOVE, POLYCOM'S SOLE OBLIGATION UNDER THIS EXPRESS WARRANTY SHALL BE, AT POLYCOM'S OPTION AND EXPENSE, TO REPAIR OR REPLACE THE DEFECTIVE SOFTWARE, OR IF NEITHER OF THE TWO FOREGOING OPTIONS IS REASONABLY AVAILABLE, POLYCOM MAY, IN ITS SOLE DISCRETION REFUND TO YOU THE PURCHASE PRICE PAID FOR THE DEFECTIVE PRODUCT. Any replacement SOFTWARE PRODUCT will substantially conform to the accompanying documentation and be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer. 6.2Warranties Exclusive. TO THE FULL EXTENT ALLOWED BY LAW, THE FOREGOING WARRANTIES AND REMEDIES ARE EXCLUSIVE AND ARE IN LIEU OF ALL OTHER WARRANTIES, TERMS, OR CONDITIONS, EXPRESS OR IMPLIED, EITHER IN FACT OR BY OPERATION OF LAW, STATUTORY OR OTHERWISE, INCLUDING WARRANTIES, TERMS, OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, SATISFACTORY QUALITY, CORRESPONDENCE WITH DESCRIPTION, AND NON- INFRINGEMENT, ALL OF WHICH ARE EXPRESSLY DISCLAIMED. POLYCOM NEITHER ASSUMES NOR AUTHORIZES ANY OTHER PERSON TO ASSUME FOR IT ANY OTHER LIABILITY IN CONNECTION WITH THE SALE, INSTALLATION, MAINTENANCE OR USE OF THE SOFTWARE PRODUCT. NO ADVICE OR INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM POLYCOM OR THROUGH OR FROM THE SOFTWARE PRODUCT SHALL CREATE ANY WARRANTY NOT EXPRESSLY STATED IN THIS AGREEMENT. NEITHER POLYCOM NOR ITS SUPPLIERS SHALL BE LIABLE UNDER THIS WARRANTY IF ITS TESTING AND EXAMINATION DISCLOSE THAT THE ALLEGED DEFECT OR MALFUNCTION IN THE SOFTWARE PRODUCT DOES NOT EXIST OR WAS CAUSED BY YOUR OR ANY THIRD PARTY'S MISUSE, NEGLECT, IMPROPER INSTALLATION OR TESTING, UNAUTHORIZED ATTEMPTS TO MODIFY THE SOFTWARE PRODUCT, OR ANY OTHER CAUSE BEYOND THE RANGE OF THE INTENDED USE, OR BY ACCIDENT, FIRE, LIGHTNING, POWER CUTS OR OUTAGES, OTHER HAZARDS, OR ACTS OF GOD. 7. Limitation of Liability YOUR USE OF THE SOFTWARE PRODUCT IS AT YOUR SOLE RISK. YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR LOSS OF DATA THAT RESULTS FROM THE DOWNLOAD OR USE OF THE SOFTWARE PRODUCT. TO THE MAXIMUM EXTENT PERMITTED BY 3725-50000-001B Release 3/17/2016 APPLICABLE LAW, IN NO EVENT SHALL POLYCOM OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION DAMAGES FOR LOSS OF BUSINESS PROFITS OR REVENUE; BUSINESS INTERRUPTION OR WORK STOPPAGE; COMPUTER FAILURE OR MALFUNCTION; LOSS OF BUSINESS INFORMATION, DATA OR DATA USE; LOSS OF GOODWILL; OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE PRODUCT OR THE PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF POLYCOM OR ITS SUPPLIER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL POLYCOM’S SUPPLIERS BE LIABLE FOR ANY DIRECT DAMAGES WHATSOEVER ARISING OUT OF THE USE OR THE INABILITY TO USE THE SOFTWARE PRODUCT. IN ANY CASE, POLYCOM'S ENTIRE LIABILITY SHALL BE LIMITED TO THE GREATER OF THE AMOUNT ACTUALLY PAID BY YOU FOR THE SOFTWARE PRODUCT OR U.S. $1.00. NOTWITHSTANDING THE TERMS OF THIS SECTION 7, IF YOU HAVE ENTERED INTO A POLYCOM SUPPORT SERVICES AGREEMENT, POLYCOM'S ENTIRE LIABILITY REGARDING SUPPORT SERVICES SHALL BE GOVERNED BY THE TERMS OF THAT AGREEMENT. 8. Indemnity You agree to indemnify and hold harmless POLYCOM and its subsidiaries, affiliates, officers, agents, co-branders,customers, suppliers or other partners, and employees, from any loss, claim or demand, including reasonable attorneys' fees, made by any third party due to or arising out of your use of the SOFTWARE PRODUCT, your connection to the SOFTWARE PRODUCT, or your violation of the Terms. 9. Disclaimers 9.1Local Laws. Some countries, states, or provinces do not allow the exclusion or limitation of implied warranties or the limitation of incidental or consequential damages for certain products supplied to consumers, or the limitation of liability for death or personal injury, so the above limitations and exclusions may be limited in their application to you. When the implied warranties are not allowed to be excluded in their entirety due to local law, they will be limited to the duration of the applicable warranty. 9.2Quality. POLYCOM cannot guarantee that the SOFTWARE PRODUCT will always function without disruptions, delay or errors. A number of factors may impact the quality of your communications and use of the SOFTWARE PRODUCT, and may result in the failure of your communications including but not limited to: your local network, firewall, your internet service provider, the public internet, the public switched telephone network and your power supply. POLYCOM takes no responsibility for any disruption, interruption or delay caused by any failure of or inadequacy in any of these items or any other items over which we have no control. 9.3High Risk Use. The SOFTWARE PRODUCT is not fault-tolerant and is not designed or intended for use in hazardous environments requiring fail-safe performance or any application in which the failure of the SOFTWARE PRODUCT could lead directly to death, personal injury, or severe physical or property damage (collectively, "High Risk Use"). Because the SOFTWARE PRODUCT is not guaranteed to function without disruptions, delay or errors (see section 9.2, above), the SOFTWARE PRODUCT should never be utilized as the sole means of communication in High Risk Use. You assume full responsibility for the selection of the SOFTWARE PRODUCT for High Risk Use. POLYCOM AND ITS SUPPLIERS EXPRESSLY DISCLAIM ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK USE. 10. Export Controls You acknowledge that the SOFTWARE PRODUCT may be subject to export and/or import laws and regulations of various countries, including but not limited to the US Export Administration Regulations, restricting the download, transfer, reexport, sale and import of the SOFTWARE PRODUCT to certain countries and persons. You further acknowledge that the SOFTWARE PRODUCT may include encryption/decryption features subject to licensing restrictions under US and other applicable laws for export, re-export, import or in-country transfer. You shall fully comply with all applicable export license restrictions and requirements as well as with all laws and regulations relating to the importation of the SOFTWARE PRODUCT, in the United States and in any foreign jurisdiction into which the SOFTWARE PRODUCT is downloaded or used. Without limiting the foregoing, the SOFTWARE PRODUCT may not be downloaded or otherwise exported or re-exported (i) into (or to a national or resident of, other than a national lawfully admitted for permanent residence in third-countries) Cuba, Iran, North Korea, Sudan, Syria or any other country against which the U.S. maintains comprehensive country-wide sanctions from time to time; (ii) any end user known, or having reason to be known, will utilize them in the design, development or production of nuclear, chemical or biological weapons; or (iii) to any restricted party identified on the U.S. Treasury Department's list of Specially Designated Nationals, the U.S. Commerce Department's Denied Persons List, Entity 3725-50000-001B Release 3/17/2016 List or Unverified List as in force from time to time (see: http://www.bis.doc.gov/complianceandenforcement/liststocheck.htm). By downloading or using the SOFTWARE PRODUCT, you are agreeing to the foregoing and you are representing and warranting that you are not located in, under the control of, acting on behalf of, or a national or resident of any such country or on any such list. If you obtained this SOFTWARE PRODUCT outside of the United States, you are also agreeing that you will not export or re-export it in violation of the laws of the country in which it was obtained including but not limited to export and sanctions laws. 11. Miscellaneous 11.1Governing Law. This Agreement shall be governed by the laws of the State of California, without reference to conflict of laws principles and any disputes will be subject to the exclusive jurisdiction of the Superior Court of Santa Clara County and/or the United States District Court for the Northern District of California. The losing party in any dispute will pay all court costs and legal fees finally awarded. . The United Nations Convention on Contracts for the International Sale of Goods (1980) and the Uniform Computer Information Transactions Act (UCITA) are hereby excluded in their entirety from application to this Agreement. 11.2Entire Agreement. This Agreement represents the complete agreement concerning the SOFTWARE PRODUCT and may be amended only by a writing executed by both parties. If any provision of this Agreement is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 11.3Contact. If you have any questions concerning this Agreement, or if you desire to contact POLYCOM for any reason, please contact the POLYCOM office serving your country. 11.4U.S. Government Restricted Rights. The software and documentation provided by POLYCOM pursuant to this Agreement are “Commercial Items,” as the term is defined at 48 C.F.R. §2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1through 227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are licensed to United States Government end users (1) only as Commercial Items and (2) with only those rights as are granted to all other users pursuant to the terms of this Agreement. 11.5Third Party Software. The SOFTWARE PRODUCT may be distributed with software governed by licenses from third parties (“Third Party Software” and “Third Party License”). Any Third Party Software is licensed to you subject to the terms and conditions of this Agreement, notwithstanding anything to the contrary in this Agreement, the corresponding Third Party License. More information on Third Party Licenses terms applicable to the SOFTWARE PRODUCT can be found in the documentation for each SOFTWARE PRODUCT and at http://documents.polycom.com/indexes/licenses. POLYCOM makes no separate representation or warranty concerning Third Party Software and shall have no obligation or liability with respect to Third Party Software. If the Third Party Licenses include licenses that provide for the availability of source code and the corresponding source code is not included with the SOFTWARE PRODUCT, then check the documentation supplied with each SOFTWARE PRODUCT to learn how to obtain such source code. 11.6Translations. This Agreement may have been translated into various languages for the convenience of POLYCOM’s customers. While the translation is correct to the best of POLYCOM’s knowledge, POLYCOM is not responsible or liable in the event of an inaccuracy. English is the controlling language of this Agreement, and any translation has been prepared for you as a courtesy only. In the event of a conflict between the English-languageversion of this Agreement and a version that has been translated into another language, the English-languageversion of this Agreement shall control. 11.7Application Programming Interfaces (API). To the extent the SOFTWARE PRODUCT includes APIs, you agree that your access and use of the APIs will be governed by the terms of the current “Application Programming Interfaces License Agreement” located at www.support.polycom.com. BY INSTALLING, COPYING, OR OTHERWISE USING THIS SOFTWARE PRODUCT YOU ACKNOWLEDGE THAT YOU HAVE READ, UNDERSTAND AND AGREE TO BE BOUND BY THESE TERMS AND CONDITIONS. Polycom, Inc. © 2015. ALL RIGHTS RESERVED. 6001 America Center Drive San Jose, CA 95002 U.S.A. 3725-50000-001B Release 3/17/2016
Acknowledgments xiii Introduction xv 1. Making Games the Modular Way 1 1.1 Important Programming Concepts.....................................2 1.1.1 Manager and Controller Scripts...............................2 1.1.2 Script Communication.......................................3 1.1.3 Using the Singleton Pattern in Unity...........................5 1.1.4 Inheritance.................................................6 1.1.5 Where to Now?.............................................8 2. Building the Core Game Framework 9 2.1 Controllers and Managers............................................11 2.1.1 Controllers................................................11 2.1.2 Managers.................................................11 2.2 Building the Core Framework Scripts..................................11 2.2.1 BaseGameController.cs.....................................12 2.2.1.1 Script Breakdown................................14 viii Contents 2.2.2 Scene Manager.............................................17 2.2.2.1 Script Breakdown................................17 2.2.3 ExtendedCustomMonoBehavior.cs...........................19 2.2.4 BaseUserManager.cs........................................20 2.2.4.1 Script Breakdown................................22 2.2.5 BasePlayerManager.cs.......................................22 2.2.5.1 Script Breakdown................................23 2.2.6 BaseInputController.cs......................................24 2.2.6.1 Script Breakdown................................26 3. Player Structure 29 3.1 Game-Specific Player Controller......................................31 3.2 Dealing with Input..................................................32 3.3 Player Manager.....................................................35 3.3.1 Script Breakdown..........................................36 3.4 User Data Manager (Dealing with Player Stats Such as Health, Lives, etc.)....37 3.4.1 Script Breakdown..........................................39 4. Recipes: Common Components 41 4.1 Introduction.......................................................41 4.2 The Timer Class....................................................43 4.2.1 Script Breakdown..........................................45 4.3 Spawn Scripts......................................................48 4.3.1 A Simple Spawn Controller..................................49 4.3.1.1 Script Breakdown................................52 4.3.2 Trigger Spawner...........................................56 4.3.3 Path Spawner..............................................57 4.3.3.1 Script Breakdown................................61 4.4 Set Gravity.........................................................66 4.5 Pretend Friction—Friction Simulation to Prevent Slipping Around........66 4.5.1 Script Breakdown..........................................68 4.6 Cameras. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 4.6.1 Third-Person Camera.......................................69 4.6.1.1 Script Breakdown................................71 4.6.2 Top-Down Camera.........................................74 4.6.2.1 Script Breakdown................................74 4.7 Input Scripts.......................................................75 4.7.1 Mouse Input...............................................75 4.7.1.1 Script Breakdown................................76 4.7.2 Single Axis Keyboard Input.................................78 4.8 Automatic Self-Destruction Script.....................................79 4.8.1 Script Breakdown..........................................79 4.9 Automatic Object Spinner............................................79 4.9.1 Script Breakdown..........................................80 ix Contents 4.10 Scene Manager.....................................................81 4.10.1 Script Breakdown..........................................82 5. Building Player Movement Controllers 85 5.1 Shoot ’Em Up Spaceship.............................................85 5.2 Humanoid Character................................................91 5.2.1 Script Breakdown..........................................96 5.3 Wheeled Vehicle...................................................106 5.3.1 Script Breakdown.........................................109 5.3.2 Wheel Alignment.........................................114 5.3.3 Script Breakdown.........................................116 6. Weapon Systems 121 6.1 Building the Scripts................................................122 6.1.1 BaseWeaponController.cs..................................122 6.1.1.1 Script Breakdown...............................127 6.1.2 BaseWeaponScript.cs......................................134 6.1.2.1 Script Breakdown...............................138 7. Recipe: Waypoints Manager 143 7.1 Waypoint System..................................................143 8. Recipe: Sound Manager 157 8.1 The Sound Controller...............................................158 8.1.1 Script Breakdown.........................................160 8.2 The Music Player...................................................163 8.2.1 Script Breakdown.........................................165 8.3 Adding Sound to the Weapons.......................................167 9. AI Manager 169 9.1 The AI State Control Script..........................................171 9.2 The Base AI Control Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 9.2.1 Script Breakdown.........................................185 9.3 Adding Weapon Control to the AI Controller..........................206 9.3.1 Script Breakdown.........................................210 10. Menus and User Interface 215 10.1 The Main Menu....................................................215 10.1.1 Script Breakdown.........................................223 10.2 In-Game User Interface.............................................231 x Contents 11. Dish: Lazer Blast Survival 233 11.1 Main Menu Scene..................................................235 11.2 Main Game Scene..................................................236 11.3 Prefabs...........................................................237 11.4 Ingredients........................................................238 11.5 Game Controller...................................................239 11.5.1 Script Breakdown.........................................243 11.6 Player Controller...................................................250 11.6.1 Script Breakdown.........................................253 11.7 Enemies..........................................................259 11.7.1 Script Breakdown.........................................260 11.8 Wave Spawning and Control........................................261 11.8.1 Script Breakdown.........................................263 11.9 Wave Properties...................................................265 11.10 Weapons and Projectiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..266 11.11 User Interface.....................................................266 11.11.1 Script Breakdown.........................................267 12. Dish: Metal Vehicle Doom 271 12.1 Main Menu Scene..................................................272 12.2 Main Game Scene..................................................272 12.2.1 Prefabs...................................................275 12.3 Ingredients........................................................275 12.3.1 Game Controller..........................................276 12.3.1.1 Script Breakdown...............................282 12.3.2 Race Controller...........................................291 12.3.2.1 Script Breakdown...............................297 12.3.3 Global Race Manager......................................306 12.3.3.1 Script Breakdown...............................311 12.3.4 Vehicle/Custom Player Control.............................318 12.3.4.1 Script Breakdown...............................327 12.3.5 User Interface.............................................344 13. Dish: Making the Game Tank Battle 345 13.1 Main Game Scene..................................................347 13.2 Prefabs...........................................................349 13.3 Ingredients........................................................349 13.4 Game Controller...................................................350 13.4.1 Script Breakdown.........................................356 13.5 Battle Controller...................................................361 13.5.1 Script Breakdown.........................................363 13.6 Global Battle Manager..............................................364 13.6.1 Script Breakdown.........................................368 13.7 Players............................................................373 13.7.1 Script Breakdown.........................................382 xi Contents 13.8 AI Chasing with SetAIChaseTargetBasedOnTag.cs.....................383 13.8.1 Script Breakdown.........................................385 14. Dish: Making the Game Interstellar Paranoids 389 14.1 Main Menu.......................................................392 14.2 Game Scenes......................................................392 14.3 Prefabs...........................................................393 14.3.1 Ingredients...............................................394 14.3.2 Game Controller..........................................395 14.3.2.1 Script Breakdown...............................401 14.3.3 Player Spaceship..........................................411 14.3.3.1 Script Breakdown...............................415 14.3.4 Enemies..................................................423 14.3.4.1 Script Breakdown...............................424 14.3.5 Waypoint Follower........................................426 14.3.5.1 Script Breakdown...............................427 Final Note 429 xiii I would like to thank my wife for all the encouragement, support, and nice cups of tea. I would also like to thank my mum and dad, my brother Steve, and everyone else who knows me. Sophie cat, be nice to the boys. Sincere thanks go to the many people who positively influence my life directly or indirectly: Michelle Ashton, Brian Robbins, George Bray, Nadeem Rasool, Christian Boutin, James and Anna, Rich and Sharon, Liz and Peter, Rob Fearon (the curator of all things shiny), everyone on Twitter who RTs my babble (you know who you are, guys!), Matthew Smith (the creator of Manic Miner), David Braben, Tōru Iwatani, and anyone who made Atari games in the 1980s. I would like to thank everyone at AK Peters/CRC Press for the help and support and for publishing my work. Finally, a massive thank you goes out to you for buying this book and for wanting to do something as cool as to make games. I sincerely hope this book helps your gamemaking adventures—feel free to tell me about them on Twitter @psychicparrot or drop by my website at http://www.psychicparrot.com. Acknowledgments xv As I was starting out as a game developer, as a self-taught programmer my skills took a while to reach a level where I could achieve what I wanted. Sometimes I wanted to do things that I just didn’t have yet the technical skills to achieve. Now and again, software packages came along that could either help me in my quest to make games or even make full games for me; complete game systems such as the Shoot ’Em-Up Construction Kit (aka SEUCK) from Sensible Software, Gary Kitchen’s GameMaker, or The Quill Adventure System could bring to life the kinds of games that went way beyond anything that my limited programming skills could ever dream of building. The downside to using game creation software was that it was tailored to create games within their chosen specific genre. If I wanted to do something outside of the limitations of the software, the source code was inaccessible and there was no way to extend or modify it. When that happened, I longed for a modular code-based system that I could plug together to create different types of games but modify parts of it without having to spend a lot of time learning how the entire system internals work—building block game development that I could actually script and modify if I needed to. After completing my first book, Game Development for iOS with Unity3D, I wanted to follow up by applying a modular style of game building to Unity3D that would provide readers with a highly flexible framework to create just about any kind of game by “plugging in” the different script components. My intention was to make a more technical second book, based on C# programming, that would offer extensibility in any direction a developer might require. In essence, what you are holding in your hands right now is a cookbook Introduction xvi Introduction for game development that has a highly flexible core framework for just about any type of game. A lot of the work I put in at the start of writing this book was in designing a framework that not only made sense in the context of Unity but also could easily cope with the demands of different genres. Prerequisites You can get up and running with the required software for the grand total of zero dollars. Everything you need can be downloaded free of charge with no catches. You may want to consider an upgrade to Unity Pro at some point in the future, to take advantage of some of its advanced features, but to get started all you need to do is grab the free version from the Unity website. Unity Free or Unity Pro (available from the Unity store at http://www.unity3d.com) Unity Free is completely free for anyone or any company making less than $100,000 per year—it may be downloaded for no charge at all, and you don’t even need a credit card. It’s a really sweet deal! We are talking about a fully functional game engine, ready to make 3D or 2D games that may be sold commercially or otherwise. There are no royalties to pay, either. Unity Pro adds a whole host of professional functionality to the engine, such as render culling and profiling. If you are a company with more than $100,000 per year of turnover, you will need a Pro license, but if you find that Unity Free doesn’t pack quite enough power, you may also want to consider going Pro. You can arrange a free trial of the Pro version right from the Unity website to try before you buy. If the trial licence runs out before you feel you know enough to make a purchase, contact Unity about extending it and they are usually very friendly and helpful about it (just don’t try using a trial license for 6 months at a time, as they may just figure it out!). C# programming knowledge Again, to reiterate this very important point, this is nota book about learning how to program. You will need to know some C#, and there are a number of other books out there for that purpose, even if I have tried to make the examples as simple as possible! This book is about making games, not about learning to program. What This Book Doesn’t Cover This is not a book about programming and it is not a book about the right or wrong way to do things. We assume that the reader has some experience with the C# programming language. I am a self-taught programmer, and I understand that there may well be better ways to do things. xvii Introduction This is a book about concepts, and it is inevitable that there will be better methods for achieving some of the same goals. The techniques and concepts offered in this book are meant to provide solid foundation, not to be the final word on any subject. It is the author’s intention that, as you gain your own experiences in game development, you make your own rules and draw your own conclusions. Additional material is available from the CRC Press Web site: http://www.crcpress. com/product/isbn/9781466581401. 1 1 Making Games the Modular Way When I first started making games, I would approach development on a project-to-project basis, recoding and rebuilding everything from scratch each time. As I became a professional developer, landing a job at a game development studio making browser-based games, I was lucky enough to work with a guy who was innovating the scene. He was a master at turning out great games (both visually and gameplay-wise) very quickly. One secret to his success lay in the development of a reusable framework that could easily be refactored to use on all of his projects. His framework was set up to deal with server communication, input handling, browser communication, and UI among other things, saving an incredible amount of time in putting together all of the essentials. By reusing the framework, it allowed more time for him and his team to concentrate on great gameplay and graphics optimization, resulting in games that, at the time, blew the competition away. Of course, the structure was tailored to how he worked (he did build it, after all), and it took me a while to get to grips with his style of development; but once I did, it really opened my eyes. From then on, I used the framework for every project and even taught other programmers how to go about using it. Development time was substantially reduced, which left more time to concentrate on making better games. This book is based on a similar concept of a game-centric framework for use with many different types of games, rather than a set of different games in different styles. The overall goal of this book is to provide script-based components that you can use within that framework to make a head start with your own projects in a way that reduces recoding, repurposing, or adaptation time. 2 1. Making Games the Modular Way In terms of this book as a cookbook, think of the framework as a base soup and the scripting components as ingredients. We can mix and match script components from different games that use the same framework to make new games, and we can share several of the same core scripts in many different games. The framework takes care of the essentials, and we add a little “glue” code to pull everything together the way we want it all to work. This framework is, of course, optional, but you should spend some time familiarizing yourself with it to help understand the book. If you intend to use the components in this book for your own games, the framework may serve either as a base to build your games on or simply as a tutorial test bed for you to rip apart and see how things work. Perhaps you can develop a better framework or maybe you already have a solid framework in place. If you do, find a way to develop a cleaner, more efficient framework or even a framework that isn’t quite so efficient but works better with your own code, and do it. In this chapter, we start by examining some of the major programming concepts used in this book and look at how they affect the design decisions of the framework. 1.1 Important Programming Concepts I had been programming in C# for a fairly long time before I actually sat down and figured out some of the concepts covered in this chapter. It was not because of any particular problem or difficulty with the concepts themselves but more because I had solved the problems in a different way that meant I had no real requirement to learn anything new. For most programmers, these concepts will be second nature and perhaps something taught in school, but I did not know how important they could be. I had heard about things like inheritance, and it was something I put in the to-do list, buried somewhere under “finish the project.” Once I took the time to figure them out, they saved me a lot of time and led to much cleaner code than I would have previously pulled together. If there’s something you are unsure about, give this chapter a read-through and see whether you can work through the ideas. Hopefully, they may save some of you some time in the long run. 1.1.1 Manager and Controller Scripts I am a strong believer in manager and controller scripts. I like to try and split things out into separate areas; for example, in the Metal Vehicle Doomgame, I have race controller scripts and a global race controller script. The race controller scripts are attached to the players and track their positions on the track, waypoints, and other relevant player-specific race information. The global race controller script talks to all the race controller scripts attached to the players to determine who is winning and when the race starts or finishes. By keeping this logic separate from the other game scripts and contained in their own controller scripts, it makes it easier to migrate them from project to project. Essentially, I can take the race controller and global race controller scripts out of the game and apply them to another game, perhaps one that features a completely different type of gameplay— for example, alien characters running around a track instead of cars. As long as I apply the correct control scripts, the race logic is in place, and I can access it in the new game. In the framework that this book contains, there are individual manager and controller scripts dealing with user data, input, game functions, and user interface. We look at those in detail in Chapter 2, but as you read this chapter, you should keep in mind the idea of separated scripts dedicated to managing particular parts of the game structure. It was 3 1.1 Important Programming Concepts important to me to design scripts as standalone so that they may be used in more than one situation. For example, our weapon slot manager will not care what kind of weapon is in any of the slots. The weapon slot manager is merely an interface between the player and the weapon, taking a call to “fire” and responding to it by telling the weapon in the currently selected weapon slot to fire. What happens on the player end will not affect the slot manager just as anything that happens with the weapon itself will not affect the slot manager. It just doesn’t care as long as your code talks to it in the proper way and as long as your weapons receive commands in the proper way. It doesn’t even matter what type of object the slot manager is attached to. If you decide to attach the weapon slot manager to a car, a boat, a telegraph pole, etc., it doesn’t really matter just as long as when you want them to fire, you use the correct function in the slot manager to get it to tell a weapon to fire. Since our core game logic is controlled by manager and controller scripts, we need to be a little smart about how we piece everything together. Some manager scripts may benefit from being static and available globally (for all other scripts to access), whereas others may be better attached to other scripts. We deal with these on a case-by-case basis. To get things started, we will be looking at some of the ways that these manager scripts can communicate with each other. As a final note for the topic in this section, you may be wondering what the difference is between managers and controllers. There really isn’t all that much, and I have only chosen to differentiate for my own sanity. I see controllers as scripts that are larger global systems, such as game state control, and managers as smaller scripts applied to gameObjects, such as weapon slot management or physics control. The terms are applied loosely, so don’t worry if there appear to be inconsistencies in the application of the term in one case versus another. I’ll try my best to keep things logical, but that doesn’t mean it’ll always make sense to everyone else! 1.1.2 Script Communication An important part of our manager- and component-based structures is how our scripts are going to communicate with each other. It is inevitable that we will need to access our scripts from a multitude of other areas of the game, which means we should try to provide interfaces that make the most sense. There are several different ways of communicating between scripts and objects in Unity: 1. Direct referencing manager scripts via variables set in the editor by the Inspector window. The easiest way to have your scripts talk to each other is to have direct references to them in the form of public variables within a class. They are populated in the Unity editor with a direct link to another script. Here is an example of direct referencing: public void aScript otherScript; In the editor window, the Inspector shows the otherScript field. We drag and drop an object containing the script component that we want to talk to. Within the class, function calls are made directly on the variable, such as otherScript.DoSomething(); 4 1. Making Games the Modular Way 2. GameObject referencing using SendMessage. SendMessage is a great way to send a message to a gameObject and call a function in one of its attached scripts or components when we do not need any kind of return result. For example, SomeGameObject.SendMessage("DoSomething"); SendMessage may also take several parameters, such as setting whether or not the engine should throw an error when there is no receiver, that is, no function in any script attached to the gameObject with a name matching the one in the SendMessage call. (SendMessageOptions). You can also pass one parameter into the chosen function just as if you were passing it via a regular function call such as SomeGameObject.SendMessage("AddScore",2); SomeGameObject.SendMessage("AddScore", SendMessageOptions.RequireReceiver); SomeGameObject.SendMessage("AddScore", SendMessageOptions.DontRequireReceiver); 3. Static variables. The static variable type is useful in that it extends across the entire system; it will be accessible in every other script. This is a particularly useful behavior for a game control script, where several different scripts may want to communicate with it to do things such as add to the player’s score, lose a life, or perhaps change a level. An example declaration of a static variable might be private static GameController aController; Although static variables extend across the entire program, you can have private and public static variables. Things get a little tricky when you try to understand the differences between public and private static types—I was glad to have friends on Twitter that could explain it all to me, so let me pass on what I was told: Public static A public static variable exists everywhere in the system and may be accessed from other classes and other types of script. Imagine a situation where a player control script needs to tell the game controller script whenever a player picks up a banana. We could deal with it like this: 1. In our gamecontroller.cs game controller script, we set up a public static: public static GameController gateway; 2. When the game controller (gamecontroller.cs) runs its Start() function, it stores a reference to itself in a public static variable like this: gateway = this; 3. In any other class, we can now access the game controller by referring to its type followed by that static variable (GameController.gateway) such as GameController.gateway.GotBanana(); 5 1.1 Important Programming Concepts Private static A private static variable exists within the class it was declared and in any other instances of the same class. Other classes/types of script will not be able to access it. As a working example, try to imagine that a script named player.cs directly controls player objects in your game. They all need to tell a player manager script when something happens, so we declare the player manager as a static variable in our player.cs script like this: private static PlayerManager playerManager; The playerManager object only needs to be set up once, by a single instance of the player class, to be ready to use for all the other instances of the same class. All player.cs scripts will be able to access the same instance of the PlayerManager. 4. The singleton design pattern. In the previous part of this section, we looked at using a static variable to share a manager script across the entire game code. The biggest danger with this method is that it is possible to create multiple instances of the same script. If this happens, you may find that your player code is talking to the wrong instance of the game controller. A singletonis a commonly used design pattern that allows for only one instance of a particular class to be instantiated at a time. This pattern is ideal for our game scripts that may need to communicate (or be communicated with) across the entire game code. Note that we will be providing a static reference to the script, exactly as we did in the “Static Variables” method earlier in this section, but in implementing a singleton class, we will be adding some extra code to make sure that only one instance of our script is ever created. 1.1.3 Using the Singleton Pattern in Unity It is not too difficult to see how useful static variables can be in communication between different script objects. In the public static example cited earlier, the idea was that we had a game controller object that needed to be accessed from one or more other scripts in our game. The method shown here was demonstrated on the Unity public wiki*by a user named Emil Johansen (AngryAnt). It uses a private static variable in conjunction with a public static function. Other scripts access the public function to gain access to the private static instance of this script, which is returned via the public function so that only one instance of the object will ever exist in a scene regardless of how many components it is attached to and regardless of how many times it is instantiated. A simple singleton structure: public class MySingleton { private static MySingleton instance; public MySingleton () *http://wiki.unity3d.com/index.php/Singleton. 6 1. Making Games the Modular Way { if (instance != null) { Debug.LogError ("Cannot have two instances of singleton."); return; } instance = this; } public static MySingleton Instance { get { if (instance == null) { new MySingleton (); } return instance; } } } The singleton instance of our script may be accessed anywhere, by any script, simply with the following syntax: MySingleton.Instance.MySingletonMember; 1.1.4 Inheritance Inheritanceis a complex concept, which demands some explanation here because of its key role within the scripts provided in this book. Have a read through this section, but don’t worry if you don’t pick up inheritance right away. Once we get to the programming, it will most likely become clear. The bottom line is that inheritance is used in programming to describe a method of providing template scripts that may be overridden, or added to, by other scripts. As a metaphor, imagine a car. All cars have four wheels and an engine. The types of wheels may vary from car to car, as will the engine, so when we say “this is a car” and try to describe how our car behaves, we may also describe the engine and wheels. These relationships may be shown in a hierarchical order: Car -Wheels -Engine Now try to picture this as a C# script: Car class Wheels function Engine function 7 1.1 Important Programming Concepts

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧