Exemple #1
0
    bool Match(AiObject aiObj)
    {
        //if (aiObj == null || !aiObj.isActive || aiObj.enemy != null || aiObj.dead)
        //    return false;

        return(AiUtil.GetChild(aiObj.transform, "faece") != null);
    }
Exemple #2
0
    public void InstantiateEffect(int effId, Transform caster, Transform target = null, EffectInstantiateCompleted OnInstantiated = null)
    {
        EffCastData data = EffCastData.GetEffCastData(effId);

        if (data == null)
        {
            return;
        }

        Transform tr = null;

        if (string.IsNullOrEmpty(data.m_posStr) || data.m_posStr.Equals("0"))
        {
            tr = caster;
        }
        else
        {
            tr = AiUtil.GetChild(caster, data.m_posStr);
        }

        if (tr == null)
        {
            return;
        }

        Transform parent = data.m_bind ? tr : null;

        Instantiate(effId, tr, parent, target, OnInstantiated);
    }
 bool CheckBones()
 {
     if (null == LeftFootBone)
     {
         LeftFootBone = AiUtil.GetChild(transform, "Bip01 L Foot");
     }
     if (null == RightFootBone)
     {
         RightFootBone = AiUtil.GetChild(transform, "Bip01 R Foot");
     }
     return(null != LeftFootBone && null != RightFootBone);
 }
Exemple #4
0
    void Start()
    {
        // Add player's own layer to mask
        mask = 1 << gameObject.layer;
        // Add Igbore Raycast layer to mask
        mask |= 1 << LayerMask.NameToLayer("Ignore Raycast");
        // Invert mask
        mask = ~mask;

        armIKSrcLeft  = AiUtil.GetChild(transform, "IKHandLeft");
        armIKSrcRight = AiUtil.GetChild(transform, "IKHandRight");

        localPosition = aimWeapon.localPosition;
        localRotation = aimWeapon.localRotation;
        distance      = Vector3.Distance(aimPivot.position, aimWeapon.position);
    }
    void Copy()
    {
        if (source == null || target == null)
        {
            return;
        }

        CopySerialized(source.transform, target.transform);

        Transform[] transforms = source.GetComponentsInChildren <Transform>();

        foreach (Transform tr in transforms)
        {
            CopySerialized(tr, AiUtil.GetChild(target.transform, tr.name));
        }
    }
 void Update()
 {
     CurrentTime += Time.deltaTime;
     if (m_root != null)
     {
         foreach (EffectDesc eff in Effect)
         {
             if (CurrentTime > eff.DelayTime)
             {
                 eff.m_effroot = AiUtil.GetChild(m_root, eff.Parent);
                 eff.Play();
             }
         }
     }
     else
     {
         Debug.LogError("Can't find the total parent or the model");
     }
 }
    void CopySerialized(Transform src, Transform tar)
    {
        if (src == null || tar == null)
        {
            return;
        }

        Rigidbody rigid = src.GetComponent <Rigidbody>();

        if (rigid != null)
        {
            Rigidbody rigid1 = tar.GetComponent <Rigidbody>();
            if (rigid1 == null)
            {
                rigid1 = tar.gameObject.AddComponent <Rigidbody>();
            }

            EditorUtility.CopySerialized(rigid, rigid1);
        }

        CapsuleCollider cap1 = src.GetComponent <CapsuleCollider>();

        if (cap1 != null)
        {
            CapsuleCollider cap2 = tar.GetComponent <CapsuleCollider>();
            if (cap2 == null)
            {
                cap2 = tar.gameObject.AddComponent <CapsuleCollider>();
            }
            EditorUtility.CopySerialized(cap1, cap2);

            cap2.center *= scale;
            cap2.radius *= scale;
            cap2.height *= scale;
        }

        SphereCollider s1 = src.GetComponent <SphereCollider>();

        if (s1 != null)
        {
            SphereCollider s2 = tar.GetComponent <SphereCollider>();
            if (s2 == null)
            {
                s2 = tar.gameObject.AddComponent <SphereCollider>();
            }
            EditorUtility.CopySerialized(s1, s2);

            s2.center *= scale;
            s2.radius *= scale;
        }

        BoxCollider box1 = src.GetComponent <BoxCollider>();

        if (box1 != null)
        {
            BoxCollider box2 = tar.GetComponent <BoxCollider>();
            if (box2 == null)
            {
                box2 = tar.gameObject.AddComponent <BoxCollider>();
            }
            EditorUtility.CopySerialized(box1, box2);

            box2.center *= scale;
            box2.size   *= scale;
        }

        CharacterJoint joint1 = src.GetComponent <CharacterJoint>();

        if (joint1 != null)
        {
            CharacterJoint joint2 = tar.GetComponent <CharacterJoint>();
            if (joint2 == null)
            {
                joint2 = tar.gameObject.AddComponent <CharacterJoint>();
            }
            EditorUtility.CopySerialized(joint1, joint2);

            joint2.connectedBody = AiUtil.GetChild(target.transform, joint2.connectedBody.name).GetComponent <Rigidbody>();
        }

        LegController leg1 = src.GetComponent <LegController>();

        if (leg1 != null)
        {
            LegController leg2 = tar.GetComponent <LegController>();
            if (leg2 == null)
            {
                leg2 = tar.gameObject.AddComponent <LegController>();
            }
            EditorUtility.CopySerialized(leg1, leg2);

            leg2.groundedPose = target.GetComponent <Animation>()[leg2.groundedPose.name].clip;
            leg2.rootBone     = AiUtil.GetChild(target.transform, leg2.rootBone.name);

            foreach (LegInfo leg in leg2.legs)
            {
                leg.ankle = AiUtil.GetChild(target.transform, leg.ankle.name);
                leg.hip   = AiUtil.GetChild(target.transform, leg.hip.name);
                leg.toe   = AiUtil.GetChild(target.transform, leg.toe.name);

                leg.footLength   *= scale;
                leg.footWidth    *= scale;
                leg.footOffset.x *= scale;
                leg.footOffset.y *= scale;
            }

            foreach (MotionAnalyzer motion in leg2.sourceAnimations)
            {
                motion.animation = target.GetComponent <Animation>()[motion.animation.name].clip;
            }
        }

        AlignmentTracker al1 = src.GetComponent <AlignmentTracker>();

        if (leg1 != null)
        {
            AlignmentTracker al2 = tar.GetComponent <AlignmentTracker>();
            if (al2 == null)
            {
                al2 = tar.gameObject.AddComponent <AlignmentTracker>();
            }
            EditorUtility.CopySerialized(al1, al2);
        }

        LegAnimator legA1 = src.GetComponent <LegAnimator>();

        if (legA1 != null)
        {
            LegAnimator legA2 = tar.GetComponent <LegAnimator>();
            if (legA2 == null)
            {
                legA2 = tar.gameObject.AddComponent <LegAnimator>();
            }
            EditorUtility.CopySerialized(legA1, legA2);
        }
    }