Exemplo n.º 1
0
        private void JustSetGpsData(UserInfoStruct userinfoStruct, ISFSObject userData)
        {
            if (userData.ContainsKey("ip"))
            {
                userinfoStruct.Ip = userData.GetUtfString("ip");
            }

            if (userData.ContainsKey("country"))
            {
                userinfoStruct.Country = userData.GetUtfString("country");
            }

            //获取gpsx; gpsy
            if ((userData.ContainsKey("gpsx") && userData.ContainsKey("gpsy")) ||
                (userData.ContainsKey("x") && userData.ContainsKey("y")))
            {
                userinfoStruct.GpsX = userData.ContainsKey("gpsx") ? userData.GetFloat("gpsx") : userData.GetFloat("x");
                userinfoStruct.GpsY = userData.ContainsKey("gpsy") ? userData.GetFloat("gpsy") : userData.GetFloat("y");
            }
            else
            {
                userinfoStruct.GpsX = -1f;
                userinfoStruct.GpsY = -1f;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置玩家GPS信息
        /// </summary>
        /// <param name="data"></param>
        public void CheckGpsInfo(ISFSObject data)
        {
            int userId = data.GetInt("uid");
            var users  = App.GetGameData <PaiJiuGameData>().PlayerList;

            for (int i = 0, max = users.Length; i < max; i++)
            {
                PaiJiuPlayer paiJiuPlayer = (PaiJiuPlayer)users[i];
                if (paiJiuPlayer == null)
                {
                    continue;
                }
                if (paiJiuPlayer.Info != null && paiJiuPlayer.Info.Id == userId && paiJiuPlayer.gameObject.activeInHierarchy)
                {
                    if ((data.ContainsKey("gpsx") && data.ContainsKey("gpsy")) || (data.ContainsKey("x") && data.ContainsKey("y")))
                    {
                        paiJiuPlayer.GpsX       = data.ContainsKey("gpsx") ? data.GetFloat("gpsx") : data.GetFloat("x");
                        paiJiuPlayer.GpsY       = data.ContainsKey("gpsy") ? data.GetFloat("gpsy") : data.GetFloat("y");
                        paiJiuPlayer.HasGpsInfo = true;

                        if (data.ContainsKey("country") && paiJiuPlayer.Info != null)
                        {
                            paiJiuPlayer.Info.Country = data.GetUtfString("country");
                        }
                    }
                    else
                    {
                        paiJiuPlayer.GpsX       = -1f;
                        paiJiuPlayer.GpsY       = -1f;
                        paiJiuPlayer.HasGpsInfo = false;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置gps信息
        /// </summary>
        /// <param name="userData"></param>
        public void SetGpsData(ISFSObject userData, string ip)
        {
            //获取gpsx; gpsy
            if ((userData.ContainsKey("x") && userData.ContainsKey("y")))
            {
                float GpsX = userData.GetFloat("x");
                float GpsY = userData.GetFloat("y");
                Position     = new Vector2(GpsX, GpsY);
                isHasGpsInfo = true;
            }
            else
            {
                Position     = new Vector2(0, 0);
                isHasGpsInfo = false;
            }

            if (userData.ContainsKey(RequestKeyOther.Country))
            {
                Country = userData.GetUtfString(RequestKeyOther.Country);
            }

            if (!string.IsNullOrEmpty(ip))
            {
                Ip = ip;
            }
        }
Exemplo n.º 4
0
    private void OnExtensionResponse(BaseEvent e)
    {
        print((string)e.Params[CONST.CMD]);

        ISFSObject sfso = (SFSObject)e.Params[CONST.CMD_PARAMS];

        if ((string)e.Params[CONST.CMD] == "trigger")
        {
            if (sfso.ContainsKey("idTransformer"))
            {
                Vector3    pos = new Vector3(sfso.GetFloat("x"), sfso.GetFloat("y"), sfso.GetFloat("z"));
                Quaternion rot = new Quaternion(sfso.GetFloat("rx"), sfso.GetFloat("ry"), sfso.GetFloat("rz"), sfso.GetFloat("rw"));

                SetPosVacuna(sfso.GetInt("idTransformer"), sfso.GetInt("idCont"), pos, rot);
            }
            else if (sfso.ContainsKey("emoji"))
            {
                remoteInterpolations[sfso.GetText("username")].GetComponentInChildren <RemoteSpriteViewerEmoji>().Show(sfso.GetInt("emoji"));
            }
            else if (sfso.ContainsKey("poster"))
            {
                remoteInterpolations[sfso.GetText("username")].GetComponentInChildren <RemoteSpriteViewerPoster>().Show(sfso.GetInt("poster") - 1);
            }
            else if (sfso.ContainsKey("tele"))
            {
                secuencia.ParcialComplete();
            }
            else if (sfso.ContainsKey("screenshot"))
            {
                screenshotBtn.RemoteScreenshot();
            }
        }
    }
Exemplo n.º 5
0
    public static Vector3 GetSFSTransform(ISFSObject data)
    {
        float x = data.GetFloat("x");
        float y = data.GetFloat("y");
        float z = data.GetFloat("z");

        return new Vector3(x,y,z);
    }
Exemplo n.º 6
0
    public static Vector3 GetSFSRotation(ISFSObject data)
    {
        float rx = data.GetFloat("rx");
        float ry = data.GetFloat("ry");
        float rz = data.GetFloat("rz");

        return new Vector3(rx, ry, rz);
    }
 //esegue animazioni remote Tastiera
 public void eseguiAnimazioniRemoteT(ISFSObject sfsObjIn)
 {
     anim.SetFloat("Forward",sfsObjIn.GetFloat("f"));
     anim.SetFloat("Turn", sfsObjIn.GetFloat("t"));
     anim.SetBool("OnGround", sfsObjIn.GetBool("o"));
     anim.SetFloat("Jump", sfsObjIn.GetFloat("j"));
     anim.SetFloat("JumpLeg", sfsObjIn.GetFloat("jL"));
     anim.SetBool("Attacco1", sfsObjIn.GetBool("a1"));
     anim.SetBool("Attacco2", sfsObjIn.GetBool("a2"));
 }
Exemplo n.º 8
0
    public static NetworkTransform fromSFSObject(ISFSObject data)
    {
        NetworkTransform nTransform = new NetworkTransform();

        nTransform.position  = new Vector3(data.GetFloat("x"), data.GetFloat("y"), data.GetFloat("z"));
        nTransform.rotation  = Quaternion.Euler(new Vector3(data.GetFloat("rx"), data.GetFloat("ry"), data.GetFloat("rz")));
        nTransform.timeStamp = data.GetDouble("time");

        //Debug.Log("fromSFSObject, timeStamp: " + data.GetDouble("time"));

        return(nTransform);
    }
Exemplo n.º 9
0
        void GetPlayerGPSInfo(PaiJiuPlayer panel, ISFSObject data)
        {
            if (data.ContainsKey("gpsx") && data.ContainsKey("gpsy"))
            {
                panel.GpsX       = data.GetFloat("gpsx");
                panel.GpsY       = data.GetFloat("gpsy");
                panel.HasGpsInfo = true;
            }

            if (data.ContainsKey("ip"))
            {
                panel.Ip = data.GetUtfString("ip");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 设置用户信息
        /// </summary>
        /// <param name="userData"></param>
        UserInfoStruct SetUserData(ISFSObject userData)
        {
            SetContryInfo(userData);

            var userinfoStruct = new UserInfoStruct();

            if (userData.ContainsKey(RequestKey.KeyId))
            {
                userinfoStruct.Id = userData.GetInt(RequestKey.KeyId);
            }

            if (userData.ContainsKey("ip"))
            {
                userinfoStruct.Ip = userData.GetUtfString("ip");
            }

            if (userData.ContainsKey("country"))
            {
                userinfoStruct.Country = userData.GetUtfString("country");
            }

            if (userData.ContainsKey(RequestKey.KeyName))
            {
                userinfoStruct.Name = userData.GetUtfString(RequestKey.KeyName);
            }

            //获取gpsx; gpsy
            if ((userData.ContainsKey("gpsx") && userData.ContainsKey("gpsy")) ||
                (userData.ContainsKey("x") && userData.ContainsKey("y")))
            {
                userinfoStruct.GpsX = userData.ContainsKey("gpsx") ? userData.GetFloat("gpsx") : userData.GetFloat("x");
                userinfoStruct.GpsY = userData.ContainsKey("gpsy") ? userData.GetFloat("gpsy") : userData.GetFloat("y");
            }
            else
            {
                userinfoStruct.GpsX = -1f;
                userinfoStruct.GpsY = -1f;
            }

            if (userData.ContainsKey(NewRequestKey.KeyAvatar))
            {
                userinfoStruct.HeadImgAvatar = userData.GetUtfString(NewRequestKey.KeyAvatar);
            }

            if (userData.ContainsKey(NewRequestKey.KeySex))
            {
                userinfoStruct.Sex = userData.GetShort(NewRequestKey.KeySex);
            }
            return(userinfoStruct);
        }
Exemplo n.º 11
0
    private void HandleDamageDone(ISFSObject data)
    {
        int attackerId = data.GetInt("attackerId");
        int targetId   = data.GetInt("targetId");

        if (attackerId == SmartFoxConnection.Connection.MySelf.Id)
        {
            NetworkPlayerManager.Instance.SpawnFloatingText(data.GetFloat("dmg"), false, targetId);
        }

        if (targetId == SmartFoxConnection.Connection.MySelf.Id)
        {
            NetworkPlayerManager.Instance.SpawnFloatingText(data.GetFloat("dmg"), true, targetId);
        }
    }
Exemplo n.º 12
0
        /// <summary>
        /// 初始化枪的类型
        /// </summary>
        /// <param name="gameInfo"></param>
        private void InitGunStyls(ISFSObject gameInfo)
        {
            var maxGunScore   = gameInfo.ContainsKey("bmax") ? gameInfo.GetInt("bmax") : 1000;
            var basicGunScore = gameInfo.ContainsKey("ante") ? gameInfo.GetInt("ante") : 10;
            var blts          = gameInfo.ContainsKey("blts") ? gameInfo.GetIntArray("blts") : _gunStyles;

            Defines.FireSpeed = gameInfo.ContainsKey("blsp") ? gameInfo.GetFloat("blsp") : 0.32f;
            //YxDebug.Log("枪炮数据:" + maxGunScore + "   " + basicGunScore);
            var count = blts.Length;

            _gunStyles = new int[count];
            var i = 0;

            for (; i < count; i++)
            {
                var score = blts[i] * basicGunScore;
                if (score > maxGunScore)
                {
                    break;
                }
                _gunStyles[i] = score;
            }
            Array.Resize(ref _gunStyles, i);
            if (i < 1)
            {
                return;
            }
            MinGunStyle = _gunStyles[0];
            MaxGunStyle = _gunStyles[_gunStyles.Length - 1];
        }
Exemplo n.º 13
0
 public void fromSFSObject(ISFSObject estimacion)
 {
     user = estimacion.GetUtfString("user");
     valorEstimacion = estimacion.GetFloat("valorEstimacion");
     descripcion = estimacion.GetUtfString("descripcion");
     id_UserStory = estimacion.GetLong("id_Story");
 }
Exemplo n.º 14
0
 /// <summary>
 /// 设置gps信息
 /// </summary>
 /// <param name="userData"></param>
 public void SetGpsData(ISFSObject userData)
 {
     //获取gpsx; gpsy
     if ((userData.ContainsKey(RequestKey.KeyGpsX) && userData.ContainsKey(RequestKey.KeyGpsY)) || (userData.ContainsKey("x") && userData.ContainsKey("y")))
     {
         GpsX         = userData.ContainsKey(RequestKey.KeyGpsX) ? userData.GetFloat(RequestKey.KeyGpsX) : userData.GetFloat("x");
         GpsY         = userData.ContainsKey(RequestKey.KeyGpsY) ? userData.GetFloat(RequestKey.KeyGpsY) : userData.GetFloat("y");
         IsHasGpsInfo = true;
     }
     else
     {
         GpsX         = -1f;
         GpsY         = -1f;
         IsHasGpsInfo = false;
     }
     GameTools.TryGetValueWitheKey(userData, out Country, RequestKey.Country);
 }
Exemplo n.º 15
0
 public static float TryGetFloat(this ISFSObject data, string key)
 {
     if (data.ContainsKey(key))
     {
         return(data.GetFloat(key));
     }
     return(0);
 }
Exemplo n.º 16
0
        public static AirBubble FromSFSData(ISFSObject obj)
        {
            AirBubble airBubble = new AirBubble();

            airBubble.time      = obj.GetLong("t");
            airBubble.value     = obj.GetFloat("v");
            airBubble.diveState = obj.GetInt("s");
            return(airBubble);
        }
Exemplo n.º 17
0
    public void OnObjectMessage(BaseEvent evt)
    {
        ISFSObject msgObj = (SFSObject)evt.Params["message"];

        if (msgObj.ContainsKey("wa"))
        {
            SetAngle(msgObj.GetFloat("wa"));
        }
    }
Exemplo n.º 18
0
 public float GetFloat(ISFSObject data, string key)
 {
     if (receiveEncrypted)
     {
         return provider.DecryptFloat(data.GetByteArray(key));
     }
     else
     {
         return data.GetFloat(key);
     }
 }
Exemplo n.º 19
0
 public float GetFloat(ISFSObject data, string key)
 {
     if (receiveEncrypted)
     {
         return(provider.DecryptFloat(data.GetByteArray(key)));
     }
     else
     {
         return(data.GetFloat(key));
     }
 }
        public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM)
        {
            string aCharacterName = anObjectIn.GetUtfString("CharacterName");
            if(aCharacterName == ourGWM.getLPC().GetName())
            {
                return;
            }
            else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName))
            {
                float Rotation = anObjectIn.GetFloat("Rotation");

                ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetRotation(Rotation);
            }
        }
        public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM)
        {
            Debug.Log("Server spawning player.");
            float[] locationArray = anObjectIn.GetFloatArray("Location");
            float aRotation = anObjectIn.GetFloat("Rotation");
            string aCharacterName = anObjectIn.GetUtfString("CharacterName");

            if(anObjectIn.GetBool("IsLocal"))
            {
                GameObject aLocalPlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic");
                aLocalPlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]);
                aLocalPlayer.transform.rotation = Quaternion.identity;

                // Since this is the local player, lets add a controller and fix the camera
                aLocalPlayer.AddComponent<LocalPlayerController>();
                aLocalPlayer.AddComponent<InputController>();
                ourGWM.setLPC(aLocalPlayer.GetComponent<LocalPlayerController>());
                ourGWM.getLPC().SetName(aCharacterName);
                aLocalPlayer.GetComponentInChildren<TextMesh>().text = aCharacterName;

                GameObject cameraAttach = new GameObject();
                cameraAttach.transform.parent = aLocalPlayer.transform;
                cameraAttach.transform.localPosition = new Vector3(1f, 2.5f, 1.0f);
                cameraAttach.name = "Camera Target";
                Camera.main.transform.parent = cameraAttach.transform;
                Camera.main.GetComponent<CameraController>().setTarget(cameraAttach);
                Camera.main.GetComponent<CameraController>().setCursorVisible(false);
            }
            else if(!anObjectIn.GetBool("IsLocal"))
            {
                GameObject aRemotePlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic");

                aRemotePlayer.name = "GameCharacter_" + aCharacterName;
                aRemotePlayer.AddComponent<RemotePlayerController>();
                aRemotePlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]);
                aRemotePlayer.GetComponent<RemotePlayerController>().SetRotation(aRotation);
                aRemotePlayer.GetComponentInChildren<TextMesh>().text = aCharacterName;

                //Add Newly spawned player to Dictionary
                ourGWM.getPlayerDictionary().Add(aCharacterName, aRemotePlayer);
            }
        }
