Esempio n. 1
0
 public static Transform[] GetProps(Transform transf)
 {
     Transform[] result;
     if (!transf.name.ToLower().Contains("jiguan"))
     {
         Transform[] handsObj   = GameObjectPath.GetHandsObj(transf);
         Transform   transform  = (!(handsObj[0] == null)) ? handsObj[0].FindChild("Bip001 Prop2") : null;
         Transform   transform2 = (!(handsObj[1] == null)) ? handsObj[1].FindChild("Bip001 Prop1") : null;
         if (transform == null && handsObj[0] != null)
         {
             transform = handsObj[0].FindChild("[@b]");
         }
         result = new Transform[]
         {
             transform,
             transform2
         };
     }
     else
     {
         Transform transform3 = transf.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bone_Prop");
         result = new Transform[]
         {
             null,
             transform3
         };
     }
     return(result);
 }
Esempio n. 2
0
    public static Transform[] GetBoneProps(Transform transf)
    {
        Transform transform  = transf.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bone_Prop2/[@wuqi2]");
        Transform transform2 = transf.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bone_Prop1/[@wuqi1]");

        Transform[] array = null;
        if (transform != null || transform2 != null)
        {
            array = new Transform[]
            {
                transform,
                transform2
            };
        }
        else
        {
            Transform transform3 = transf.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bone_Prop");
            if (transform3 == null)
            {
                transform3 = transf.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bone_WuQiGuaZai/[@wuqi1]");
            }
            if (transform3 != null)
            {
                array = new Transform[]
                {
                    transform3
                };
            }
        }
        if (array == null)
        {
            array = GameObjectPath.GetProps(transf);
        }
        return(array);
    }
Esempio n. 3
0
    private void OnEnable()
    {
        if (base.GetComponent <CharacterController>())
        {
            return;
        }
        if (this.m_host == null)
        {
            return;
        }
        Transform transformByType = GameObjectPath.GetTransformByType <PalGameObjectBase>(base.transform);

        if (transformByType == null)
        {
            transformByType = GameObjectPath.GetTransformByType <Animator>(base.transform);
        }
        if (transformByType != null && this.m_host != null && this.m_host != transformByType)
        {
            this.InitHost();
            Transform parent = base.transform.parent;
            if (parent != null)
            {
                Collider component = parent.GetComponent <Collider>();
                if (component != null)
                {
                    parent.gameObject.layer = 17;
                }
            }
            if (this.m_host.GetComponent <PalNPC>() != null && base.GetComponent <Collider>())
            {
                base.GetComponent <Collider>().isTrigger = true;
            }
        }
    }
Esempio n. 4
0
    public virtual bool Save(BinaryWriter writer)
    {
        string path = GameObjectPath.GetPath(base.transform);

        writer.Write(path);
        this.SaveTranData(writer);
        this.SaveTargetData(writer);
        return(true);
    }
Esempio n. 5
0
    public static Transform[] GetTakePoint(Transform transf)
    {
        Transform[] handsObj   = GameObjectPath.GetHandsObj(transf);
        Transform   transform  = (!(handsObj[0] == null)) ? handsObj[0].FindChild("[@b]") : null;
        Transform   transform2 = (!(handsObj[1] == null)) ? handsObj[1].FindChild("[@a]") : null;

        return(new Transform[]
        {
            transform,
            transform2
        });
    }
