void Start() { transf = gameObject.GetComponent <Transform>(); //获取transf组件 w = gameObject.GetComponent <Weapons>(); //实例化w w.ChooseWeapon(); //拿上枪 bulletNumber = w.bulletNumber; //得到弹夹子弹数 bulletTotalNumber = w.bulletTotalNumber; //得到总子弹数 audioSource = gameObject.GetComponent <AudioSource>(); //获取audioSourse组件 }
private void Start() { w = gameObject.GetComponent <Weapons>(); //实例化武器 w.ChooseWeapon(); //获取武器 nma = gameObject.GetComponent <NavMeshAgent>(); //实例化NMA enemyLayer = new TeamManager().ChooseEnemy(team); //获取敌人的层 audioSource = gameObject.GetComponent <AudioSource>(); //实例化audioSourse组件 bulletNumber = w.bulletNumber; //得到弹夹子弹数 bulletTotalNumber = w.bulletTotalNumber; //得到总子弹数 stateManager = State.Search; //先处于追逐状态 }
public void ChangeGun(string WeaponName) { if (WeaponName.Equals("UZI")) { weapon_of_player.weaponInHand = weapons.UZI; weapon_of_player.ChooseWeapon(); PC.bulletNumber = PC.w.bulletNumber; PC.bulletTotalNumber = PC.w.bulletTotalNumber; } if (WeaponName.Equals("AK47")) { weapon_of_player.weaponInHand = weapons.Ak47; weapon_of_player.ChooseWeapon(); PC.bulletNumber = PC.w.bulletNumber; PC.bulletTotalNumber = PC.w.bulletTotalNumber; } if (WeaponName.Equals("M249")) { weapon_of_player.weaponInHand = weapons.M249; weapon_of_player.ChooseWeapon(); PC.bulletNumber = PC.w.bulletNumber; PC.bulletTotalNumber = PC.w.bulletTotalNumber; } if (WeaponName.Equals("AWP")) { weapon_of_player.weaponInHand = weapons.AWP; weapon_of_player.ChooseWeapon(); PC.bulletNumber = PC.w.bulletNumber; PC.bulletTotalNumber = PC.w.bulletTotalNumber; } if (WeaponName.Equals("M3")) { weapon_of_player.weaponInHand = weapons.M3; weapon_of_player.ChooseWeapon(); PC.bulletNumber = PC.w.bulletNumber; PC.bulletTotalNumber = PC.w.bulletTotalNumber; } }