Exemplo n.º 22
0
    public void CreateNewGameObject(ISFSObject obj)
    {
        string id = obj.GetUtfString("Id");

        //parse id to determine type
        string[] temp = id.Split('-');
        //Debug.Log(temp[0] + " " + temp[1] + " " + temp[2]);

        int type = int.Parse(temp[1]);

        GameObject newObject;

        //Debug.Log("Make new stuff");

        switch (type)
        {
            case 00: //tank
                Vector3 pos = new Vector3(obj.GetFloat("px"), obj.GetFloat("py"), obj.GetFloat("pz"));
                newObject = (GameObject)Instantiate(OtherPlayerTankPrefab, pos, Quaternion.identity);
                newObject.GetComponent<InputController>().id = temp[0];
                newObject.GetComponent<NetTag>().Id = temp[0] + "-00-" + "00";
                GameObject.FindWithTag("MainCamera").GetComponent<MainCameraScript>().setEnemies();
                GameObject.FindWithTag("MapCamera").GetComponent<MapCameraScript>().setEnemies();
                updatePhysList();
                break;

            case 1: //projectile
                newObject = (GameObject)Instantiate(heatProjectile, new Vector3(obj.GetFloat("ppx"), obj.GetFloat("ppy"), obj.GetFloat("ppz")), Quaternion.Euler(new Vector3(obj.GetFloat("prx"), obj.GetFloat("pry"), obj.GetFloat("prz"))));
                newObject.rigidbody.velocity = new Vector3(obj.GetFloat("pvx"), obj.GetFloat("pvy"), obj.GetFloat("pvz"));
                newObject.transform.position += newObject.rigidbody.velocity.normalized * 7;
                newObject.GetComponent<NetTag>().Id = temp[0] + "-1-" + temp[2];
                //primaryCount++;
                // Recoil
                /*NetInputController thisRemoteController = GetRemoteController(temp[0] + "-00-" + "00");
                thisRemoteController.Hull.rigidbody.AddForceAtPosition(-newObject.rigidbody.velocity * newObject.rigidbody.mass, thisRemoteController.Turret.Muzzle.transform.position, ForceMode.Impulse);*/
                updatePhysList();
                //Debug.Log("Spawning New Projectile with ID: " + newObject.GetComponent<NetTag>().Id);
                break;

            case 2: //missile
                newObject = (GameObject)Instantiate(ATMissile, new Vector3(obj.GetFloat("ppx"),obj.GetFloat("ppy"),obj.GetFloat("ppz")), Quaternion.Euler(new Vector3(obj.GetFloat("prx"),obj.GetFloat("pry"),obj.GetFloat("prz"))));
                newObject.GetComponent<GuidedProjectileInputController>().TargetPosition = new Vector3(obj.GetFloat("tx"), obj.GetFloat("ty"), obj.GetFloat("tz")); //ATMissile
                newObject.rigidbody.velocity = new Vector3(obj.GetFloat("pvx"), obj.GetFloat("pvy"), obj.GetFloat("pvz")); //ATMissile
                newObject.transform.position += newObject.rigidbody.velocity.normalized * 7;
                newObject.GetComponent<NetTag>().Id = temp[0] + "-2-" + temp[2];
                //secondaryCount++;
                updatePhysList();
                //Debug.Log("Spawning New Missile with ID: " + newObject.GetComponent<NetTag>().Id);
                break;

            default:
                //Debug.Log("Type was: " + type);
                break;
        }
    }
 //esegue animazioni remote Punta e clicca
 public void eseguiAnimazioniRemoteC(ISFSObject sfsObjIn)
 {
     forward= sfsObjIn.GetFloat("f");
     attacco1=sfsObjIn.GetBool("a1");
     attacco2=sfsObjIn.GetBool("a2");
 }
