Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     settingFile = Resources.Load<GameSetting>("Setting/GameSetting");
     titleText = this.GetComponent<Text>();
     titleText.color = new Color(1,1,1,0);
     StartCoroutine (EffectText ());
 }
Ejemplo n.º 2
0
    static GameSetting()
    {
        setting = FindObjectOfType(typeof(GameSetting)) as GameSetting;
        if (setting == null)
        {
            GameObject obj2 = new GameObject("GameSetting");
            setting = obj2.AddComponent(typeof(GameSetting)) as GameSetting;
        }
        if (setting == null) return;

        setting.MobileType = 1;
        setting.DeviceID = "00-E1-4C-36-F5-C8";//更换会重新注册账号
        setting.ScreenX = 860;
        setting.ScreenY = 460;
        setting.RetailID = "0000";
        setting.GameID = 1;
        setting.ServerID = 1;
        setting.ClientAppVersion = "1.0";
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 转账
        /// </summary>
        /// <param name="siteId">所属商户</param>
        /// <param name="game">当前游戏配置</param>
        /// <param name="user">用户信息</param>
        /// <param name="action">转入转出类型</param>
        /// <param name="orderID">转账订单号(本地)</param>
        /// <param name="currency">货币类型</param>
        /// <param name="money">金额</param>
        /// <returns></returns>
        public TransferResult Transfer(Site site, GameSetting game, UserGame user, TransferAction action, string orderID, decimal money)
        {
            if (user == null)
            {
                return(new TransferResult(ResultStatus.NoUser));
            }
            // 订单格式的判断
            if (WebAgent.IsUserName(orderID, 2, 16))
            {
                return(new TransferResult(ResultStatus.OrderIDFormat));
            }

            // 金额判断(默认是2位小数,如果游戏接口的特别要求,则在游戏接口中返回金额错误)
            if (money <= 0M || Math.Round(money, 2) != money)
            {
                return(new TransferResult(ResultStatus.BadMoney));
            }

            // 本地锁(如果部署集群则需要修改成为分布式锁)
            lock (LockHelper.GetLoker($"{user.ToString()}"))
            {
                //同一个商户订单重复,不允许操作
                if (this.ReadDB.Exists <UserTransfer>(t => t.SiteID == site.ID && t.SourceID == orderID))
                {
                    return(new TransferResult(ResultStatus.ExistsOrder));
                }

                //添加转账记录,把状态设置为转账中
                UserTransfer userTransfer = new UserTransfer()
                {
                    SiteID   = site.ID,
                    GameID   = game.ID,
                    UserID   = user.UserID,
                    Money    = money,
                    Action   = action,
                    CreateAt = DateTime.Now,
                    FinishAt = DateTime.MinValue,
                    SystemID = string.Empty,
                    SourceID = orderID,
                    Status   = TransferStatus.Paying
                };
                this.WriteDB.InsertIdentity(userTransfer);

                // 调用API接口
                TransferResult result = game.Setting.Transfer(new TransferInfo()
                {
                    Prefix   = site.Prefix,
                    UserName = user.Account,
                    Action   = action,
                    OrderID  = orderID,
                    Currency = site.Currency,
                    Money    = money
                });

                userTransfer.SystemID = result.SystemID;
                userTransfer.FinishAt = DateTime.Now;
                userTransfer.Status   = result.Status switch
                {
                    ResultStatus.Exception => TransferStatus.Exception,
                    ResultStatus.Success => TransferStatus.Success,
                    _ => TransferStatus.Faild
                };
                this.WriteDB.Update(userTransfer, t => t.SystemID, t => t.FinishAt, t => t.Status);

                if (!result)
                {
                    return(new TransferResult(result.Status));
                }

                if (result.Balance != null)
                {
                    UserAgent.Instance().UpdateBalance(user, result.Balance.Value);
                }
                else
                {
                    BalanceResult balanceResult = this.GetBalance(site, game, user);
                    if (balanceResult)
                    {
                        result.Balance = balanceResult.Balance;
                    }
                }
                return(result);
            }
        }
Ejemplo n.º 4
0
        public void Fill_LeftStrg31(GridStrategy gStrategy, GameSetting gameSetting)
        {
            //double _treshold = 0.7;
            double _treshold = 0;

            StringBuilder sb = new StringBuilder();

            //nodes
            for (int i = 0; i < gStrategy.Rules.Count; i++)
            {
                AddNode(new Node(i, gStrategy.Rules[i]));
            }

            GridStrategy offensiveM = new GridStrategy();

            offensiveM.Rules.Add(gStrategy.Rules[0]);
            offensiveM.Rules.Add(gStrategy.Rules[1]);
            offensiveM.Rules.Add(gStrategy.Rules[2]);
            offensiveM.Rules.Add(gStrategy.Rules[3]);
            GridStrategy offensiveR = new GridStrategy();

            offensiveR.Rules.Add(gStrategy.Rules[4]);
            offensiveR.Rules.Add(gStrategy.Rules[5]);
            offensiveR.Rules.Add(gStrategy.Rules[6]);
            offensiveR.Rules.Add(gStrategy.Rules[7]);
            offensiveR.Rules.Add(gStrategy.Rules[8]);
            offensiveR.Rules.Add(gStrategy.Rules[9]);
            GridStrategy offensiveL = new GridStrategy();

            offensiveL.Rules.Add(gStrategy.Rules[10]);
            offensiveL.Rules.Add(gStrategy.Rules[11]);
            offensiveL.Rules.Add(gStrategy.Rules[12]);
            offensiveL.Rules.Add(gStrategy.Rules[13]);
            offensiveL.Rules.Add(gStrategy.Rules[14]);
            offensiveL.Rules.Add(gStrategy.Rules[15]);
            GridStrategy defensiveM = new GridStrategy();

            defensiveM.Rules.Add(gStrategy.Rules[16]);
            defensiveM.Rules.Add(gStrategy.Rules[17]);
            defensiveM.Rules.Add(gStrategy.Rules[18]);
            defensiveM.Rules.Add(gStrategy.Rules[19]);
            GridStrategy defensiveR = new GridStrategy();

            defensiveR.Rules.Add(gStrategy.Rules[20]);
            defensiveR.Rules.Add(gStrategy.Rules[21]);
            defensiveR.Rules.Add(gStrategy.Rules[22]);
            defensiveR.Rules.Add(gStrategy.Rules[23]);
            defensiveR.Rules.Add(gStrategy.Rules[24]);
            defensiveR.Rules.Add(gStrategy.Rules[25]);
            GridStrategy defensiveL = new GridStrategy();

            defensiveL.Rules.Add(gStrategy.Rules[26]);
            defensiveL.Rules.Add(gStrategy.Rules[27]);
            defensiveL.Rules.Add(gStrategy.Rules[28]);
            defensiveL.Rules.Add(gStrategy.Rules[29]);
            defensiveL.Rules.Add(gStrategy.Rules[30]);

            List <GridStrategy> lStrategy = new List <GridStrategy>();

            lStrategy.Add(offensiveM);
            lStrategy.Add(offensiveR);
            lStrategy.Add(offensiveL);
            lStrategy.Add(defensiveM);
            lStrategy.Add(defensiveR);
            lStrategy.Add(defensiveL);

            //edges
            double        max    = -1;
            List <Triple> values = new List <Triple>();

            foreach (GridStrategy tempStrg in lStrategy)
            {
                for (int i = 0; i < tempStrg.Rules.Count - 1; i++)
                {
                    for (int j = i + 1; j < tempStrg.Rules.Count; j++)
                    {
                        GridRule r1 = tempStrg.Rules[i];
                        GridRule r2 = tempStrg.Rules[j];

                        //ball
                        double ballRuleSize = gStrategy.GridToReal(r1.Ball, gameSetting).DistanceFrom(
                            gStrategy.GridToReal(r2.Ball, gameSetting)
                            );

                        //mine
                        double mineSize = 0;
                        for (int k = 0; k < gameSetting.NUMBER_OF_ROBOTS - 1; k++)
                        {
                            mineSize += gStrategy.GridToReal(r1.Mine[r1.ZMine[k]], gameSetting).DistanceFrom(
                                gStrategy.GridToReal(r2.Mine[r2.ZMine[k]], gameSetting)
                                );
                        }

                        //oppnt
                        double oppntSize = 0;
                        for (int k = 0; k < gameSetting.NUMBER_OF_ROBOTS - 1; k++)
                        {
                            oppntSize += gStrategy.GridToReal(r1.Oppnt[r1.ZOppnt[k]], gameSetting).DistanceFrom(
                                gStrategy.GridToReal(r2.Oppnt[r2.ZOppnt[k]], gameSetting)
                                );
                        }

                        if (ballRuleSize + mineSize + oppntSize > max)
                        {
                            max = ballRuleSize + mineSize + oppntSize;
                        }

                        int ii = gStrategy.Rules.IndexOf(tempStrg.Rules[i]);
                        int ij = gStrategy.Rules.IndexOf(tempStrg.Rules[j]);

                        values.Add(new Triple(ii, ij, ballRuleSize + mineSize + oppntSize));
                    }
                }
            }

            for (int i = 0; i < values.Count; i++)
            {
                double norm = 1 - (values[i].z / max);
                sb.AppendLine(values[i].x + " " + values[i].y + " " + Math.Round(norm, 3).ToString().Replace(',', '.'));
                //Console.WriteLine("{0} {1} {2} {3}", values[i].x, values[i].y, values[i].z, norm);

                if (norm >= _treshold)
                {
                    AddEdge(nodes[values[i].x], nodes[values[i].y], norm);
                }
            }

            string filename = "GRAPH_" + gStrategy.Name + ".txt";

            File.Delete(filename);
            using (StreamWriter sw = new StreamWriter(new FileStream(filename, FileMode.CreateNew)))
            {
                sw.Write(sb.ToString());
            }
        }
Ejemplo n.º 5
0
 public void OnDrag(PointerEventData eventData)
 {
     curPos = GameSetting.CurMouseWorldPos(eventData.position);
 }
Ejemplo n.º 6
0
    void Start()
    {
        mSetting = new GameSetting();
        setSetting(mSetting);

        Subject.addObserver(new Observer("settingMain", (aMessage) => {
            switch (aMessage.name)
            {
            case "initialMoneyRateButtonPushed":
                MySceneManager.openScene("initialMoneySetting", null, null, (aData) => {
                    mSetting.mInitialMoneyRate = aData.get <float>("rate");
                    setSetting(mSetting);
                });
                break;

            case "feeRateButtonPushed":
                MySceneManager.openScene("feeSetting", null, null, (aData) => {
                    mSetting.mFeeRate = aData.get <float>("rate");
                    setSetting(mSetting);
                });
                break;

            case "acquisitionRateButtonPushed":
                MySceneManager.openScene("acquisitionSetting", null, null, (aData) => {
                    mSetting.mAcqusitionRate = aData.get <float>("rate");
                    setSetting(mSetting);
                });
                break;

            case "stageButtonPushed":
                MySceneManager.openScene("stageSetting", null, null, (aData) => {
                    mSetting.mStageName = aData.get <string>("stage");
                    setSetting(mSetting);
                });
                break;

            //ai設定
            case "ai1ButtonPushed":
                MySceneManager.openScene("aiSetting", null, null, (aData) => {
                    mSetting.mCharaData1.mAi     = aData.get <string>("ai");
                    mSetting.mCharaData1.mAiName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "ai2ButtonPushed":
                MySceneManager.openScene("aiSetting", null, null, (aData) => {
                    mSetting.mCharaData2.mAi     = aData.get <string>("ai");
                    mSetting.mCharaData2.mAiName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "ai3ButtonPushed":
                MySceneManager.openScene("aiSetting", null, null, (aData) => {
                    mSetting.mCharaData3.mAi     = aData.get <string>("ai");
                    mSetting.mCharaData3.mAiName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "ai4ButtonPushed":
                MySceneManager.openScene("aiSetting", null, null, (aData) => {
                    mSetting.mCharaData4.mAi     = aData.get <string>("ai");
                    mSetting.mCharaData4.mAiName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            //キャラ設定
            case "chara1ButtonPushed":
                MySceneManager.openScene("charaSetting",
                                         new Arg(new Dictionary <string, object>()
                {
                    { "ng", new string[3] {
                          mSetting.mCharaData2.mFile, mSetting.mCharaData3.mFile, mSetting.mCharaData4.mFile
                      } }
                }),
                                         null, (aData) => {
                    mSetting.mCharaData1.mFile = aData.get <string>("file");
                    mSetting.mCharaData1.mName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "chara2ButtonPushed":
                MySceneManager.openScene("charaSetting",
                                         new Arg(new Dictionary <string, object>()
                {
                    { "ng", new string[3] {
                          mSetting.mCharaData1.mFile, mSetting.mCharaData3.mFile, mSetting.mCharaData4.mFile
                      } }
                }),
                                         null, (aData) => {
                    mSetting.mCharaData2.mFile = aData.get <string>("file");
                    mSetting.mCharaData2.mName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "chara3ButtonPushed":
                MySceneManager.openScene("charaSetting",
                                         new Arg(new Dictionary <string, object>()
                {
                    { "ng", new string[3] {
                          mSetting.mCharaData1.mFile, mSetting.mCharaData2.mFile, mSetting.mCharaData4.mFile
                      } }
                }),
                                         null, (aData) => {
                    mSetting.mCharaData3.mFile = aData.get <string>("file");
                    mSetting.mCharaData3.mName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "chara4ButtonPushed":
                MySceneManager.openScene("charaSetting",
                                         new Arg(new Dictionary <string, object>()
                {
                    { "ng", new string[3] {
                          mSetting.mCharaData1.mFile, mSetting.mCharaData2.mFile, mSetting.mCharaData3.mFile
                      } }
                }),
                                         null, (aData) => {
                    mSetting.mCharaData4.mFile = aData.get <string>("file");
                    mSetting.mCharaData4.mName = aData.get <string>("name");
                    setSetting(mSetting);
                });
                break;

            case "startButtonPushed":
                startGame();
                break;

            default:
                return;
            }
        }));
    }
Ejemplo n.º 7
0
 public override void Initialize(GameInfo gameInfo, GameSetting gameSetting)
 {
     base.Initialize(gameInfo, gameSetting);
     comingoutDay = new Random().Next(3) + 1;
     isCameout    = false;
 }
Ejemplo n.º 8
0
        private void UpdateAppSettings(GameSetting setting, XmlNode appSettings, XmlDocument parent)
        {
            SaveKeyValue(appSettings, parent, "Product.Code", () => setting.GameCode, DefaultConfig.GameCode, true);
            SaveKeyValue(appSettings, parent, "Product.Name", () => setting.GameName, DefaultConfig.GameName);
            SaveKeyValue(appSettings, parent, "Product.ServerId", () => setting.GameServerCode, DefaultConfig.ServerCode, true);
            SaveKeyValue(appSettings, parent, "Product.SignKey", () => setting.GameSignKey, DefaultConfig.GameSignKey);
            SaveKeyValue(appSettings, parent, "Product.DesEnKey", () => setting.ProductDesEnKey, DefaultConfig.ProductDesEnKey);
            SaveKeyValue(appSettings, parent, "Product.ClientDesDeKey", () => setting.ClientDesDeKey, DefaultConfig.ClientDesDeKey);
            SaveKeyValue(appSettings, parent, "Game.Port", () => setting.SocketPort, DefaultConfig.SocketPort, true);
            SaveKeyValue(appSettings, parent, "Redis.Host", () => setting.Redis.Host, DefaultConfig.RedisHost, true);
            SaveKeyValue(appSettings, parent, "Redis.ReadHost", () => setting.Redis.ReadOnlyHost, DefaultConfig.ReadOnlyHost, true);
            SaveKeyValue(appSettings, parent, "Redis.Db", () => setting.Redis.Db, DefaultConfig.RedisDb, true);
            SaveKeyValue(appSettings, parent, "Redis.ConnectTimeout", () => setting.Redis.ConnectTimeout, DefaultConfig.ConnectTimeout);
            SaveKeyValue(appSettings, parent, "Redis.PoolTimeOut", () => setting.Redis.PoolTimeOut, DefaultConfig.PoolTimeOut);
            SaveKeyValue(appSettings, parent, "Redis.Pool.MaxWritePoolSize", () => setting.Redis.MaxWritePoolSize, DefaultConfig.MaxWritePoolSize);
            SaveKeyValue(appSettings, parent, "Redis.Pool.MaxReadPoolSize", () => setting.Redis.MaxReadPoolSize, DefaultConfig.MaxReadPoolSize);

            SaveKeyValue(appSettings, parent, "Game.Http.Host", () => setting.HttpHost, DefaultConfig.HttpHost, true);
            SaveKeyValue(appSettings, parent, "Game.Http.Port", () => setting.HttpPort, DefaultConfig.HttpPort, true);
            SaveKeyValue(appSettings, parent, "Game.Http.Name", () => setting.HttpName, DefaultConfig.HttpName);
            SaveKeyValue(appSettings, parent, "Game.Http.Timeout", () => setting.HttpTimeout, DefaultConfig.HttpTimeout);
            SaveKeyValue(appSettings, parent, "MaxConnections", () => setting.SocketMaxConnections, DefaultConfig.SocketMaxConnections);
            SaveKeyValue(appSettings, parent, "Backlog", () => setting.SocketBacklog, DefaultConfig.SocketBacklog);
            SaveKeyValue(appSettings, parent, "MaxAcceptOps", () => setting.SocketMaxAcceptOps, DefaultConfig.SocketMaxAcceptOps);
            SaveKeyValue(appSettings, parent, "BufferSize", () => setting.SocketBufferSize, DefaultConfig.SocketBufferSize);

            SaveKeyValue(appSettings, parent, "Game.Action.EnableGZip", () => setting.ActionEnableGZip, DefaultConfig.ActionEnableGZip);
            SaveKeyValue(appSettings, parent, "Game.Action.GZipOutLength", () => setting.ActionGZipOutLength, DefaultConfig.ActionGZipOutLength);
            SaveKeyValue(appSettings, parent, "Game.Action.TypeName", () => setting.ActionTypeName, DefaultConfig.ActionTypeName);
            SaveKeyValue(appSettings, parent, "Game.Action.AssemblyName", () => setting.ActionAssemblyName, DefaultConfig.ActionAssemblyName);
            SaveKeyValue(appSettings, parent, "Game.Action.Script.TypeName", () => setting.ActionScriptTypeName, DefaultConfig.ActionScriptTypeName);
            SaveKeyValue(appSettings, parent, "Python_Disable", () => setting.PythonDisable, DefaultConfig.PythonDisable);
            SaveKeyValue(appSettings, parent, "Script_IsDebug", () => setting.ScriptIsDebug, DefaultConfig.ScriptIsDebug, true);
            SaveKeyValue(appSettings, parent, "ScriptRelativePath", () => setting.ScriptRelativePath, DefaultConfig.ScriptRelativePath);
            SaveKeyValue(appSettings, parent, "CSharpRootPath", () => setting.CSharpRootPath, DefaultConfig.CSharpRootPath);
            SaveKeyValue(appSettings, parent, "PythonRootPath", () => setting.PythonRootPath, DefaultConfig.PythonRootPath);

            SaveKeyValue(appSettings, parent, "Lua_Disable", () => setting.LuaDisable, DefaultConfig.LuaDisable);
            SaveKeyValue(appSettings, parent, "LuaRootPath", () => setting.LuaRootPath, DefaultConfig.LuaRootPath);

            SaveKeyValue(appSettings, parent, "ScriptMainClass", () => setting.ScriptMainClass, DefaultConfig.ScriptMainClass, true);
            SaveKeyValue(appSettings, parent, "ScriptMainTypeName", () => setting.ScriptMainTypeName, DefaultConfig.ScriptMainTypeName, true);
            SaveKeyValue(appSettings, parent, "ScriptSysAsmReferences", () => string.Join(";", setting.ScriptSysAsmReferences), "");
            SaveKeyValue(appSettings, parent, "ScriptAsmReferences", () => string.Join(";", setting.ScriptAsmReferences), "");

            SaveKeyValue(appSettings, parent, "Game.Entity.AssemblyName", () => setting.ModelEntityAssemblyName, DefaultConfig.ModelEntityAssemblyName);
            SaveKeyValue(appSettings, parent, "Game.Script.DecodeFunc.TypeName", () => setting.ScriptDecodeFuncTypeName, DefaultConfig.ScriptDecodeFuncTypeName, true);
            SaveKeyValue(appSettings, parent, "Game.Remote.Script.TypeName", () => setting.RemoteScriptTypeName, DefaultConfig.RemoteScriptTypeName, true);

            SaveKeyValue(appSettings, parent, "Cache.global.period", () => setting.CacheGlobalPeriod, DefaultConfig.CacheGlobalPeriod);
            SaveKeyValue(appSettings, parent, "Cache.user.period", () => setting.CacheUserPeriod, DefaultConfig.CacheUserPeriod);
            SaveKeyValue(appSettings, parent, "Game.Cache.UpdateDbInterval", () => setting.CacheUpdateDbInterval, DefaultConfig.CacheUpdateDbInterval);
            SaveKeyValue(appSettings, parent, "Cache.update.interval", () => setting.CacheUpdateInterval, DefaultConfig.CacheUpdateInterval);
            SaveKeyValue(appSettings, parent, "Cache.expired.interval", () => setting.CacheExpiredInterval, DefaultConfig.CacheExpiredInterval);
            SaveKeyValue(appSettings, parent, "Cache.enable.writetoDb", () => setting.CacheEnableWritetoDb, DefaultConfig.CacheEnableWritetoDb);
            SaveKeyValue(appSettings, parent, "Cache.Serializer", () => setting.CacheSerializer, DefaultConfig.CacheSerializer);
            SaveKeyValue(appSettings, parent, "DataSyncQueueNum", () => setting.DataSyncQueueNum, DefaultConfig.DataSyncQueueNum);
            SaveKeyValue(appSettings, parent, "SqlWaitSyncQueueNum", () => setting.SqlWaitSyncQueueNum, DefaultConfig.SqlWaitSyncQueueNum);
            SaveKeyValue(appSettings, parent, "SqlSyncQueueNum", () => setting.SqlSyncQueueNum, DefaultConfig.SqlSyncQueueNum);


            SaveKeyValue(appSettings, parent, "Log.TableName.Format", () => setting.LogTableNameFormat, DefaultConfig.LogTableNameFormat);
            SaveKeyValue(appSettings, parent, "Log.PriorBuild.Month", () => setting.LogPriorBuildMonth, DefaultConfig.LogPriorBuildMonth);
            SaveKeyValue(appSettings, parent, "PublishType", () => setting.PublishType, DefaultConfig.DefPublishType);
            SaveKeyValue(appSettings, parent, "EnableGM", () => setting.EnableGm, DefaultConfig.EnableGm);
            SaveKeyValue(appSettings, parent, "Sns.PreAccount", () => setting.SnsAccountPrefixChar, DefaultConfig.SnsAccountPrefixChar);
            SaveKeyValue(appSettings, parent, "Game.Language.TypeName", () => setting.LanguageTypeName, DefaultConfig.LanguageTypeName);
        }
Ejemplo n.º 9
0
 public void ShowRulePanel(GameSetting gameSetting)
 {
     rulePanel.Show(gameSetting);
 }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     GameSetting.Init();
 }
Ejemplo n.º 11
0
 public void StartGame()
 {
     gameSetting = new GameSetting(MapSize, 15000);
     InitializeTimers();
 }
Ejemplo n.º 12
0
 private void CheckRules(GameSetting setting)
 {
     Launcher.Instance.ShowRulePanel(setting);
 }
Ejemplo n.º 13
0
 public Strategy(GameSetting gameSetting)
 {
     this.gameSetting = gameSetting;
 }
Ejemplo n.º 14
0
    public static void Create(BinaryReader reader)
    {
        var header = new RecordHeader(reader);

        switch (header.Type)
        {
        case RecordType.BirthSign:
            BirthSignRecord.Create(reader, header);
            break;

        case RecordType.BodyPart:
            BodyPartRecord.Create(reader, header);
            break;

        case RecordType.Cell:
            CellRecord.Create(reader, header);
            break;

        case RecordType.Dialogue:
            DialogRecord.Create(reader, header);
            break;

        case RecordType.GameSetting:
            GameSetting.Create(reader, header);
            break;

        case RecordType.Info:
            InfoRecord.Create(reader, header);
            break;

        case RecordType.Land:
            LandRecord.Create(reader, header);
            break;

        case RecordType.LandTexture:
            LandTextureRecord.Create(reader, header);
            break;

        case RecordType.MagicEffect:
            MagicEffectRecord.Create(reader, header);
            break;

        case RecordType.PathGrid:
            Pathgrid.Create(reader, header);
            break;

        case RecordType.Script:
            Script.Create(reader, header);
            break;

        case RecordType.Skill:
            SkillRecord.Create(reader, header);
            break;

        case RecordType.SoundGenerator:
            SoundGenerator.Create(reader, header);
            break;

        case RecordType.Tes3:
            Tes3Record.Create(reader, header);
            break;

        default:
        {
            var size = GotoSubrecord(SubRecordType.Id, header);
            var id   = reader.ReadString(size);
            reader.BaseStream.Position = header.DataOffset + header.DataSize;
            var recordData = CreateRecordData(header.Type);
            recordData.Header = header;
            Records.Add(id, recordData);
            break;
        }
        }
    }
 public void AssignLevelID()
 {
     m_Level_ID = GameSetting.GetLevelID(m_Level_RoadWidth, m_Level_Speed);
 }
Ejemplo n.º 16
0
 void Start()
 {
     gameSetting = Resources.Load<GameSetting>("GameSetting");
 }
Ejemplo n.º 17
0
    // Calculate Attack type from movement
    private void Update()
    {
        if (Time.timeScale == 0 || !input)
        {
            return;
        }

        // Calculate movement direciton here from CharacterInput inputs.
        var movementDirection = GetMovementDirection();

        animation.SetParameter("MovementDirection", movementDirection);

        var moveSpeed = GetMovementSpeed();

        animation.SetParameter("MovementSpeed", moveSpeed);

        transform.eulerAngles += new Vector3(0, input.Yaw * rotateSpeed, 0);
        var movementSpeed = this.movementSpeed;

        switch (moveSpeed)
        {
        case MovementSpeed.Run:
            movementSpeed *= GameSetting.Get("fBaseRunMultiplier").FloatValue;
            break;

        case MovementSpeed.Sneak:
            //movementSpeed *= GameSetting.Get("fSneakSpeedMultiplier").FloatValue;
            break;

        case MovementSpeed.Walk:
            break;

        case MovementSpeed.None:
            movementSpeed = 0;
            break;
        }

        // Jumping
        if (input.Jump && isGrounded)
        {
            GetComponent <Rigidbody>().velocity += new Vector3(0, jumpHeight, 0);
            isGrounded = false;
            animation.SetParameter("IsGrounded", isGrounded);
        }

        // Movement
        switch (movementDirection)
        {
        case MovementDirection.Forward:
        case MovementDirection.ForwardLeftRight:
            Move(Vector3.forward, movementSpeed);
            break;

        case MovementDirection.Back:
        case MovementDirection.BackLeftRight:
            Move(Vector3.back, movementSpeed);
            break;

        case MovementDirection.Left:
        case MovementDirection.LeftForwardBack:
            Move(Vector3.left, movementSpeed * strafeSpeed);
            break;

        case MovementDirection.Right:
        case MovementDirection.RightForwardBack:
            Move(Vector3.right, movementSpeed * strafeSpeed);
            break;

        case MovementDirection.ForwardLeft:
            Move(new Vector3(-0.75f, 0, 0.75f), movementSpeed);
            break;

        case MovementDirection.ForwardRight:
            Move(new Vector3(0.75f, 0, 0.75f), movementSpeed);
            break;

        case MovementDirection.BackLeft:
            Move(new Vector3(-0.75f, 0, -0.75f), movementSpeed);
            break;

        case MovementDirection.BackRight:
            Move(new Vector3(0.75f, 0, -0.75f), movementSpeed);
            break;
        }

        // Attacking
        // If attack is not being pressed, don't perform an attack
        if (input.Attack)
        {
            switch (movementDirection)
            {
            case MovementDirection.None:
            case MovementDirection.ForwardLeft:
            case MovementDirection.ForwardRight:
            case MovementDirection.BackLeft:
            case MovementDirection.BackRight:
                animation.SetParameter("AttackType", AttackType.Chop);
                break;

            case MovementDirection.Forward:
            case MovementDirection.Back:
            case MovementDirection.ForwardLeftRight:
            case MovementDirection.BackLeftRight:
                animation.SetParameter("AttackType", AttackType.Thrust);
                break;

            case MovementDirection.Left:
            case MovementDirection.Right:
                animation.SetParameter("AttackType", AttackType.Slash);
                break;
            }
        }
        else
        {
            animation.SetParameter("AttackType", AttackType.None);
        }
    }
Ejemplo n.º 18
0
        private void SetConnectionString(GameSetting setting, string name, string providerName, string connectionString)
        {
            ConnectionString conn = null;

            if (name == GameSetting.DbSnscenter)
            {
                conn = setting.SnsCenter;
            }
            else if (name == GameSetting.DbPaycenter)
            {
                conn = setting.PayCenter;
            }
            else
            {
                conn = setting.Connections.Where(t => t.Name == name).FirstOrDefault();
                if (conn == null)
                {
                    conn = new ConnectionString()
                    {
                        Name = name
                    };
                    setting.Connections.Add(conn);
                }
            }
            conn.ProviderName = EnumParse <DbProviderType>(providerName);
            var    attrs      = connectionString.Split(';');
            string extendAttr = conn.Extend ?? "";

            foreach (var item in attrs)
            {
                string[] keyValue = item.Split('=');
                if (keyValue.Length == 2)
                {
                    string key   = keyValue[0].Trim().Replace(" ", "").ToLower();
                    string value = keyValue[1].Trim();
                    switch (key)
                    {
                    case "server":
                    case "datasource":
                        string[] arr = value.Split(',');
                        conn.DataSource = arr[0];
                        if (arr.Length > 1)
                        {
                            conn.Port = arr[1].ToInt();
                        }
                        break;

                    case "charset":
                        conn.Charset = value;
                        break;

                    case "database":
                    case "initialcatalog":
                        conn.Database = value;
                        break;

                    case "uid":
                    case "userid":
                        conn.Uid = value;
                        break;

                    case "pwd":
                    case "password":
                        conn.Pwd = value;
                        break;

                    case "port":
                        conn.Port = value.ToInt();
                        break;

                    default:
                        extendAttr += string.Format("{0}={1};", keyValue[0].Trim(), value);
                        break;
                    }
                }
            }
            conn.Extend = extendAttr;
        }
Ejemplo n.º 19
0
 public void SaveSettings(GameSetting gameSetting)
 {
     SaveSettings(gameSetting, Last_Settings);
 }
Ejemplo n.º 20
0
        private void SetAppSetting(GameSetting setting, string name, string value)
        {
            switch (name)
            {
            case "Product.Code":
                setting.GameCode = Convert.ToInt32(value);
                break;

            case "Product.Name":
                setting.GameName = Convert.ToString(value);
                break;

            case "Product.ServerId":
                setting.GameServerCode = Convert.ToInt32(value);
                break;

            case "Product.SignKey":
                setting.GameSignKey = value;
                break;

            case "Product.DesEnKey":
                setting.ProductDesEnKey = value;
                break;

            case "Product.ClientDesDeKey":
                setting.ClientDesDeKey = value;
                break;

            case "Game.Port":
                setting.SocketPort = Convert.ToInt32(value);
                break;

            case "Redis.Host":
                setting.Redis.Host = value;
                break;

            case "Redis.ReadHost":
                setting.Redis.ReadOnlyHost = value;
                break;

            case "Redis.Db":
                setting.Redis.Db = Convert.ToInt32(value);
                break;

            case "Redis.MaxWritePoolSize":
                setting.Redis.MaxWritePoolSize = Convert.ToInt32(value);
                break;

            case "Redis.MaxReadPoolSize":
                setting.Redis.MaxReadPoolSize = Convert.ToInt32(value);
                break;

            case "Redis.ConnectTimeout":
                setting.Redis.ConnectTimeout = Convert.ToInt32(value);
                break;

            case "Redis.PoolTimeOut":
                setting.Redis.PoolTimeOut = Convert.ToInt32(value);
                break;

            case "Game.Http.Host":
                setting.HttpHost = value;
                break;

            case "Game.Http.Port":
                setting.HttpPort = Convert.ToInt32(value);
                break;

            case "Game.Http.Name":
                setting.HttpName = value;
                break;

            case "Game.Http.Timeout":
                setting.HttpTimeout = Convert.ToInt32(value);
                break;

            case "MaxConnections":
                setting.SocketMaxConnections = Convert.ToInt32(value);
                break;

            case "Backlog":
                setting.SocketBacklog = Convert.ToInt32(value);
                break;

            case "MaxAcceptOps":
                setting.SocketMaxAcceptOps = Convert.ToInt32(value);
                break;

            case "BufferSize":
                setting.SocketBufferSize = Convert.ToInt32(value);
                break;

            case "Game.Action.EnableGZip":
                setting.ActionEnableGZip = Convert.ToBoolean(value);
                break;

            case "Game.Action.GZipOutLength":
                setting.ActionGZipOutLength = Convert.ToInt32(value);
                break;

            case "Game.Action.TypeName":
                setting.ActionTypeName = value;
                break;

            case "Game.Action.AssemblyName":
                setting.ActionAssemblyName = value;
                break;

            case "Game.Action.Script.TypeName":
                setting.ActionScriptTypeName = value;
                break;

            case "Python_Disable":
                setting.PythonDisable = Convert.ToBoolean(value);
                break;

            case "Script_IsDebug":
                setting.ScriptIsDebug = Convert.ToBoolean(value);
                break;

            case "CSharpRootPath":
                setting.CSharpRootPath = value;
                break;

            case "PythonRootPath":
                setting.PythonRootPath = value;
                break;

            case "Lua_Disable":
                setting.LuaDisable = Convert.ToBoolean(value);
                break;

            case "LuaRootPath":
                setting.LuaRootPath = value;
                break;

            case "ScriptMainClass":
                setting.ScriptMainClass = value;
                break;

            case "ScriptMainTypeName":
                setting.ScriptMainTypeName = value;
                break;

            case "ScriptSysAsmReferences":
                setting.ScriptSysAsmReferences = value.Split(';');
                break;

            case "ScriptAsmReferences":
                setting.ScriptAsmReferences = value.Split(';');
                break;

            case "Game.Entity.AssemblyName":
                setting.ModelEntityAssemblyName = value;
                break;

            case "Game.Script.DecodeFunc.TypeName":
                setting.ScriptDecodeFuncTypeName = value;
                break;

            case "Game.Remote.Script.TypeName":
                setting.RemoteScriptTypeName = value;
                break;

            case "Cache.global.period":
                setting.CacheGlobalPeriod = Convert.ToInt32(value);
                break;

            case "Cache.user.period":
                setting.CacheUserPeriod = Convert.ToInt32(value);
                break;

            case "Game.Cache.UpdateDbInterval":
                setting.CacheUpdateDbInterval = Convert.ToInt32(value);
                break;

            case "Cache.update.interval":
                setting.CacheUpdateInterval = Convert.ToInt32(value);
                break;

            case "Cache.expired.interval":
                setting.CacheExpiredInterval = Convert.ToInt32(value);
                break;

            case "Cache.enable.writetoDb":
                setting.CacheEnableWritetoDb = Convert.ToBoolean(value);
                break;

            case "Cache.Serializer":
                setting.CacheSerializer = value.ToEnum <StorageMode>();
                break;

            case "DataSyncQueueNum":
                setting.DataSyncQueueNum = Convert.ToInt32(value);
                break;

            case "SqlWaitSyncQueueNum":
                setting.SqlWaitSyncQueueNum = Convert.ToInt32(value);
                break;

            case "SqlSyncQueueNum":
                setting.SqlSyncQueueNum = Convert.ToInt32(value);
                break;

            case "Log.TableName.Format":
                setting.LogTableNameFormat = value;
                break;

            case "Log.PriorBuild.Month":
                setting.LogPriorBuildMonth = Convert.ToInt32(value);
                break;

            case "PublishType":
                setting.PublishType = EnumParse <PublishType>(value);
                break;

            case "EnableGM":
                setting.EnableGm = Convert.ToBoolean(value);
                break;

            case "Sns.PreAccount":
                setting.SnsAccountPrefixChar = value;
                break;

            case "Game.Language.TypeName":
                setting.LanguageTypeName = value;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 21
0
 public void LoadSettings(out GameSetting gameSetting)
 {
     gameSetting = SerializeUtility.Load <GameSetting>(Last_Settings, defaultSettings[GamePlayers.Four]);
 }
Ejemplo n.º 22
0
 public override object GetNew()
 {
     return(GameSetting.GetNew());
 }
Ejemplo n.º 23
0
    void Awake()
    {
        // First we check if there are any other instances conflicting
        if (Instance != null && Instance != this)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(this);

        // Here we save our singleton instance
        Instance = this;


        PlayerName = PlayerPrefs.GetString("PlayerName");
        LoadLevelResults();

        mCurrentLevelResult  = new LevelResult();
        mCurrentChapterLevel = new ChapterLevel();

        mCurrentChapterLevel.iChapter = PlayerPrefs.GetInt("LastChapter");
        mCurrentChapterLevel.iLevel   = PlayerPrefs.GetInt("LastLevel");

        bToolTipOff = PlayerPrefs.GetInt("bToolTipOff") > 0;

        //mLevelResults.Add (mCurrentChapterLevel, mCurrentLevelResult);

                #if !UNITY_EDITOR
        AndroidJavaClass  up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = up.GetStatic <AndroidJavaObject> ("currentActivity");
        AndroidJavaObject contentResolver = currentActivity.Call <AndroidJavaObject> ("getContentResolver");
        AndroidJavaClass  secure          = new AndroidJavaClass("android.provider.Settings$Secure");
        android_id = secure.CallStatic <string> ("getString", contentResolver, "android_id");
                #endif

        int iCounterApplicationLaunch;         //Счетчик запуска приложения
        iCounterApplicationLaunch = PlayerPrefs.GetInt("iCounterApplicationLaunch");
        Debug.Log("iCounterApplicationLaunch = " + iCounterApplicationLaunch);
        if (iCounterApplicationLaunch == 0)
        {
            switch (Application.systemLanguage.ToString())
            {
            case "Russian":
                Localization.language = "Русский";
                break;

            case "Ukrainian":
                Localization.language = "Українська";
                break;

            default:
                Localization.language = "English";
                break;
            }
        }
        iCounterApplicationLaunch++;
        GameSetting.Instance.googleAnalytics.LogEvent("Statistics", "StartApplication", "iCounterApplicationLaunch", iCounterApplicationLaunch);
        PlayerPrefs.SetInt("iCounterApplicationLaunch", iCounterApplicationLaunch);

        quitGame = false;
    }
 // Use this for initialization
 void Start()
 {
     settings = new GameSetting();
     settings.isLoggerOpenned = false;
 }
Ejemplo n.º 25
0
    static void OpenRemotePatchRootPath()
    {
        GameSetting gameSetting = Resources.Load <GameSetting>("GameSetting");

        System.Diagnostics.Process.Start(gameSetting.GetPatchRootPath());
    }
Ejemplo n.º 26
0
        public void Fill(GridStrategy gStrategy, GameSetting gameSetting, double _treshold)
        {
            StringBuilder sb = new StringBuilder();

            //nodes
            for (int i = 0; i < gStrategy.Rules.Count; i++)
            {
                AddNode(new Node(i, gStrategy.Rules[i]));
            }

            //edges
            double        max    = -1;
            List <Triple> values = new List <Triple>();

            for (int i = 0; i < gStrategy.Rules.Count - 1; i++)
            {
                for (int j = i + 1; j < gStrategy.Rules.Count; j++)
                {
                    GridRule r1 = gStrategy.Rules[i];
                    GridRule r2 = gStrategy.Rules[j];

                    //ball
                    double ballRuleSize = gStrategy.GridToReal(r1.Ball, gameSetting).DistanceFrom(
                        gStrategy.GridToReal(r2.Ball, gameSetting)
                        );

                    //mine
                    double mineSize = 0;
                    for (int k = 0; k < gameSetting.NUMBER_OF_ROBOTS - 1; k++)
                    {
                        mineSize += gStrategy.GridToReal(r1.Mine[r1.ZMine[k]], gameSetting).DistanceFrom(
                            gStrategy.GridToReal(r2.Mine[r2.ZMine[k]], gameSetting)
                            );
                    }

                    //oppnt
                    double oppntSize = 0;
                    for (int k = 0; k < gameSetting.NUMBER_OF_ROBOTS - 1; k++)
                    {
                        oppntSize += gStrategy.GridToReal(r1.Oppnt[r1.ZOppnt[k]], gameSetting).DistanceFrom(
                            gStrategy.GridToReal(r2.Oppnt[r2.ZOppnt[k]], gameSetting)
                            );
                    }

                    if (ballRuleSize + mineSize + oppntSize > max)
                    {
                        max = ballRuleSize + mineSize + oppntSize;
                    }

                    values.Add(new Triple(i, j, ballRuleSize + mineSize + oppntSize));
                }
            }

            for (int i = 0; i < values.Count; i++)
            {
                double norm = 1 - (values[i].z / max);
                //Console.WriteLine("{0} {1} {2} {3}", values[i].x, values[i].y, values[i].z, norm);

                if (norm >= _treshold)
                {
                    AddEdge(nodes[values[i].x], nodes[values[i].y], norm);
                    sb.AppendLine(values[i].x + " " + values[i].y + " " + Math.Round(norm, 3).ToString().Replace(',', '.'));
                }
            }

            /**
             * string filename = "GRAPH_" + gStrategy.Name + ".txt";
             * File.Delete(filename);
             * using (StreamWriter sw = new StreamWriter(new FileStream(filename, FileMode.CreateNew)))
             * {
             *  sw.Write(sb.ToString());
             *  sw.Close();
             * }
             */
        }
Ejemplo n.º 27
0
        public void operate(string type, string msg = "")
        {
            ThreadStart action = null;

            stateTitle = "";
            if (type == "init")
            {
                if (hwnd > 0)
                {
                    unbind();
                }
                action = () =>
                {
                    try
                    {
                        Thread.Sleep(3000);
                        init_window(int.Parse(msg));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                };
            }
            else if (type == "locate")
            {
                action = () =>
                {
                    locate(msg, setting.AutoTrans);
                };
            }
            else if (type == "shout")
            {
                action = () =>
                {
                    shout(msg);
                };
            }
            else if (type == "pause")
            {
                action = () =>
                {
                    setState("已暂停");
                };
            }
            else if (type == "screenshot")
            {
                action = () =>
                {
                    screenshot(new Random().Next() + ".bmp");
                };
            }
            else if (type == "fuhun-init")
            {
                stateTitle = "附魂";
                action     = () =>
                {
                    setState("报名中");
                    fuhun.Sign();
                    setState("准备竞技");
                    //findMap("中立-附魂战场");
                    DataEvent?.Invoke("fuhun-capture", fuhun.GetCapture());
                    setState("标记敌人中");
                    //DataEvent?.Invoke("fuhun-capture", @"E:\Users\Administrator\source\repos\WpfApp1\MyTool\bin\Debug\debug\fuhun\637159218502426004.bmp");
                };
            }
            else if (type == "fuhun-tag")
            {
                stateTitle = "附魂";
                action     = () =>
                {
                    setState("PK中");
                    fuhun.PK(msg);
                    DataEvent?.Invoke("fuhun-end", "");
                };
            }
            else if (type == "fight")
            {
                stateTitle = "打架";
                action     = () => fight.Action(msg);
            }
            else if (type == "kuafu-boss")
            {
                stateTitle = "跨服boss";
                action     = () => kuafuBoss.Action(msg);
            }
            else if (type == "game-setting")
            {
                setting = JsonConvert.DeserializeObject <GameSetting>(msg);
            }
            if (action != null)
            {
                killTask();
                thread = new Thread(action);
                thread.Start();
            }
        }
Ejemplo n.º 28
0
 public SimpleMoveNominator(GameSetting setting)
 {
     this.Setting = setting;
 }
Ejemplo n.º 29
0
 public void CreateGame(Player[] players, GameSetting setting)
 {
     m_wcfClient.CreateGame(players, setting);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 游客进入游戏(试玩游戏)
 /// </summary>
 /// <param name="site">所属商户</param>
 /// <param name="game">当前游戏配置</param>
 /// <param name="category">要进入的游戏类型,不指定则为默认</param>
 /// <param name="code">要进入的单独游戏的代码</param>
 /// <returns></returns>
 public LoginResult Guest(GameSetting game, GameCategory?category, string code)
 {
     // 调用API登录接口
     return(game.Setting.Guest(new LoginUser()));
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Called when the game started.
 /// </summary>
 /// <param name="gameInfo">Information about current game status.</param>
 /// <param name="gameSetting">Game settings.</param>
 public abstract void Initialize(GameInfo gameInfo, GameSetting gameSetting);
Ejemplo n.º 32
0
        /// <summary>
        /// Note: lingshang and haidi should be obtained in baseHandStatus
        /// </summary>
        /// <param name="playerIndex"></param>
        /// <param name="CurrentRoundStatus"></param>
        /// <param name="winningTile"></param>
        /// <param name="baseHandStatus"></param>
        /// <returns></returns>
        public static PointInfo GetPointInfo(int playerIndex, ServerRoundStatus CurrentRoundStatus, Tile winningTile,
                                             HandStatus baseHandStatus, Tile[] doraTiles, Tile[] uraDoraTiles, int beiDora, GameSetting yakuSettings)
        {
            var zhenting = CurrentRoundStatus.IsZhenting(playerIndex);

            if (zhenting && !baseHandStatus.HasFlag(HandStatus.Tsumo))
            {
                return(new PointInfo());
            }
            var handData   = CurrentRoundStatus.HandData(playerIndex);
            var handStatus = baseHandStatus;

            if (MahjongLogic.TestMenqing(handData.Melds))
            {
                handStatus |= HandStatus.Menqing;
            }
            // test richi
            if (CurrentRoundStatus.RichiStatus(playerIndex))
            {
                handStatus |= HandStatus.Richi;
                // test one-shot
                if (yakuSettings.HasOneShot && CurrentRoundStatus.OneShotStatus(playerIndex))
                {
                    handStatus |= HandStatus.OneShot;
                }
                // test WRichi
                if (CurrentRoundStatus.FirstTurn)
                {
                    handStatus |= HandStatus.WRichi;
                }
            }

            // test first turn
            if (CurrentRoundStatus.FirstTurn)
            {
                handStatus |= HandStatus.FirstTurn;
            }
            var roundStatus = new RoundStatus
            {
                PlayerIndex       = playerIndex,
                OyaPlayerIndex    = CurrentRoundStatus.OyaPlayerIndex,
                CurrentExtraRound = CurrentRoundStatus.Extra,
                RichiSticks       = CurrentRoundStatus.RichiSticks,
                FieldCount        = CurrentRoundStatus.Field,
                TotalPlayer       = CurrentRoundStatus.TotalPlayers
            };
            var isQTJ = CurrentRoundStatus.GameSettings.GameMode == GameMode.QTJ;

            return(MahjongLogic.GetPointInfo(handData.HandTiles, handData.Melds, winningTile,
                                             handStatus, roundStatus, yakuSettings, isQTJ, doraTiles, uraDoraTiles, beiDora));
        }
 public SimpleBoardEvaluator(GameSetting setting)
 {
     this.Setting = setting;
 }