Пример #1
0
        public MapInfo(DataRow Row)
        {
            MapIndex = Row["Map Index"] is DBNull ? -1 : (int)Row["Map Index"];
            FileName = Row["File Name"] is DBNull ? string.Empty : Row["File Name"].ToString();
            MapName  = Row["Map Name"] is DBNull ? string.Empty : Row["Map Name"].ToString();
            MiniMap  = Row["Mini Map"] is DBNull ? -1 : (int)Row["Mini Map"];
            BigMap   = Row["Big Map"] is DBNull ? -1 : (int)Row["Big Map"];

            string Flags = Row["Flags"] is DBNull ? string.Empty : Row["Flags"].ToString();

            if (Flags.IndexOf("SAFE", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                FightMode = FightSetting.Safe;
            }
            else if (Flags.IndexOf("FIGHT", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                FightMode = FightSetting.Fight;
            }

            if (Flags.IndexOf("DAY", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                LightMode = LightSetting.Day;
            }
            else if (Flags.IndexOf("NIGHT", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                LightMode = LightSetting.Night;
            }

            if (Flags.IndexOf("MINE", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                CanMine = true;
            }
        }
Пример #2
0
    private void ParseMessage(string Message)
    {
        try
        {
            JSONObject jsonOBJ = new JSONObject(Message);

            if (HostMode)
            {
                if(jsonOBJ["command"].str == "UserData")
                {
                    this.pairedUserData = new UserData(jsonOBJ["data"]);

                    Invoke("SendUserData",0f);

                    isConnected = true;

                    if(OnPaired!=null)
                    {
                        OnPaired.Invoke(PairedUserData);
                    }

                }
                else if(jsonOBJ["command"].str == "FightSetting")
                {
                    this.fightSetting = new FightSetting(jsonOBJ["data"]);

                    if(OnFightSetting!=null)OnFightSetting.Invoke(this.fightSetting);

                }
                else if(jsonOBJ["command"].str == "FightData")
                {
                    this.targetResult = new SingleUserFightResult(jsonOBJ["data"]);

                    if (myResult != null && targetResult != null)
                    {
                        fullUserFightResult = new FullUserFightResult();
                        fullUserFightResult.localResult = myResult;
                        fullUserFightResult.oppositeResult = targetResult;

                        parseTest.UpdateFightState(fullUserFightResult);
                        parseTest.AddBattleRecord(LocalUserData.userID,LocalUserData.userName,fullUserFightResult.localResult.TimeOffset,PairedUserData.userID,PairedUserData.userName,fullUserFightResult.oppositeResult.TimeOffset);

                        if(OnFightResult!=null)OnFightResult.Invoke(fullUserFightResult);
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            else
            {
                if(jsonOBJ["command"].str == "UserData")
                {
                    this.pairedUserData = new UserData(jsonOBJ["data"]);

                    if(OnPaired!=null)
                    {
                        OnPaired.Invoke(PairedUserData);
                    }

                    CalculatingRTT = false;

                    isConnected = true;

                    Invoke("SendBattleConfig",0);

                }
                else if(jsonOBJ["command"].str == "FightData")
                {
                    this.targetResult = new SingleUserFightResult(jsonOBJ["data"]);

                    if (myResult != null && targetResult != null)
                    {
                        fullUserFightResult = new FullUserFightResult();
                        fullUserFightResult.localResult = myResult;
                        fullUserFightResult.oppositeResult = targetResult;

                        parseTest.UpdateFightState(fullUserFightResult);

                        if(OnFightResult!=null)OnFightResult.Invoke(fullUserFightResult);
                    }
                }
                else
                {
                    throw new Exception();
                }
            }

        }
        catch
        {
            Debug.Log("unknown command:"+Message);
        }
    }
Пример #3
0
    public void SendBattleConfig()
    {
        fightSetting = new FightSetting ();

        fightSetting.MusicTime = UnityEngine.Random.Range (MusicMinTime,MusicMaxTime);
        fightSetting.RTT = RTTTime;

        JSONObject json = new JSONObject ();

        json.AddField("command","FightSetting");
        json.AddField ("data", this.fightSetting.ToJSON());

        SendTheMessage (json.ToString());

        Invoke ("SetSelfBattleSoundWithDelay", RTTTime/2);
    }
Пример #4
0
 public void FinishAndResetAPI(Action callback = null)
 {
     CancelInvoke ();
     hostMode = false;
     Advertising = false;
     isConnected = false;
     pairedUserData = null;
     fightSetting = null;
     RTTTime = 0;
     CalculatingRTT = false;
     ResponseTimer = 0;
     myResult = null;
     targetResult = null;
     fullUserFightResult = null;
     BluetoothLEHardwareInterface.DeInitialize (callback);
     bluetoothDeviceScript = null;
 }
Пример #5
0
 public void FakeFightStart()
 {
     FightSetting setting = new FightSetting();
     setting.MusicTime = 10;
     setting.RTT = 0f;
     OnFightSetting.Invoke (setting);
 }