示例#1
0
        static bool Prefix(WeaponPool __instance, int id, ConfigWeapon w, Weapon weapon)
        {
            weapon.TypeId = id;
            weapon.Type   = w.Type;
            weapon.Proto  = __instance.GetProto(w, id);
            if (weapon.Animator == null)
            {
                weapon.Animator = __instance.GetComponent <Animator>();
            }

            var ctrl = WeaponPool_Build_Patch_1.LoadAnimator(w.Animation);

            if (ctrl != null)
            {
                weapon.Animator.runtimeAnimatorController = ctrl;
            }

            if (id != 0)
            {
                ConfigItem configItem = ConfigItem.get(id);
                weapon.name = configItem.Name;
            }
            weapon.SetWeaponImage("Weapon");
            if (ConfigWeapon.getAttackSound(id) != "0")
            {
                weapon.AttackSound.clip = (AudioClip)Resources.Load(ConfigWeapon.getAttackSound(id), typeof(AudioClip));
            }
            return(false);
        }
示例#2
0
        public static bool Prefix(WeaponPool __instance, int id)
        {
            var cfg = ConfigWeapon.get(id);

            if (!__instance.PrefabDict.ContainsKey(cfg.Prefab))
            {
                AssetBundle asset = null;
                try
                {
                    //var name = cfg.Prefab.Substring(cfg.Prefab.LastIndexOf('\\') + 1);
                    //name = name.Substring(name.LastIndexOf('/') + 1);
                    asset = AssetBundle.LoadFromFile(cfg.Prefab);
                    var prefabGo = asset.LoadAsset <GameObject>("武器");
                    __instance.PrefabDict.Add(cfg.Prefab, new WeaponCaches(prefabGo));
                    Debug.Log("Load Prefab:" + cfg.Prefab);
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Load Prefab {0} faild:{1}", cfg.Prefab, e));
                }
                finally
                {
                    if (asset != null)
                    {
                        asset.Unload(false);
                    }
                }
            }
            return(true);
        }
示例#3
0
    public void Create(int vID, int roomID, string nName, int team, int characterID, int mainWeaponID, int secondWeaponID)
    {
        GameObject   model  = Resources.Load("Prefab/Avatar/Avatar_" + characterID) as GameObject;
        ConfigWeapon main   = Source.ReadWeaponConfig(mainWeaponID);
        ConfigWeapon second = Source.ReadWeaponConfig(secondWeaponID);
        GameObject   avatar = Factory.CreateAvatar(model, team, this.isLocal, this.transform.position, this.transform.rotation, main, second);

        avatar.GetComponent <PhotonView>().viewID = vID;

        var battleMgr = avatar.GetComponent <C_BattleMgr>();

        battleMgr.nickName = nName;
        battleMgr.roomID   = roomID;
        battleMgr.OnKill   = Battle.battleMgr.AddScore;

        Battle.PlayerJoin(team, roomID, battleMgr);

        if (this.isLocal)
        {
            Battle.localPlayerCamera = avatar.GetComponent <C_Camera>().mainCamera;
            var uiMgr = avatar.GetComponent <C_UiEventMgr>();
            Battle.hudMgr.Init(uiMgr);
            Battle.planeHUDMgr.Init(uiMgr);
            Battle.localPlayerBattleInfo = battleMgr;

            battleMgr.SetPlayerEnable(false);
        }
    }
示例#4
0
        static bool Prefix(WeaponPool __instance, ItemData item, ConfigWeapon w, Weapon weapon)
        {
            weapon.TypeId = item.id;
            weapon.Type   = w.Type;

            var par     = new object[] { w, item };
            var oMethod = typeof(WeaponPool).GetMethod("GetProto", BindingFlags.Instance | BindingFlags.NonPublic);
            var ret     = oMethod.Invoke(__instance, par);

            weapon.Proto = (IWeaponProto)ret;

            var ctrl = WeaponPool_Build_Patch_1.LoadAnimator(w.Animation);

            if (ctrl != null)
            {
                weapon.Animator.runtimeAnimatorController = ctrl;
            }

            weapon.name = ConfigItem.getName(item.id);
            weapon.SetWeaponImage("Weapon");
            if (ConfigWeapon.getAttackSound(item.id) != "0")
            {
                weapon.AttackSound.clip = (AudioClip)Resources.Load(ConfigWeapon.getAttackSound(item.id), typeof(AudioClip));
            }
            return(false);
        }