Esempio n. 6
0
    public void Init(PalNPC npc)
    {
        if (npc == null)
        {
            return;
        }
        this.myTransform = base.transform;
        this.npc         = npc;
        this._host       = npc.transform;
        PerceptionDate perceptionDate = GameObjectPath.FindSpecParent(base.transform, typeof(PerceptionDate)) as PerceptionDate;

        if (perceptionDate != null)
        {
            this.RangeWidthAngle = perceptionDate.RangeWidthAngle;
            this.watchDistance   = perceptionDate.watchDistance;
            this.listenRadius    = perceptionDate.listenRadius;
            UnityEngine.Object.Destroy(perceptionDate);
        }
        npc.perception = this;
        GameObject model = npc.model;

        if (model != null)
        {
            Agent component = model.GetComponent <Agent>();
            component.perception = this;
            this.modelTF         = model.transform;
        }
        int characterID = npc.Data.CharacterID;

        if (characterID < 8 && characterID != 6)
        {
            this.prosInterval    = 0.07f;
            this.watchDistance   = 15f;
            this.RangeWidthAngle = 27f;
        }
        if (this.relayP < 0.01f)
        {
            this.relayP = 0.01f;
        }
        this.IgnoreLayer      = 2;
        this.IgnoreMask       = (1 << this.IgnoreLayer | 131072 | 262144 | 256);
        this.IgnoreMask       = ~this.IgnoreMask;
        base.gameObject.layer = this.IgnoreLayer;
        this.InitFrustumMesh();
        this.InitRange();
        this.lastTime     = Time.realtimeSinceStartup;
        this.bShowFrustum = false;
        this.bActive      = true;
        base.enabled      = true;
    }
Esempio n. 7
0
 public static Transform SearchSubNode(Transform target, string name)
 {
     if (target.name == name)
     {
         return(target);
     }
     for (int i = 0; i < target.childCount; i++)
     {
         Transform transform = GameObjectPath.SearchSubNode(target.GetChild(i), name);
         if (transform != null)
         {
             return(transform);
         }
     }
     return(null);
 }
Esempio n. 8
0
    private void InitHost()
    {
        Transform transformByType = GameObjectPath.GetTransformByType <PalGameObjectBase>(base.transform);

        if (transformByType != null)
        {
            this.m_host = transformByType.transform;
        }
        else
        {
            this.m_host = GameObjectPath.GetTransformByType <Animator>(base.transform);
        }
        if (this.m_host == null)
        {
            this.m_host = base.transform;
        }
    }
Esempio n. 9
0
    public virtual void ClearPrefab()
    {
        if (base.transform == null)
        {
            return;
        }
        string path = GameObjectPath.GetPath(base.transform);

        for (int i = 0; i < this.prefabObjs.Count; i++)
        {
            UnityEngine.Object @object = this.prefabObjs[i];
            if (@object != null)
            {
                Resources.UnloadAsset(@object);
            }
        }
        this.prefabObjs.Clear();
    }
Esempio n. 10
0
    protected virtual void SaveTranData(BinaryWriter writer)
    {
        Transform transform = base.gameObject.GetModelObj(false).transform;

        try
        {
            writer.Write(transform.position.x);
            writer.Write(transform.position.y);
            writer.Write(transform.position.z);
            writer.Write(transform.rotation.w);
            writer.Write(transform.rotation.x);
            writer.Write(transform.rotation.y);
            writer.Write(transform.rotation.z);
            writer.Write(transform.gameObject.activeSelf);
        }
        catch (Exception ex)
        {
            string path = GameObjectPath.GetPath(base.transform);
            Debug.LogError("Error : " + path + " " + ex.ToString());
        }
    }
Esempio n. 11
0
    private void InitRange()
    {
        Transform transformByType = GameObjectPath.GetTransformByType <Animator>(base.transform);

        if (transformByType == null)
        {
            Debug.LogError(this.myTransform.name + "往上面没有找到 Animator");
            return;
        }
        this.range = transformByType.FindChild("Range");
        if (this.range == null)
        {
            this.range = new GameObject("Range")
            {
                transform =
                {
                    parent = transformByType
                }
            }.transform;
        }
        SphereCollider sphereCollider = this.range.GetComponent <SphereCollider>();

        if (sphereCollider == null)
        {
            sphereCollider = this.range.gameObject.AddComponent <SphereCollider>();
        }
        sphereCollider.radius    = (this.watchDistance + this.listenRadius) / 2f;
        sphereCollider.isTrigger = true;
        this.range.localPosition = new Vector3(0f, 0f, this.watchDistance - sphereCollider.radius);
        this.perceptionRange     = this.range.GetComponent <PerceptionRange>();
        if (this.perceptionRange == null)
        {
            this.perceptionRange = this.range.gameObject.AddComponent <PerceptionRange>();
        }
        this.perceptionRange.perception = this;
        this.range.gameObject.layer     = this.IgnoreLayer;
    }
