Пример #1
0
 public static void KianaDetachHandler(ConfigWeaponAttach config, IWeaponAttacher kiana, string avatarType)
 {
     DetachWeaponAttachPoint(kiana, "WeaponLeftHand");
     DetachWeaponAttachPoint(kiana, "WeaponRightHand");
     DeleteAttachPointChildren(kiana, "WeaponLeftHand", true);
     DeleteAttachPointChildren(kiana, "WeaponRightHand", true);
 }
Пример #2
0
        private static void DetachWeaponAttachPoint(IWeaponAttacher avatar, string attachPoint)
        {
            Transform transform = avatar.GetAttachPoint(attachPoint);

            transform.GetComponent <MeshFilter>().sharedMesh        = null;
            transform.GetComponent <MeshRenderer>().sharedMaterials = new Material[0];
        }
Пример #3
0
 public static void BronyaDetachHandler(ConfigWeaponAttach config, IWeaponAttacher bronya, string avatarType)
 {
     DetachWeaponAttachPoint(bronya, "WeaponLeftArmIn");
     DetachWeaponAttachPoint(bronya, "WeaponLeftArmOut");
     DeleteAttachPointChildren(bronya, "WeaponLeftArmIn", true);
     DeleteAttachPointChildren(bronya, "WeaponLeftArmOut", true);
 }
Пример #4
0
        private static void MoveAvatarAttachPoint(IWeaponAttacher avatar, string weaponAttachPointTransPath, string avatarAttachPointName, Transform protoTrans)
        {
            Transform from        = protoTrans.Find(weaponAttachPointTransPath);
            Transform attachPoint = avatar.GetAttachPoint(avatarAttachPointName);

            CopyTransformLocalProperties(from, attachPoint);
        }
Пример #5
0
        private static Transform AttachPartToAttachPoint(IWeaponAttacher avatar, string partPath, string attachPoint, Transform protoTrans)
        {
            Transform  transform  = avatar.GetAttachPoint(attachPoint);
            GameObject gameObject = protoTrans.Find(partPath).gameObject;

            if (gameObject.GetComponent <MeshFilter>() == null)
            {
                transform.GetComponent <MeshFilter>().sharedMesh = null;
                return(transform);
            }
            transform.GetComponent <MeshFilter>().sharedMesh        = gameObject.GetComponent <MeshFilter>().sharedMesh;
            transform.GetComponent <MeshRenderer>().sharedMaterials = gameObject.GetComponent <MeshRenderer>().sharedMaterials;
            return(transform);
        }
Пример #6
0
 public static void MeiDetachHandler(ConfigWeaponAttach config, IWeaponAttacher mei, string avatarType)
 {
     if ((avatarType == "Mei_C1_DH") || (avatarType == "Mei_C3_WS"))
     {
         DetachWeaponAttachPoint(mei, "WeaponRightHand");
         DeleteAttachPointChildren(mei, "WeaponRightHand", true);
     }
     else if ((avatarType == "Mei_C2_CK") || (avatarType == "Mei_C4_LD"))
     {
         DetachWeaponAttachPoint(mei, "WeaponLeftHand");
         DetachWeaponAttachPoint(mei, "WeaponRightHand");
         DeleteAttachPointChildren(mei, "WeaponLeftHand", true);
         DeleteAttachPointChildren(mei, "WeaponRightHand", true);
     }
 }
Пример #7
0
        private static void DeleteAttachPointChildren(IWeaponAttacher avatar, string attachPoint, bool onlyMeshChild = true)
        {
            Transform transform = avatar.GetAttachPoint(attachPoint);
            int       index     = 0;

            while (transform.childCount > index)
            {
                if (onlyMeshChild && (transform.GetChild(index).GetComponent <MeshRenderer>() == null))
                {
                    index++;
                }
                else
                {
                    UnityEngine.Object.DestroyImmediate(transform.GetChild(index).gameObject);
                }
            }
        }
