文件名称:unity3d开发的FPS
文件大小:14.77MB
文件格式:ZIP
更新时间:2016-06-07 08:16:37
游戏
Unity3d开发的小游戏,#pragma strict //巡逻范围 var patrolRadius = 200; var currentTarget : Transform; //路径点 var wayPoints : Transform[]; var attackRadius = 5; var currentWayPoint : Transform; var findWayTime = 5; var lastTime = 0; //bot状态 var botState : Person; //攻击是否结束 var attackEnd = true; private var bot : GameObject; private var nga : NavMeshAgent; private var anima : Animation; function Start () { //取得AI对象 bot = transform.gameObject; botState = GetComponent(Person); nga = GetComponent(NavMeshAgent); //初始化动画 anima = bot.transform.Find("girl").transform.animation; //设置动画速度 anima["Run00"].speed = 2.0; anima["Attack"].speed = 2.0; if(currentTarget != null){ nga.SetDestination(currentTarget.position); } } function Update () { if(currentTarget == null){ nga.Stop(true); }else{ if(botState.Life > 0){ //必须在攻击结束后才能恢复其它动作 if(attackEnd == true){ if(GetTargetDistance()>3){ nga.SetDestination(currentTarget.position); nga.Resume(); anima.CrossFade("Run00",0.3); }else{ nga.Stop(true); anima.CrossFade("Attack",0.3); //1秒后执行攻击函数 Invoke("Attack",0.6); //攻击状态未完成 attackEnd = false; } } } } } function move(){ } function Attack(){ if(currentTarget != null){ var player : CharacterState = currentTarget.GetComponent("CharacterState"); player.ApplyDamage(5); } //攻击状态已完成 attackEnd = true; } function GetTargetDistance(){ return Vector3.Distance(bot.transform.position,currentTarget.transform.position ); } function findWay(){ } function Death(){ //停止追踪目标 nga.Stop(true); }
【文件预览】:
demo_Data
----sharedassets0.assets(22.21MB)
----Resources()
--------unity default resources(12.61MB)
----PlayerConnectionConfigFile(23B)
----output_log.txt(263KB)
----mainData(46KB)
----Mono()
--------etc()
--------mono.dll(2MB)
----Managed()
--------UnityScript.Lang.dll(14KB)
--------Assembly-CSharp-firstpass.dll(36KB)
--------Assembly-CSharp.dll(194KB)
--------mscorlib.dll(2.38MB)
--------Mono.Security.dll(286KB)
--------UnityEngine.dll(477KB)
--------Assembly-UnityScript-firstpass.dll(83KB)
--------Boo.Lang.dll(124KB)
--------System.dll(1.02MB)
--------Assembly-UnityScript.dll(38KB)
----resources.assets(424KB)
demo.exe