Esempio n. 12
0
    public static Transform GetHeadProp(Transform transf)
    {
        Transform headObj = GameObjectPath.GetHeadObj(transf);

        return((!(headObj == null)) ? headObj.Find("[@h]") : null);
    }
Esempio n. 13
0
    private void Update()
    {
        if (!this.bActive)
        {
            base.enabled = false;
            return;
        }
        this.curInterval -= Time.deltaTime;
        float num = Time.realtimeSinceStartup - this.lastTime - this.HighLevelP;

        //if (num > PalMain.MinDeltaTime)
        //{
        //	this.lastTime = Time.realtimeSinceStartup;
        //	this.HighLevelP += this.relayP;
        //	return;
        //}
        this.HighLevelP = 0f;
        this.lastTime   = Time.realtimeSinceStartup;
        if (this.curInterval < 0f)
        {
            this.curInterval = this.prosInterval;
            if (this.targetsCanBePercept.Count > 0)
            {
                bool flag = false;
                foreach (KeyValuePair <Transform, List <PerceptionTarget> > current in this.targetsCanBePercept)
                {
                    Transform key = current.Key;
                    if (key == null)
                    {
                        Transform transformByType = GameObjectPath.GetTransformByType <Agent>(base.transform);
                        if (transformByType != null)
                        {
                            Debug.LogWarning(transformByType.name + " 没有找到 目标宿主 进行一次情况");
                        }
                        flag = true;
                        break;
                    }
                    bool flag2 = false;
                    foreach (PerceptionTarget current2 in current.Value)
                    {
                        if (!(current2 == null))
                        {
                            if (this.IsExsitInFrustum(current2.transform) && this.IsCanSeen(current2))
                            {
                                flag2 = true;
                                break;
                            }
                        }
                    }
                    if (flag2)
                    {
                        if (!this.hostsCanBeSeen.Contains(key))
                        {
                            this.hostsCanBeSeen.Add(key);
                            if (this.OnBeSeenEvent != null)
                            {
                                this.OnBeSeenEvent(key);
                            }
                            this.SendMessageToUScript(key, true);
                        }
                    }
                    else if (this.hostsCanBeSeen.Contains(key))
                    {
                        this.hostsCanBeSeen.Remove(key);
                        if (this.OnBeNotSeenEvent != null)
                        {
                            this.OnBeNotSeenEvent(key);
                        }
                        this.SendMessageToUScript(key, false);
                    }
                    int num2 = this.hostsCanBeListened.IndexOf(key);
                    if (this.IsExsitInListenRange(key))
                    {
                        if (num2 < 0)
                        {
                            this.hostsCanBeListened.Add(key);
                        }
                    }
                    else if (num2 > -1)
                    {
                        this.hostsCanBeListened.RemoveAt(num2);
                    }
                }
                if (flag)
                {
                    this.targetsCanBePercept.Clear();
                }
            }
            else
            {
                this.hostsCanBeSeen.Clear();
                this.hostsCanBeListened.Clear();
            }
        }
        if (this.bShowFrustum && this.meshRenderer != null && this.meshRenderer.material != null)
        {
            Vector3 position = this.myTransform.position;
            this.meshRenderer.material.SetFloat("_Distance", this.watchDistance);
            this.meshRenderer.material.SetVector("_ObjPos", new Vector4(position.x, position.y, position.z, 1f));
        }
        if (this.bShowFrustum != this.meshRenderer.enabled)
        {
            this.meshRenderer.enabled = this.bShowFrustum;
        }
    }