《Unity3D编写雷电游戏.docx》由会员分享,可在线阅读,更多相关《Unity3D编写雷电游戏.docx(16页珍藏版)》请在优知文库上搜索。
1、HierarchyCreateMainMainCamerarMeCU_StartBeginPlayerPlayerTerreinOInspectora*三MainIStaticTagUnZggdt1.ayerDfauhtJTransformO.Posibon1,191681Y13.49377Z-0.033691RotationOYOZOSceleX1Y1Z1Main.Script(Script)。ScriptMaineScriptGCurStateBMain(StateStOStateStart(Script).。ScriptKStateStartStaitMenUMenueeStartOQS
2、tateRun(Script)ProjectCratAllCode!8MameScnptAlMenuBBegmGamefiPayerConbolSStatefiStotcRunSstatestartImageAiModeINewTerrainPrefdbScene.StandardAssets.ThunderScriptPlayerStateRunPlayer料S税在按M拉卜网切根先起先场花:usingSystem.Coiiections;publicclassBeginGame:MonoBehaviourpublicStateRunm_RunState;publicMJIn_Scriptm-
3、Mai11Scnpt;/UsethisforinitializationvoidStart()vodOnMouseEnterOPentCenBC;voidOnMouseUpO(m一MdinSaiPt.ChangeStatWmRunState);voidOnMouseExitO(PrtntreXItM)出个和本息拄在一个板上而的.由它时Mii人M也的主场景JF同堂卜飞机的体动.现在起先真正的的或元素的*nr常力,让匕机动起求的先是飞m的我迪,可拿2D中的段班是利触侑诩环羊动.在3D中我阳M以让步保机移动存我我。叫口粮超个大地形.在地形I依一”附宅的东曲UUpdateISCaMedonceperf
4、rameVOKJUpdate()Tum1.eft=false;TumRight=false;if(Input.GtKey(KeyCadeAV)Vector3SCreenPos=Ca5creenP0s.y)this.trfisforn.Transte(Vector3.forwardTime.deltaTmem.nMoveSpeed);)if(Input.GetKey(KeyCde.S)Vector3SCreenPoS=Camer.maiCamera.WxldToScreenPolt(this.transrorm.position);If(OswnPos.y)ts.tr3sform.Trastat
5、e(Vector3,forwardme.detTme-m_nMoveSpeed);)If(1nput.GctKcy(KeyCodc.A)(VeCtOr3ScreenPos=Camera.mainC4merd.VorldToScreenPoint(this.transform.position);if(OscreenPos.x)Chis.transform.Transte(Vector3.enMTime.OeitaTimeMm.nMoveSpeed);向左仪添(CurRoutionscreenPos.x)this.transform.Tranlate(Vector3.leftTime.delUT
6、imcam.nMo*Spd;内右转if(CurRotation-RotateUmit)CurRotation-RotateSpeed;TumRight-true;)忖来If(ITum1.cft&ITumRight)if(CurRoUtion0.0)CurRotation-=RotateSpeed;elserf(Curftatono11znewVcctor3(0,0,1);m_Pbnc.rotation三rot;让如机和E帆超以H定的过I曳前格th.transforn.Translate(Vector3.forwardTime.deltaTmemMoveSpeed);Camer.mainCa11
7、era.transform.Translate(Vector3.up*TimeddtaTimemm.nMoveSpeed);也机的也便限制代码,不知为什么,我的两小角废跟IX收的长果mw,空好r?.这次欠皖入f州的彼弟庄.纭用松下知H侑4capsuleWprerabfrtR.处死各村武X2网的期先切换.箕不由的邠到电il发式中的StQmgV检K“尤软略校大的A体介MM以值过仃度构嵯嫌去学月.立个校式W实加State检式汇不幻Weapon年是全的贰笈的M英,斯的A龙雄承广它,HttWA.,佛模型.实现Fire碌R就M以Weaponranger用普丹生册武建.切推戌花.usingUaityEngm
8、e;usingSystem.Colcto11s;publicclassWcaponManagcr:MOnOBehaviOUrpublicWeaponm-CurWcap11;privatefloatmFireBapseTime=O;/UsethisforinitializationvoidStart()UUpOateiscaedonceperframevo*dUpdate()m_RrcEiapseTmCurVeapon.Getu!letI11tervdl()mCurVeapcn.Fre();m_FirelapseTime=O;)else)位求子外放射;的“刈.然黯衽大干时何伸隰后才能放射卜个子外
9、.火各父类,usingUnityEngine;usingSyStem.Collections;usingSystem;publicclassveapo11:MonoBehaviourprotectedfloatm_fBullct1ntcrval=O;,用炎型publicStringm一IyPeName=*;publicfloatGetBaIteGntervdIOreturnmBUlleunterVaI;UUsethisforinitializationvoidStart()/UpdateiscanedonceperframevoidUpdate()publicvirtualvoidRreo()
10、域珞本的种子岬,usingUnityEngine;usingSyStem.Collections;publicclassWeaponNormal:Weapon(privateconstIntMA.FP-2;publicTra115form()m,ArePot-newTransfornMAX-FP;publicRgdbodym_BullctPrc;WcaponNormal()(mfBulletlntervai三2;m_tVPeName三Norma;/UsethisforinitializationvoidStart()/UpdateiscalledonceperframevokJUpdate()
11、publicoverridev*dFre()(forntI三O;in,m_FirePoinl(i.rotation);do11e.velocily=transfo11n.TransformOirecton(Veclor3.forwrd20);m_FkePOint;1个敦也储C攻射广外的垃肯在娟”母中.可以在飞机附,用2的GameOb胆UK科别伸I;的也和.然GlH入这个IiE中MAX-FP定义72的t,这以刈迪雷件这个兄rigidbody才3H所以4.2/广舛的prefab时竹定传为它*J11gdtody才1.PlayerPlaneFirePointlFircPointZFirePoint3F
12、rcPoint41.IOBModelSpotlightPleycrTerrainScaleBQWeaponManager(Script)沏ScriptCurWeaponWeaponManacoPlane(WapoOBQWeaponNormal(Script)寄6ScnptTypeNameFirePointSizeElement0Element1BulletPreWcaponNorm.oNormal2,FirePomtZ(Tr.O,FrePont3(Tr.O4BuIIetNormaIOSStateRun图StateStart,WeaponEBWeaponWeaponManagerVZeaponNormaIImageAlModelJNewTerraintPrefabBuIIctNormaISceneStandardAssetsQThundei