public override void setWeapon() { ICharacter owner = m_soldierBuildParam.character; IWeapon weapon = FactoryManager.getWeaponFactory().createWeapon(m_soldierBuildParam.weapon); weapon.setOwner(owner); owner.setWeapon(weapon); owner.getGameObject().AddComponent <IKController>();//添加IK控制脚本(注意,是添加在拥有Animator的角色上,不是武器上) Vector3 weaponPos = UnityTool.findChildGameObject(owner.getGameObject(), "MainWeaponPos").transform.localPosition; UnityTool.attach(owner.getGameObject(), weapon.getGameObject(), weaponPos); }
// 播放特效 public void playEffect(string EffectName) { // 取得特效 IAssetFactory factory = FactoryManager.getAssetFactory(); GameObject effectObj = factory.loadEffect(EffectName); if (effectObj == null) { return; } // 将特效附加到当前角色对象 UnityTool.attach(m_gameObject, effectObj, Vector3.zero); }
public override void setWeapon() { //if (m_enemyBuildParam.weapon == ENUM_Weapon.Null) //return; IWeapon weapon = FactoryManager.getWeaponFactory().createWeapon(m_enemyBuildParam.weapon); weapon.setOwner(m_enemyBuildParam.character); //UnityTool.attachToRefPos(m_enemyBuildParam.character.getGameObject(), weapon.getGameObject(), "mesh_R_Forearm", Vector3.zero); if (m_enemyBuildParam.weapon != ENUM_Weapon.Fist) { UnityTool.attach(m_enemyBuildParam.character.getGameObject(), weapon.getGameObject(), Vector3.zero + new Vector3(0, 1, 0)); } m_enemyBuildParam.character.setWeapon(weapon); }
//设置特效组件 public override void setupEffect() { m_gunEnd = UnityTool.findChildGameObject(m_gameObject, "GunBarrelEnd"); GameObject shootEffect = FactoryManager.getAssetFactory().loadEffect("ShootEffect"); UnityTool.attach(m_gunEnd, shootEffect, Vector3.zero); m_particles = shootEffect.GetComponent <ParticleSystem>(); m_audio = m_gunEnd.GetComponent <AudioSource>(); m_line = m_gunEnd.GetComponent <LineRenderer>(); //m_light = m_gunEnd.GetComponent<Light>(); m_light = UnityTool.findChildGameObject(m_gunEnd, "FireLight").GetComponent <Light>(); m_line.SetColors(Color.red, Color.black); m_line.SetWidth(0.1f, 0.1f); }