Пример #8
0
 public static void AttachWeaponMesh(ConfigWeapon weaponConfig, IWeaponAttacher avatar, Transform weaponProtoTrans, string avatarType)
 {
     weaponConfig.Attach.GetAttachHandler()(weaponConfig.Attach, weaponProtoTrans, avatar, avatarType);
 }
Пример #9
0
 public static Transform[] MeiAttachHandler(ConfigWeaponAttach config, Transform weaponProtoTrans, IWeaponAttacher mei, string avatarType)
 {
     Transform[] transformArray;
     if ((avatarType == "Mei_C1_DH") || (avatarType == "Mei_C3_WS"))
     {
         DeleteAttachPointChildren(mei, "WeaponRightHand", false);
         transformArray = new Transform[] { AttachPartToAttachPoint(mei, "LongSword", "WeaponRightHand", weaponProtoTrans) };
         InstantiateChildrenAndAttach(weaponProtoTrans.Find("LongSword"), transformArray[0], false);
         return(transformArray);
     }
     if ((avatarType == "Mei_C2_CK") || (avatarType == "Mei_C4_LD"))
     {
         DeleteAttachPointChildren(mei, "WeaponLeftHand", false);
         DeleteAttachPointChildren(mei, "WeaponRightHand", false);
         transformArray = new Transform[] { AttachPartToAttachPoint(mei, "ShortSword", "WeaponLeftHand", weaponProtoTrans), AttachPartToAttachPoint(mei, "ShortSword", "WeaponRightHand", weaponProtoTrans) };
         InstantiateChildrenAndAttach(weaponProtoTrans.Find("ShortSword"), transformArray[0], false);
         InstantiateChildrenAndAttach(weaponProtoTrans.Find("ShortSword"), transformArray[1], false);
         return(transformArray);
     }
     return(new Transform[0]);
 }
Пример #10
0
 public static Transform[] KianaAttachHandler(ConfigWeaponAttach config, Transform weaponProtoTrans, IWeaponAttacher kiana, string avatarType)
 {
     DeleteAttachPointChildren(kiana, "WeaponLeftHand", true);
     DeleteAttachPointChildren(kiana, "WeaponRightHand", true);
     Transform[] transformArray = new Transform[] { AttachPartToAttachPoint(kiana, "LeftPistol", "WeaponLeftHand", weaponProtoTrans), AttachPartToAttachPoint(kiana, "RightPistol", "WeaponRightHand", weaponProtoTrans) };
     InstantiateChildrenAndAttach(weaponProtoTrans.Find("LeftPistol"), transformArray[0], true);
     InstantiateChildrenAndAttach(weaponProtoTrans.Find("RightPistol"), transformArray[1], true);
     MoveAvatarAttachPoint(kiana, "LeftPistol/LeftGunPoint", "LeftGunPoint", weaponProtoTrans);
     MoveAvatarAttachPoint(kiana, "RightPistol/RightGunPoint", "RightGunPoint", weaponProtoTrans);
     return(transformArray);
 }
Пример #11
0
 public static void HimekoDetachHandler(ConfigWeaponAttach config, IWeaponAttacher himeko, string avatarType)
 {
     DetachWeaponAttachPoint(himeko, "WeaponRightHand");
     DeleteAttachPointChildren(himeko, "WeaponRightHand", true);
 }
Пример #12
0
 /// <summary>
 /// Constructor for a RobotFactory that sets
 /// the <see cref="IPainter"/> and <see cref="IWeaponAttacher"/> implementing
 /// objects on this type (all factories can paint/arm robots).
 /// </summary>
 /// <param name="paintMachineToUse">An <see cref="IPainter"/> implementing object for this factory to paint robots.</param>
 /// <param name="weaponAttacherMachineToUse">An <see cref="IWeaponAttacher"/> implementing object for this factory to arm robots.</param>
 public RobotFactory(IPainter paintMachineToUse, IWeaponAttacher weaponAttacherMachineToUse)
 {
     Robots                = new List <IRobot>();
     paintMachine          = paintMachineToUse;
     weaponAttacherMachine = weaponAttacherMachineToUse;
 }