Exemplo n.º 24
0
    private void recieveExplosionForce(ISFSObject msg)
    {
        var force = msg.GetFloat("force");
        var pos = msg.GetFloatArray("pos");
        var team = msg.GetUtfString("team");
        targetPosition = new Vector3(pos[0], Y_PLANE, pos[1]);

        GameObject newExplosion = Instantiate(ExplosionPF, targetPosition, Quaternion.identity) as GameObject;

        if (team == "blue")
        {
            newExplosion.GetComponent<ParticleSystem>().startColor = new Color(0.0f, 0.5f, 1.0f, 1.0f);
        }
        else
        {
            newExplosion.GetComponent<ParticleSystem>().startColor = Color.red;
        }

        Vector3 lightPosition = targetPosition;
        lightPosition.y += 10.0f;

        GameObject explosionLight = Instantiate(ExplosionLightPF, lightPosition, Quaternion.identity) as GameObject;

        if (team == "blue")
        {
            explosionLight.GetComponent<Light>().color = Color.blue;
        }
        else
        {
            explosionLight.GetComponent<Light>().color = Color.red;
        }

        float totalTime = 2.0f * force/160.0f;

        Destroy(newExplosion, totalTime);

        totalTime = totalTime/5.0f;

        Destroy(explosionLight, totalTime);

        GameObject[] blocksArray = GameObject.FindGameObjectsWithTag("Block");
        foreach (GameObject block in blocksArray)
        {
            if (block.GetComponent<BoxCollider>().bounds.Contains(targetPosition))
            {
                var extents = block.GetComponent<BoxCollider>().bounds.extents;
                if(targetPosition.x > block.transform.position.x)
                    targetPosition += new Vector3(extents.x, 0, 0);
                else
                    targetPosition -= new Vector3(extents.x, 0, 0);

                if(targetPosition.z > block.transform.position.z)
                    targetPosition += new Vector3(0, 0, extents.z);
                else
                    targetPosition -= new Vector3(0, 0, extents.z);
            }

            block.GetComponent<Rigidbody>().AddExplosionForce(force, targetPosition, 25.0f, 0.0f, ForceMode.Impulse);
        }
    }
