예제 #1
0
    private void Start()
    {
        zoneDetection = GetComponentInChildren <ZoneDetection>();

        boat = GetComponent <Boat>();
        if (boat.Direction().Equals(Vector3.left))
        {
            float pos = zoneDetection.transform.localPosition.x;
            zoneDetection.transform.localPosition = new Vector3(-pos, transform.position.y, 0f);
        }
        zoneDetection.Init();
    }
예제 #2
0
    void Create()
    {
        characters = GameObject.Find("Characters");
        if (characters == null)
        {
            characters = new GameObject("Characters");
        }

        if (characts[0] != null)
        {
            if (characters.transform.FindChild(Wname) == null)
            {
                for (int i = 0; i < characts.Count; i++)
                {
                    if (characts[i] != null)
                    {
                        Asset.Add(Instantiate(characts[i]) as GameObject);
                        Asset[i].transform.parent   = characters.transform;
                        Asset[i].transform.position = posNPC;
                        string nameA = Asset[i].name;
                        if (nameA.Contains("(Clone)"))
                        {
                            nameA = nameA.Replace("(Clone)", "");
                        }
                        Asset[i].name = Wname + "_" + nameA;

                        /*character = Instantiate(PrefabNPC) as GameObject;
                         * character.name = Wname;
                         * character.transform.parent = characters.transform;
                         * character.transform.position = posNPC; */
                        AddTag("Character");
                        Asset[i].tag = "Character";
                        if (Asset[i].GetComponent("CapsuleCollider") == null)
                        {
                            zone = Asset[i].AddComponent("CapsuleCollider") as CapsuleCollider;
                        }
                        else
                        {
                            zone = Asset[i].GetComponent("CapsuleCollider") as CapsuleCollider;
                        }
                        zone.radius    = 1;
                        zone.isTrigger = false;
                        zone.height    = 2.5f;
                        if (Asset[i].GetComponent("Entity") == null)
                        {
                            entity = Asset[i].AddComponent("Entity") as Entity;
                        }
                        else
                        {
                            entity = Asset[i].GetComponent("Entity") as Entity;
                        }
                        entity.prototype = Pname;
                        if (Asset[i].GetComponent("EnableLife") == null)
                        {
                            ELife = Asset[i].AddComponent("EnableLife") as EnableLife;
                        }
                        else
                        {
                            ELife = Asset[i].GetComponent("EnableLife") as EnableLife;
                        }
                        ELife.wait = delay;
                        if (Asset[i].GetComponent("LifeSceneRoleNames") == null)
                        {
                            Asset[i].AddComponent("LifeSceneRoleNames");
                        }
                        if (Asset[i].GetComponent("ZoneDetection") == null)
                        {
                            ZDec = Asset[i].AddComponent("ZoneDetection") as ZoneDetection;
                        }
                        else
                        {
                            ZDec = Asset[i].GetComponent("ZoneDetection") as ZoneDetection;
                        }
                        ZDec.useTrigger = true;
                        if (Asset[i].GetComponent("InteractionDetection") == null)
                        {
                            Asset[i].AddComponent("InteractionDetection");
                        }
                        if (Asset[i].GetComponent("NavMeshAgent") == null)
                        {
                            Asset[i].AddComponent("NavMeshAgent");
                        }
                        if (Asset[i].GetComponent("Rigidbody") == null)
                        {
                            Asset[i].AddComponent("Rigidbody");
                        }

                        /*if(NPCAnimator != "" && character.GetComponent(NPCAnimator) == null)
                         *      character.AddComponent(NPCAnimator);*/
                        if (Asset[i].GetComponentInChildren <SphereCollider>() == null)
                        {
                            SmartZone = new GameObject("SmartZone");
                            SmartZone.transform.parent = Asset[i].transform;
                            if (SmartZone.GetComponent("SphereCollider") == null)
                            {
                                smartZ = SmartZone.AddComponent("SphereCollider") as SphereCollider;
                            }
                            else
                            {
                                smartZ = SmartZone.GetComponent("SphereCollider") as SphereCollider;
                            }
                            smartZ.radius    = 1;
                            smartZ.isTrigger = true;
                        }

                        if (Asset[i].GetComponentInChildren <MessageDisplayer>() == null)
                        {
                            SpeechBubble = new GameObject("SpeechBubble");
                            SpeechBubble.transform.parent = Asset[i].transform;
                            if (SpeechBubble.GetComponent("MessageDisplayer") == null)
                            {
                                SpeechBubble.AddComponent("MessageDisplayer");
                            }
                            if (SpeechBubble.GetComponent("AutoFacingCam") == null)
                            {
                                SpeechBubble.AddComponent("AutoFacingCam");
                            }
                        }
                    }
                }
            }

            if (Wname != "" && Wname != " ")
            {
                EditorGUIUtility.PingObject(Asset[0]);
                Selection.activeGameObject = Asset[0];

                this.Close();
                Selection.activeGameObject.GetComponent <Entity>();
            }
        }
    }