示例#5
0
        public static void BronyaRuntimeAttachHandler(ConfigWeapon config, Transform weaponProtoTrans, BaseMonoAnimatorEntity avatar, string avatarType)
        {
            BronyaWeaponAttach attach = (BronyaWeaponAttach)config.Attach;

            if (!string.IsNullOrEmpty(attach.WeaponEffectPattern))
            {
                SetTransformParentAndReset(Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar).transform, avatar.GetAttachPoint("GunPoint"));
            }
        }
示例#6
0
 public void Init(ConfigWeapon config, byte type)
 {
     this.config         = config;
     this.type           = type;
     this.cutPic.texture = config.cutPicInEquip;
     this.wName.text     = config.wname;
     this.damage.text    = config.damage.ToString();
     this.fireSpeed.text = config.fireSpeed.ToString();
     this.mag.text       = config.mag.ToString();
     this.spread.text    = config.spread.ToString();
 }
示例#7
0
 public void AttachWeapon(int weaponID, string avatarType)
 {
     if (this._weaponMetaID != weaponID)
     {
         this._weaponMetaID = weaponID;
         ConfigWeapon weaponConfig     = WeaponData.GetWeaponConfig(weaponID);
         Transform    weaponProtoTrans = Miscs.LoadResource <GameObject>(weaponConfig.Attach.PrefabPath, BundleType.RESOURCE_FILE).transform;
         WeaponAttach.AttachWeaponMesh(weaponConfig, this, weaponProtoTrans, avatarType);
         int layer = 8;
         base.gameObject.SetLayer(layer, true);
     }
 }
示例#8
0
        public static void KianaRuntimeAttachHandler(ConfigWeapon config, Transform weaponProtoTrans, BaseMonoAnimatorEntity avatar, string avatarType)
        {
            KianaWeaponAttach attach = (KianaWeaponAttach)config.Attach;

            if (!string.IsNullOrEmpty(attach.WeaponEffectPattern))
            {
                GameObject obj2 = Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar);

                GameObject obj3 = Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar);

                SetTransformParentAndReset(obj2.transform, avatar.GetAttachPoint("LeftGunPoint"));
                SetTransformParentAndReset(obj3.transform, avatar.GetAttachPoint("RightGunPoint"));
            }
        }
示例#9
0
        public static void AddAvatarWeaponAdditionalAbilities(int weaponID, AvatarActor avatar)
        {
            ConfigWeapon weaponConfig = GetWeaponConfig(weaponID);

            for (int i = 0; i < weaponConfig.AdditionalAbilities.Length; i++)
            {
                ConfigAbility abilityConfig = AbilityData.GetAbilityConfig(weaponConfig.AdditionalAbilities[i].AbilityName, weaponConfig.AdditionalAbilities[i].AbilityOverride);
                avatar.CreateAppliedAbility(abilityConfig);
                if (!string.IsNullOrEmpty(weaponConfig.AdditionalAbilities[i].AbilityReplaceID))
                {
                    avatar.abilityIDMap[weaponConfig.AdditionalAbilities[i].AbilityReplaceID] = abilityConfig.AbilityName;
                }
            }
        }
示例#10
0
 public void OnWeaponItemClick(ConfigWeapon config, byte type)
 {
     if (type == 1)
     {
         mainSelect.UpdateData(config);
         Battle.playerBattleSave.mainWeaponId = config.id;
         Battle.SavePlayerBattleData();
     }
     else if (type == 2)
     {
         secondSelect.UpdateData(config);
         Battle.playerBattleSave.secondWeaponId = config.id;
         Battle.SavePlayerBattleData();
     }
 }
示例#11
0
        public static void MeiRuntimeAttachHandler(ConfigWeapon config, Transform weaponProtoTrans, BaseMonoAnimatorEntity avatar, string avatarType)
        {
            MeiWeaponAttach attach = (MeiWeaponAttach)config.Attach;

            if (!string.IsNullOrEmpty(attach.WeaponEffectPattern))
            {
                if ((avatarType == "Mei_C1_DH") || (avatarType == "Mei_C3_WS"))
                {
                    SetTransformParentAndReset(Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar).transform, avatar.GetAttachPoint("WeaponRightHand"));
                }
                else if ((avatarType == "Mei_C2_CK") || (avatarType == "Mei_C4_LD"))
                {
                    GameObject obj3 = Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar);

                    GameObject obj4 = Singleton <EffectManager> .Instance.CreateGroupedEffectPattern(attach.WeaponEffectPattern, avatar);

                    SetTransformParentAndReset(obj3.transform, avatar.GetAttachPoint("WeaponLeftHand"));
                    SetTransformParentAndReset(obj4.transform, avatar.GetAttachPoint("WeaponRightHand"));
                }
            }
        }
    public void InstallWeapon(int index, ConfigWeapon config, bool isActive)
    {
        var weapon    = GameObject.Instantiate(config.model, handPoint);
        var weaponAtt = weapon.GetComponent <WeaponAttribute>();

        weaponAtt.runtimeMag = weaponAtt.mag - 1;
        weaponAtt.bore       = true;
        weaponAtt.index      = index;

        weaponAtt.constraint.SetSource(0, new ConstraintSource()
        {
            sourceTransform = (int)weaponAtt.type == 1 ? riflePoint : pistolPoint,
            weight          = 1
        });

        weaponAtt.constraint.weight = 1;
        weaponAtt.interval          = 60f / weaponAtt.fireSpeed;
        weaponAtt.Init(this.gameObject, config);

        weaponAtt.active = isActive;

        weaponAttributes.Add(index, weaponAtt);
    }