Exemplo n.º 25
0
 private void UpdatePolicePosition(ISFSObject data)
 {
     float police_x = (float)data.GetFloat("police_x");
     float police_y = (float)data.GetFloat("police_y");
     currentPolice.transform.position = new Vector3(police_x * mg.getScale().x, (police_y * mg.getScale().y + 0.2F * mg.getScale().y), 2F);
 }
Exemplo n.º 26
0
    private void updateInterpolationData(ISFSObject obj)
    {
        Vector3 nTrans = NetworkHelper.GetSFSTransform(obj);
        Vector3 nAngle = NetworkHelper.GetSFSRotation(obj);

        if (firstUpdate)
        {
            mostRecentTrans = nTrans;
            mostRecentAngle = nAngle;
            firstUpdate = false;
        }

        // Store last trans
        lastTransform = mostRecentTrans;

        // Store last angle
        lastAngle = mostRecentAngle;

        mostRecentAngle = nAngle;

        prevTime = mostRecentTime;

        mostRecentTrans = nTrans;

        mostRecentTime = obj.GetFloat("time");

        distanceDelta.x = (mostRecentTrans.x - lastTransform.x)/(mostRecentTime - prevTime);
        distanceDelta.y = (mostRecentTrans.y - lastTransform.y)/(mostRecentTime - prevTime);
        distanceDelta.z = (mostRecentTrans.z - lastTransform.z)/(mostRecentTime - prevTime);

        // Need to prevent issues from angle differences larger than 180
        if ( Math.Abs(mostRecentAngle.x - lastAngle.x) > 180.0f)
        {
            if (mostRecentAngle.x < lastAngle.x)
            {
                mostRecentAngle.x = mostRecentAngle.x + 360.0f;
            }
            else
            {
                lastAngle.x = lastAngle.x + 360.0f;
            }
        }

        if ( Math.Abs(mostRecentAngle.y - lastAngle.y) > 180.0f)
        {
            if (mostRecentAngle.y < lastAngle.y)
            {
                mostRecentAngle.y = mostRecentAngle.y + 360.0f;
            }
            else
            {
                lastAngle.y = lastAngle.y + 360.0f;
            }
        }

        if ( Math.Abs(mostRecentAngle.z - lastAngle.z) > 180.0f)
        {
            if (mostRecentAngle.z < lastAngle.z)
            {
                mostRecentAngle.z = mostRecentAngle.z + 360.0f;
            }
            else
            {
                lastAngle.z = lastAngle.z + 360.0f;
            }
        }

        angleDelta = (mostRecentAngle - lastAngle)/(mostRecentTime - prevTime);

        lastAngle = FixAngles(lastAngle);
        mostRecentAngle = FixAngles(mostRecentAngle);
    }