예제 #1
0
        private void OnExtensionResponse(BaseEvent e)
        {
            string    cmd  = (string)e.Params["cmd"];
            SFSObject data = (SFSObject)e.Params["params"];

            if (cmd == "gameisplaying")
            {
                if (data.ContainsKey("value"))
                {
                    _sfs.Send(new LeaveRoomRequest(_sfs.LastJoinedRoom));
                    _gameIsPlaying = (bool)data.GetBool("value");
                    _okButton.CMD(Consts.UI_CMD_ENABLE);
                    Tank myseft = (Tank)_network.GetMainTank();
                    if (!myseft.IsAlive())
                    {
                        myseft.ReGeneration();
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 初始化用户信息
        /// </summary>
        /// <param name="data"></param>
        public void Init(SFSObject data)
        {
            if (data == null)
            {
                return;
            }


            if (data.ContainsKey("User"))
            {
                User = data.GetUtfString("User");
            }
            if (data.ContainsKey("Id"))
            {
                Id = data.GetInt("Id");
            }
            if (data.ContainsKey("isMe"))
            {
                IsMe = data.GetBool("isMe");
            }
        }
    /**
     * Handle responses from server side Extension.
     */
    public void OnExtensionResponse(BaseEvent evt)
    {
        string    cmd        = (string)evt.Params["cmd"];
        SFSObject dataObject = (SFSObject)evt.Params["params"];

        switch (cmd)
        {
        case "start":
            StartGame(dataObject.GetInt("t"),
                      dataObject.GetInt("p1i"),
                      dataObject.GetInt("p2i"),
                      dataObject.GetUtfString("p1n"),
                      dataObject.GetUtfString("p2n")
                      );
            break;

        case "stop":
            UserLeft();
            break;

        case "move":
            MoveReceived(dataObject.GetFloat("x"),      // line coordinates
                         dataObject.GetFloat("y"),      //
                         dataObject.GetBool("d"),       // line direction
                         dataObject.GetInt("t"),        // player id
                         dataObject.GetFloat("xSq"),    // square coordinates
                         dataObject.GetFloat("ySq"),    //
                         dataObject.GetInt("s1"),       // player 1 score
                         dataObject.GetInt("s2")        // player 2 score
                         );
            break;

        case "win":
            ShowWinner(cmd, (int)dataObject.GetInt("w"));
            break;
        }
    }
예제 #4
0
 //end methods for send()
 //methods for responses
 private void SignUpResponse(SFSObject sfsdata)
 {
     bool success = sfsdata.GetBool("success");
     if (success) {
         OnEvent("register", "Registration successful, please check your email for further instructions.");
     } else {
         OnEvent("register", sfsdata.GetUtfString("errorMessage"));
     }
 }
예제 #5
0
 public void fromSFSObjectSinUS(SFSObject us)
 {
     this.id_sprint=us.GetLong("Id_Sprint");
     this.id_proyecto=us.GetLong("id_Proyecto");
     this.estado=us.GetUtfString("estado");
     this.fechaInicio=System.DateTime.Parse(us.GetUtfString("fechaInicio"));//new System.DateTime(us.GetLong ("fechaInicio"));
     this.fechaFin=System.DateTime.Parse(us.GetUtfString("fechaFin"));//new System.DateTime(us.GetLong ("fechaFin"));
     this.titulo=us.GetUtfString("titulo");
     this.cerrado = us.GetBool("cerrado");
     string s = us.GetUtfString ("fecha_ultimo_cambio");
     if(!s.Equals(""))
         this.fecha_ultimo_cambio = System.DateTime.Parse(s);
     Debug.Log (this.fecha_ultimo_cambio.ToString ());
 }
예제 #6
0
    public override void fromSFSObject(SFSObject item)
    {
        this.id_sprint=item.GetLong("Id_Sprint");
        this.id_proyecto=item.GetLong("id_Proyecto");
        this.estado=item.GetUtfString("estado");
        this.fechaInicio=System.DateTime.Parse(item.GetUtfString("fechaInicio"));//new System.DateTime(us.GetLong ("fechaInicio"));
        this.fechaFin=System.DateTime.Parse(item.GetUtfString("fechaFin"));//new System.DateTime(us.GetLong ("fechaFin"));
        this.titulo=item.GetUtfString("titulo");
        this.cerrado = item.GetBool("cerrado");
        string s = item.GetUtfString ("fecha_ultimo_cambio");
        if(!s.Equals(""))
            this.fecha_ultimo_cambio = System.DateTime.Parse(s);
        ISFSArray stories=item.GetSFSArray("listaStories");
        foreach(SFSObject story in stories)
        {
            UserStory UserStory=new UserStory();
            UserStory.fromSFSObject(story);

            listaStories.Add(UserStory);
        }
        Debug.Log (this.fecha_ultimo_cambio.ToString ());
    }
예제 #7
0
        private void OnExtensionResponse(BaseEvent e)
        {
            string    cmd  = (string)e.Params["cmd"];
            SFSObject data = (SFSObject)e.Params["params"];
            User      user = (User)e.Params["user"];

            try
            {
                if (cmd == Consts.CMD_IS_PRIMARY)
                {
                    _network.SetPrimary((int)data.GetShort(Consts.ROOM_ONWER));
                    _isEnablePlayButton = (_network.IsPrimary() == _sfs.MySelf.Id) ? true : false;
                    if (!_isEnablePlayButton)
                    {
                        _playButton.CMD(Consts.UI_CMD_DISABLE);
                    }
                    else
                    {
                        _readyButton.CMD(Consts.UI_CMD_DISABLE);
                        return;
                    }
                    //////////////// dis play ready state ////////////////
                    if (data.ContainsKey(Consts.READY_ARRAY) && data.ContainsKey(Consts.ID_ARRAY))
                    {
                        short[] id    = data.GetShortArray(Consts.ID_ARRAY);
                        bool[]  ready = data.GetBoolArray(Consts.READY_ARRAY);
                        for (int i = 0; i < id.Length; i++)
                        {
                            User userReady = _network.GetCurretRoom().GetUserById((int)id[i]);
                            if (userReady != null)
                            {
                                bool isOwner = (_network.IsPrimary() == userReady.Id) ? true : false;
                                _namePlates.Add(userReady, isOwner);
                                _namePlates.SetReady((int)id[i], ready[i]);
                            }
                        }
                    }
                    Debug.WriteLine("Is primary :" + _isEnablePlayButton);
                    return;
                }
                if (cmd == Consts.CMD_USER_READY)
                {
                    if (data.ContainsKey(Consts.CAN_PLAY))
                    {
                        if (_network.IsPrimary() == _sfs.MySelf.Id)
                        {
                            if (data.ContainsKey(Consts.MESSAGE))
                            {
                                Debug.WriteLine(data.GetUtfString(Consts.MESSAGE));
                            }
                        }
                        bool canPlay = data.GetBool(Consts.CAN_PLAY);
                        if (canPlay)
                        {
                            Game1.sceneManager.GotoScene(Consts.SCENE_PLAY);
                        }
                        return;
                    }
                    if (data.ContainsKey(Consts.ID_ARRAY) && data.ContainsKey(Consts.READY_ARRAY))
                    {
                        short[] id      = data.GetShortArray(Consts.ID_ARRAY);
                        bool[]  isReady = data.GetBoolArray(Consts.READY_ARRAY);
                        for (int i = 0; i < id.Length; i++)
                        {
                            _namePlates.SetReady((int)id[i], isReady[i]);
                        }
                    }
                    return;
                }
            }catch (Exception exp)
            {
                Debug.WriteLine(exp.ToString());
            }
        }
예제 #8
0
    public override void fromSFSObject(SFSObject item)
    {
        listaTareas = new ArrayList();
        listaEstimacion = new ArrayList();
        listaCriterios = new ArrayList ();
        this.id_UserStory=item.GetLong("id_UserStory");
        this.id_Sprint = item.GetLong ("Id_Sprint");
        this.descripcion=item.GetUtfString("descripcion");
        this.prioridad=item.GetInt("prioridad");
        this.titulo=item.GetUtfString("Titulo");
        this.estadoEstimacion=item.GetInt("estadoEstimacion");
        this.id_proyecto=item.GetLong("id_proyecto");
        string s = item.GetUtfString ("fecha_ultimo_cambio");
        this.cerrada = item.GetBool("cerrada");
        if(!s.Equals(""))
            this.fecha_ultimo_cambio = System.DateTime.Parse(s);
        this.valorEstimacion = item.GetFloat("valorEstimacion");
        ISFSArray tareas=item.GetSFSArray("listaTareas");

        foreach(SFSObject tarea in tareas)
        {
            Task task=new Task();
            task.fromSFSObject(tarea);

            listaTareas.Add(task);
        }
        ISFSArray estimaciones=item.GetSFSArray("listaEstimacion");

        foreach(SFSObject estimacion in estimaciones)
        {
            Estimacion est=new Estimacion();
            est.fromSFSObject(estimacion);
            listaEstimacion.Add(est);
        }

        ISFSArray criterios=item.GetSFSArray("listaCriterios");
        if(criterios !=null)
        foreach(SFSObject criteria in criterios)
        {
            AcceptanceCriteria ac=new AcceptanceCriteria();
            ac.fromSFSObject(criteria);
            listaCriterios.Add(ac);
        }
    }
예제 #9
0
 public static void HandleUpdatePlayerInfo(SFSObject message)
 {
     TetrisPlayer = message.GetBool ("tetrisPlayer");
     BreakoutPlayer = message.GetBool ("breakoutPlayer");
     PlatformPlayer = message.GetBool ("platformPlayer");
 }
예제 #10
0
    public static void HandleSoundObject(SFSObject message)
    {
        string sound = message.GetUtfString("sound");
        bool isPlay = message.GetBool("state");
        if (isPlay)
        {
            if (sound == "kick")
                kickS.Play ();
            else if (sound == "jump")
                jumpS.Play ();
            else if (sound == "surge")
                surgeS.Play ();
            else if (sound == "blink")
                blinkS.Play ();
            else if (sound == "blockMove")
                pieceMove.Play ();
            else if (sound == "lineClear")
                lineClear.Play ();
            else if (sound == "ballBounce")
                ballBounce.Play ();
            else if (sound == "brickHit")
                brickHit.Play ();
            else if (sound == "dead")
                charDeadS.Play ();

        }
        else
        {
            if (sound == "kick")
                kickS.Stop ();
            else if (sound == "jump")
                jumpS.Stop ();
            else if (sound == "surge")
                surgeS.Stop ();
            else if (sound == "blink")
                blinkS.Stop ();
            else if (sound == "blockMove")
                pieceMove.Stop ();
            else if (sound == "lineClear")
                lineClear.Stop ();
            else if (sound == "ballBounce")
                ballBounce.Stop ();
            else if (sound == "brickHit")
                brickHit.Stop ();
            else if (sound == "dead")
                charDeadS.Stop ();

        }

        //AudioClip ac = Resources.Load(sound_path) as AudioClip;

        //AudioSource.PlayClipAtPoint(ac, Camera.main.transform.position);
        //pieceMove = gameObject.AddComponent<AudioSource>();
        //pieceMove.clip = Resources.Load("Sounds/tetris_move") as AudioClip;
    }
예제 #11
0
    public static void HandleObjectUpdate(SFSObject message)
    {
        string type = message.GetUtfString ("objectType");
        float xPos = message.GetFloat ("xPos");
        float yPos = message.GetFloat ("yPos");
        float zPos = message.GetFloat ("zPos");
        float xRot = message.GetFloat ("xRot");
        float yRot = message.GetFloat ("yRot");
        float zRot = message.GetFloat ("zRot");

        float xDir = message.GetFloat ("xDir");
        float yDir = message.GetFloat ("yDir");
        float zDir = message.GetFloat ("zDir");

        int blockType = message.GetInt ("blockType");

        string[] cubeIDs = message.GetUtfStringArray ("cubeIDs");
        string id = message.GetUtfString ("ID");
        int animType = message.GetInt ("charAnim");

        float Speed = message.GetFloat ("Speed");
        bool Hit = message.GetBool ("Hit");
        bool Jump = message.GetBool ("Jump");

        Vector3 position = new Vector3 (xPos, yPos, zPos);
        Quaternion rotation = Quaternion.Euler(new Vector3(xRot, yRot, zRot));
        Vector3 forward = new Vector3 (xDir, yDir, zDir);

        switch (type) {
        case "Block":
            UpdateBlockObject(blockType, id, cubeIDs, position, rotation);
            break;

        case "Bar":
                UpdateBarObject(id, position, rotation);
            break;

        case "Ball":
                UpdateBallObject(id, position, rotation);
            break;

        case "Character":
            UpdateCharacterObject (id, (CharacterAnimType)animType, position, rotation, forward, Speed, Hit, Jump);
            break;
        }
    }