示例#13
0
    public void Init(GameObject obj, ConfigWeapon config)
    {
        // 安装属性
        this.wname            = config.wname;
        this.type             = config.type;
        this.mag              = config.mag;
        this.runtimeMag       = config.mag;
        this.damage           = config.damage;
        this.fireSpeed        = config.fireSpeed;
        this.spread           = config.spread;
        this.aimSpread        = config.aimSpread;
        this.crouchSpreadRate = config.crouchSpreadRate;
        this.recoilX          = config.recoilX;
        this.recoilY          = config.recoilY;
        this.cutPicInBattle   = config.cutPicInBattle;

        this.interval = 60f / fireSpeed;

        // 初始化武器状态组件,传递武器物体的组件等
        foreach (var state in states.Values)
        {
            state.Init(obj);
        }
    }
示例#14
0
 public static void AttachWeaponMesh(ConfigWeapon weaponConfig, IWeaponAttacher avatar, Transform weaponProtoTrans, string avatarType)
 {
     weaponConfig.Attach.GetAttachHandler()(weaponConfig.Attach, weaponProtoTrans, avatar, avatarType);
 }
示例#15
0
 public static void HimekoRuntimeAttachHandler(ConfigWeapon config, Transform weaponProtoTrans, BaseMonoAnimatorEntity himeko, string avatarType)
 {
 }
示例#16
0
 public void UpdateData(ConfigWeapon config)
 {
     this.image.texture = config.cutPicInEquip;
     this.wName.text    = config.wname;
 }
示例#17
0
    public static GameObject CreateAvatar(GameObject avatar, int camp, bool isLocal, Vector3 position, Quaternion rotation, ConfigWeapon main, ConfigWeapon second)
    {
        var avatarObj = GameObject.Instantiate(avatar);
        //Object.Destroy(avatarObj.GetComponent<C_UIData>(), 0);
        var _camera = avatarObj.GetComponent <C_Camera>();

        // 设置阵营
        var attributes = avatarObj.GetComponent <C_Attributes>();

        attributes.camp = camp;
        // 设置是否是本机用户
        avatarObj.GetComponent <C_Velocity>().isLocalPlayer = isLocal;
        // 本机用户的话开启相机组件,否则关闭
        avatarObj.GetComponentInChildren <Camera>().enabled = isLocal;
        // 设置射击时的射线判定需要碰撞的Layer
        _camera.shootLayerMask = Source.ReadConfig <ConfigLayer>("LayerMask/Camp" + camp + "CameraMask").layerMask;
        // 添加武器
        var weaponHandle = avatarObj.GetComponent <C_WeaponHandle>();

        weaponHandle.mainWeapon   = main;
        weaponHandle.secondWeapon = second;

        // 如果是本机用户,进一步处理
        if (isLocal)
        {
            // 添加主UI显示的数据关联组件
            //avatarObj.AddComponent<C_UIData>();
            // 输入检测组件
            avatarObj.AddComponent <C_Input>();
            // 添加声音监听组件
            _camera.cameraObj.gameObject.AddComponent <AudioListener>();
            // 设置当前对局中的本地玩家相机
            Battle.localPlayerCameraTrans = _camera.cameraObj;
            Battle.localPlayerCamera      = _camera.mainCamera;
            Battle.localPlayerCamp        = camp;
        }

        Aspect.SetCamp(avatarObj, camp);

        avatarObj.transform.position = position;
        avatarObj.transform.rotation = rotation;
        avatarObj.GetComponent <GameObjectEntity>().enabled = true;

        return(avatarObj);
    }