Пример #13
0
 public static void FukaDetachHandler(ConfigWeaponAttach config, IWeaponAttacher fuka, string avatarType)
 {
     DetachWeaponAttachPoint(fuka, "WeaponTail");
     DeleteAttachPointChildren(fuka, "WeaponTail", true);
 }
Пример #14
0
 public static Transform[] FukaAttachHandler(ConfigWeaponAttach config, Transform weaponProtoTrans, IWeaponAttacher fuka, string avatarType)
 {
     DeleteAttachPointChildren(fuka, "WeaponTail", true);
     Transform[] transformArray = new Transform[] { AttachPartToAttachPoint(fuka, "Tail", "WeaponTail", weaponProtoTrans) };
     InstantiateChildrenAndAttach(weaponProtoTrans.Find("Tail"), transformArray[0], true);
     return(transformArray);
 }
Пример #15
0
        public static Transform[] BronyaAttachHandler(ConfigWeaponAttach config, Transform weaponProtoTrans, IWeaponAttacher bronya, string avatarType)
        {
            Transform[] transformArray = new Transform[2];
            DeleteAttachPointChildren(bronya, "WeaponLeftArmIn", true);
            DeleteAttachPointChildren(bronya, "WeaponLeftArmOut", true);
            transformArray[0] = AttachPartToAttachPoint(bronya, "GunIn", "WeaponLeftArmIn", weaponProtoTrans);
            transformArray[1] = AttachPartToAttachPoint(bronya, "GunOut", "WeaponLeftArmOut", weaponProtoTrans);
            InstantiateChildrenAndAttach(weaponProtoTrans.Find("GunIn"), transformArray[0], true);
            InstantiateChildrenAndAttach(weaponProtoTrans.Find("GunOut"), transformArray[1], true);
            Material[] sharedMaterials = bronya.gameObject.transform.Find("MC_Body").GetComponent <Renderer>().sharedMaterials;
            Material   targetMaterial  = null;

            foreach (Material material2 in sharedMaterials)
            {
                if (material2.shader.name == "miHoYo/Character/Machine")
                {
                    targetMaterial = material2;
                    break;
                }
            }
            if (targetMaterial != null)
            {
                BronyaCopyMcBodyMaterial(targetMaterial, transformArray[0]);
                BronyaCopyMcBodyMaterial(targetMaterial, transformArray[1]);
            }
            int layer = LayerMask.NameToLayer("Weapon");

            SetRendererLayer(transformArray[0], layer);
            SetRendererLayer(transformArray[1], layer);
            MoveAvatarAttachPoint(bronya, "GunIn/GunPointAttach", "GunPoint", weaponProtoTrans);
            bronya.gameObject.GetComponent <Animator>().Rebind();
            return(transformArray);
        }
Пример #16
0
 public static Transform[] HimekoAttachHandler(ConfigWeaponAttach config, Transform weaponProtoTrans, IWeaponAttacher himeko, string avatarType)
 {
     DeleteAttachPointChildren(himeko, "WeaponRightHand", true);
     Transform[] transformArray = new Transform[] { AttachPartToAttachPoint(himeko, "Sword", "WeaponRightHand", weaponProtoTrans) };
     InstantiateChildrenAndAttach(weaponProtoTrans.Find("Sword"), transformArray[0], true);
     return(transformArray);
 }
Пример #17
0
 /// <summary>
 /// Constructor for a LargeRobotFactory that passes
 /// the <see cref="IPainter"/> and <see cref="IWeaponAttacher"/> implementing
 /// object to the base class (all factories can paint/arm robots).
 /// </summary>
 /// <param name="paintMachineToUse">An <see cref="IPainter"/> implementing object for this factory to paint robots.</param>
 /// <param name="weaponAttacherMachineToUse">An <see cref="IWeaponAttacher"/> implementing object for this factory to arm robots.</param>
 public LargeRobotFactory(IPainter paintMachineToUse, IWeaponAttacher weaponAttacherMachineToUse)
     : base(paintMachineToUse, weaponAttacherMachineToUse)
 {
 }