예제 #3
0
 private void OnDisable()
 {
     zoneDetection = GetComponentInChildren <ZoneDetection>();
     Reset();
 }
예제 #4
0
    void Create()
    {
        characters = GameObject.Find("Characters");
        if(characters == null)
            characters = new GameObject("Characters");

        if (characts[0] != null)
        {
            if(characters.transform.FindChild(Wname) == null){
                for (int i = 0; i < characts.Count; i++)
                {
                    if (characts[i] != null)
                    {
                        Asset.Add(Instantiate(characts[i]) as GameObject);
                        Asset[i].transform.parent = characters.transform;
                        Asset[i].transform.position = posNPC;
                        string nameA = Asset[i].name;
                        if (nameA.Contains("(Clone)"))
                            nameA = nameA.Replace("(Clone)", "");
                        Asset[i].name = Wname + "_" + nameA;

                        /*character = Instantiate(PrefabNPC) as GameObject;
                        character.name = Wname;
                        character.transform.parent = characters.transform;
                        character.transform.position = posNPC; */
                        AddTag("Character");
                        Asset[i].tag = "Character";
                        if (Asset[i].GetComponent("CapsuleCollider") == null)
                            zone = Asset[i].AddComponent("CapsuleCollider") as CapsuleCollider;
                        else
                            zone = Asset[i].GetComponent("CapsuleCollider") as CapsuleCollider;
                        zone.radius = 1;
                        zone.isTrigger = false;
                        zone.height = 2.5f;
                        if (Asset[i].GetComponent("Entity") == null)
                            entity = Asset[i].AddComponent("Entity") as Entity;
                        else
                            entity = Asset[i].GetComponent("Entity") as Entity;
                        entity.prototype = Pname;
                        if (Asset[i].GetComponent("EnableLife") == null)
                            ELife = Asset[i].AddComponent("EnableLife") as EnableLife;
                        else
                            ELife = Asset[i].GetComponent("EnableLife") as EnableLife;
                        ELife.wait = delay;
                        if (Asset[i].GetComponent("LifeSceneRoleNames") == null)
                            Asset[i].AddComponent("LifeSceneRoleNames");
                        if (Asset[i].GetComponent("ZoneDetection") == null)
                            ZDec = Asset[i].AddComponent("ZoneDetection") as ZoneDetection;
                        else
                            ZDec = Asset[i].GetComponent("ZoneDetection") as ZoneDetection;
                        ZDec.useTrigger = true;
                        if (Asset[i].GetComponent("InteractionDetection") == null)
                            Asset[i].AddComponent("InteractionDetection");
                        if (Asset[i].GetComponent("NavMeshAgent") == null)
                            Asset[i].AddComponent("NavMeshAgent");
                        if (Asset[i].GetComponent("Rigidbody") == null)
                            Asset[i].AddComponent("Rigidbody");
                        /*if(NPCAnimator != "" && character.GetComponent(NPCAnimator) == null)
                            character.AddComponent(NPCAnimator);*/
                        if (Asset[i].GetComponentInChildren<SphereCollider>() == null)
                        {
                            SmartZone = new GameObject("SmartZone");
                            SmartZone.transform.parent = Asset[i].transform;
                            if(SmartZone.GetComponent("SphereCollider") == null)
                                smartZ = SmartZone.AddComponent("SphereCollider") as SphereCollider;
                            else
                                smartZ = SmartZone.GetComponent("SphereCollider") as SphereCollider;
                            smartZ.radius = 1;
                            smartZ.isTrigger = true;
                        }

                        if (Asset[i].GetComponentInChildren<MessageDisplayer>() == null)
                        {
                            SpeechBubble = new GameObject("SpeechBubble");
                            SpeechBubble.transform.parent = Asset[i].transform;
                            if(SpeechBubble.GetComponent("MessageDisplayer") == null)
                                SpeechBubble.AddComponent("MessageDisplayer");
                            if(SpeechBubble.GetComponent("AutoFacingCam") == null)
                                SpeechBubble.AddComponent("AutoFacingCam");
                        }
                    }
                }
            }

            if(Wname != "" && Wname != " "){
                EditorGUIUtility.PingObject(Asset[0]);
                Selection.activeGameObject = Asset[0];

                this.Close();
                Selection.activeGameObject.GetComponent<Entity>();
            }
         }
    }