Пример #1
0
    void Start()
    {
        this.player = (Player)GameObject.FindGameObjectWithTag("Player").GetComponent("Player");

        this.eventService = (EventService)this.gameObject.GetComponent("EventService");
        this.eventService.successResponseHandler = new WebService.SuccessResponseHandler(this.HandleSendEventsSuccess);

        this.roomService = (RoomService)this.gameObject.GetComponent("RoomService");

        if (PlayerPrefs.HasKey("avatar"))
        {
            Debug.Log(PlayerPrefs.GetString("avatar"));

            AvatarModel avatar = JsonMapper.ToObject <AvatarModel>(PlayerPrefs.GetString("avatar"));

            if (avatar != null)
            {
                this.player.AvatarId = avatar.avatar_id;
                this.player.Name     = avatar.label;
                this.player.XP       = avatar.GetAttributeValue("xp");
                this.player.HP       = avatar.GetAttributeValue("hp");
            }
        }
        else
        {
            Debug.LogWarning("Started game with no avatar data.");
        }

        if (this.roomId != 0)
        {
            this.roomService.successResponseHandler = new WebService.SuccessResponseHandler(this.PopulateRoomContainers);
            this.roomService.GetRoom(this.roomId);
        }
    }