Esempio n. 1
0
 public void DropItemRight()
 {
     if (rightHandItem == null)
     {
         Debug.LogError("Trying drop item with empty hands");
         return;
     }
     rightHandItem.transform.SetParent(null, true);
     rightHandItem = null;
 }
Esempio n. 2
0
    public long uid;    //拾取玩家id -1为没有被拾取

    public static InGameItem Deserialize(DataStream reader)
    {
        InGameItem item = new InGameItem();

        item.id       = reader.ReadSInt32();
        item.showtime = reader.ReadSInt64();
        item.pos      = NetTools.VectorDeserialize(reader);
        item.confid   = reader.ReadSInt32();
        item.uid      = reader.ReadSInt64();
        return(item);
    }
Esempio n. 3
0
 public void PickItemRight(InGameItem item)
 {
     if (this.rightHandItem != null)
     {
         Debug.LogError("Trying to pick item with full hand");
         return;
     }
     this.rightHandItem = item;
     rightHandItem.transform.SetParent(GameObject.Find("B_R_Hand").transform, false);
     rightHandItem.transform.localPosition = new Vector3(0, 0, 0);
     rightHandItem.transform.localRotation = Quaternion.identity;
 }
Esempio n. 4
0
 void Awake()
 {
     items = new List <InGameItem>();
     foreach (var itm in startingItems)
     {
         if (itm != null)
         {
             GameObject newItem = GameObject.CreatePrimitive(PrimitiveType.Cube);
             newItem.name = "an item(" + itm.name + ")";
             newItem.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
             newItem.transform.SetParent(gameObject.transform);
             InGameItem newInGameItem = newItem.AddComponent <InGameItem>();
             newInGameItem.sourceItem = itm;
             items.Add(newInGameItem);
         }
     }
 }
Esempio n. 5
0
    void RoomResponse(Resp r)
    {
        RoomResp resp = (RoomResp)r;

        NetTools.Log("RoomResponse : " + resp.GetProtocol());
        NetTools.Log("==================RoomResponse type: " + resp.GetType());

        if (resp.GetType() == NetProtocols.ROOM_IN)
        {
            resp.GetRoomDate().Log();
        }
        else if (resp.GetType() == NetProtocols.ROOM_SHOW_RAND_ITEM)
        {
            InGameItem item = resp.GetInGameItem();
            item.Log();
        }

        if (resp.GetType() >= 10 && resp.GetType() <= 14)
        {
            NetTools.Log("============ROOM MODE : " + resp.GetType());
        }
    }
Esempio n. 6
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (m_bInvincible == false)
        {
            if (col.CompareTag("Obstacle"))
            {
                float fVal = Random.Range(0.0f, 1.0f);

                if (fVal > InGameManager.Instance.Character.Evade)
                {
                    InGameManager.Instance.Character.Hp--;
                    FlashImage();
                    InGameManager.Instance.CharacterHpChange(-1);
                }
                else
                {
                    FlashRed();
                }
            }
        }
        if (col.CompareTag("Item"))
        {
            InGameItem item = col.GetComponent <InGameItem>();
            InGameManager.Instance.ItemAcquire(item.Item.Type);
            if (item.Item.HpUp)
            {
                if (InGameManager.Instance.Character.Hp < InGameManager.Instance.Character.MaxHp)
                {
                    InGameManager.Instance.Character.Hp++;
                    InGameManager.Instance.CharacterHpChange(1);
                }
            }
            if (item.Item.SpeedUp)
            {
                InGameData.Instance.Speed += 20;
            }
        }
    }
Esempio n. 7
0
    public override void Deserialize(DataStream reader)
    {
        base.Deserialize(reader);
        type = reader.ReadSInt32();
        NetTools.Log("RoomResp : " + type);

        switch (type)
        {
        case NetProtocols.ROOM_IN:
            rd = new RoomData();
            rd.Deserialize(reader);
            DeserializePlayerList(reader);
            break;

        case NetProtocols.ROOM_LEAVE:

            break;

        case NetProtocols.ROOM_INPLAYER:
//			uid = reader.ReadSInt64();
//			uname = reader.ReadString16();

            pm = new InRoomPlayerManager();
            pm.Deserialize(reader);
            break;

        case NetProtocols.ROOM_OUTPLAYER:
            uid = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_SEL_MODE:
            uid    = reader.ReadSInt64();
            modeid = reader.ReadSInt32();
            break;

        case NetProtocols.ROOM_READY:
            time    = reader.ReadSInt64();
            levelid = reader.ReadSInt32();
            break;

        case NetProtocols.ROOM_HIDE:
            time = reader.ReadSInt64();
            DeserializePlayerList(reader);
            break;

        case NetProtocols.ROOM_FIND:
            time = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_OVER:
            time = reader.ReadSInt64();

            wintype = reader.ReadByte();
            int rewardcount = reader.ReadSInt32();

            for (int i = 0; i < rewardcount; i++)
            {
                rewardList.Add(reader.ReadSInt32());
            }
            break;

        case NetProtocols.ROOM_RESULT:
            time = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_WAIT:
            time = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_PLAYER_DIE:
            sourceid = reader.ReadSInt64();
            targetid = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_SHOW_RAND_ITEM:
            item = InGameItem.Deserialize(reader);
            break;

        case NetProtocols.ROOM_GET_RAND_ITEM:
            item = InGameItem.Deserialize(reader);
            break;

        case NetProtocols.ROOM_USE_ITEM:
            item     = InGameItem.Deserialize(reader);
            targetid = reader.ReadSInt64();
            break;

        case NetProtocols.ROOM_PLAYER_LIFE:
            uid  = reader.ReadSInt64();
            life = reader.ReadSInt32();
            break;
        }
    }