Exemplo n.º 1
0
    public void initRoomInfo()
    {
        Dictionary <string, constant.Direction> dic = new Dictionary <string, constant.Direction>();

        dic.Add("UpRoom", constant.Direction.south);
        dic.Add("DownRoom", constant.Direction.north);
        dic.Add("LeftRoom", constant.Direction.east);
        dic.Add("RightRoom", constant.Direction.west);

        roominfo        roomInfo  = mMapInfo.getCurRoom();
        List <doorinfo> doorinfos = roomInfo.mDoorInfos;

        foreach (KeyValuePair <string, constant.Direction> pair in dic)
        {
            GameObject[] objs = GameObject.FindGameObjectsWithTag(pair.Key);
            if (objs != null)
            {
                foreach (GameObject obj in objs)
                {
                    char_enter_script com = obj.GetComponent <char_enter_script>();
                    com.mDir = pair.Value;

                    //Debug.Log("obj:" + obj.name);

                    room_property pro = obj.GetComponent <room_property>();
                    //Debug.Log ("pro:" + pro.mX + "," + pro.mY + "," + (pro.mDoorInfo));
                    foreach (doorinfo info in doorinfos)
                    {
                        //Debug.Log ("info:" + info.mX + "," + info.mY);
                        if (pro.mX == info.mX && pro.mY == info.mY)
                        {
                            //Debug.Log("add roominfo");
                            pro.mDoorInfo = info;
                            //Debug.Log ("info:" + info);
                            //Debug.Log ("pro.mDoorInfo:" + pro.mDoorInfo.mX);
                            if (info.mNextRoomId != 0)
                            {
                                GameObject wall = obj.transform.parent.transform.Find("wall").gameObject;
                                wall.SetActive(false);
                            }
                        }
                    }
                }
            }
        }

        initRoomSceneInfo(roomInfo);
    }
 void OnTriggerEnter(Collider other)
 {
     //other.GetComponent
     //Debug.Log ("OnTriggerEnter "+other.gameObject.tag);
     //Debug.Log ("OnTriggerEnter " + other.gameObject.tag);
     if (other.gameObject.tag.Equals("Player"))
     {
         //Debug.Log ("player enter");
         //other.gameObject.rigidbody.velocity = new Vector3(0,0,0);
         //DontDestroyOnLoad(other.gameObject);
         //Application.LoadLevel(0);
         room_property pro = this.gameObject.GetComponent <room_property>();
         //Debug.Log("pro:" + pro);
         //Debug.Log("pro.mRoomInfo:" + pro.mDoorInfo);
         if (pro != null && pro.mDoorInfo.mId != 0)
         {
             constant.getMapLogic().enterRoom(this.gameObject, other.gameObject);
         }
     }
 }
Exemplo n.º 3
0
    public void openDoor()
    {
        GameObject[] doors = GameObject.FindGameObjectsWithTag("normalDoors");
        roominfo     info  = constant.getMapLogic().getCurRoom();

        //Debug.Log ("openDoor");
        foreach (GameObject door in doors)
        {
            GameObject    doorTouch = door.transform.parent.Find("door_touch").gameObject;
            room_property pro       = doorTouch.GetComponent <room_property>();
            if (pro.mDoorInfo != null && pro.mDoorInfo.hasNext() && info.mEnterDoorId != pro.mDoorInfo.mId)
            {
                tk2dSpriteAnimator ani = door.GetComponent <tk2dSpriteAnimator>();
                //Debug.Log("openDoor:" + door.name);
                BoxCollider box = ani.gameObject.GetComponent <BoxCollider> ();
                if (!box.isTrigger)
                {
                    ani.Play("open");
                    ani.AnimationCompleted = playOpenDoorAni;
                }
            }
        }
    }
Exemplo n.º 4
0
    public GameObject getDoorTouchObj(int doorId)
    {
        List <string> doornames = new List <string>();

        doornames.Add("UpRoom");
        doornames.Add("DownRoom");
        doornames.Add("LeftRoom");
        doornames.Add("RightRoom");

        foreach (string name in doornames)
        {
            GameObject[] objs = GameObject.FindGameObjectsWithTag(name);
            foreach (GameObject obj in objs)
            {
                room_property pro = obj.GetComponent <room_property>();
                if (pro.mDoorInfo.mId == doorId)
                {
                    return(obj);
                }
            }
        }

        return(null);
    }