Exemplo n.º 1
0
        /// <summary>
        /// 技能攻击
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="par"></param>
        /// <returns></returns>
        private bool AttackJiNeng(FightObject fighter, int level, GameConfig gc)
        {
            //伤害类型 物理0  魔法1
            int injuryType = gc.Value.GetIntOrDefault("InjuryType");

            List<ActionResult> results = SkillAttack(fighter, level, gc, injuryType);
            if (results.Count > 0)
            {
                FightAction action = fighter.Action;
                action.Result = results;
                int fightCount = action.FightCount;
                action.FightCount = FightAction.HasAction;
                m_actions.Add(action);

                //蓄力,第二次攻击..
                SkillBuffer buff = fighter.FindBuffer(BufferType.XuLi);
                if (buff != null)
                {
                    action = action.CopyNew();
                    action.FightCount = fightCount;
                    fighter.Action = action;
                    List<ActionResult> results2 = SkillAttack(fighter, level, gc, injuryType);
                    if (results2.Count > 0)
                    {
                        action.Result = results2;
                        action.FightCount = FightAction.HasAction;
                        m_actions.Add(action);
                    }
                }
                return true;
            }
            return false;
        }
Exemplo n.º 2
0
        private List<ActionResult> SkillAttack(FightObject fighter, int level, GameConfig gc, int injuryType)
        {
            List<ActionResult> results = new List<ActionResult>();
            AttackDamage attack;
            AttackParameter par = new AttackParameter(gc, level);
            if (injuryType == 0)
            {
                attack = new AttackPhysical(fighter, par);
            }
            else
            {
                attack = new AttackMagic(fighter, par);
            }

            TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType");
            if (targetType == TargetType.Single)
            {
                var targets = FilterTargets(fighter);
                if (targets.Count > 0)
                {
                    ActionResult result = Attack(attack, targets[0]);
                    results.Add(result);
                }
            }
            else
            {
                var targets = EnemyTargets(fighter, targetType, par);
                foreach (var v in targets)
                {
                    ActionResult result2 = Attack(attack, v, targets);
                    results.Add(result2);
                }
            }
            return results;
        }
Exemplo n.º 3
0
 public PersonalFam(GameConfig gc, string difficulty)
     : base(gc, difficulty)
 {
     Variant v = gc.Value.GetVariantOrDefault("Limit");
     int dayDev = v.GetIntOrDefault("DayDev");
     int familyTask = v.GetIntOrDefault("FamilyTask");
 }
Exemplo n.º 4
0
 //复活
 private bool DaoJuRevive(FightPlayer a, int p, PlayerEx package, GameConfig c)
 {
     string target = a.Action.Target;
     FightPlayer t = m_teamA.FirstOrDefault(x => x.ID == target) as FightPlayer;
     if (t == null) t = m_teamB.FirstOrDefault(x => x.ID == target) as FightPlayer;
     if (t == null || t.IsLive) return false;
     //检查使用限制..
     //if (!SupplyLimit(note, c)) return false;
     if (a.Player.RemoveGoods(p, GoodsSource.DaoJuRevive))
     {
         ActionResult result = new ActionResult(target);
         //百分比复活生命
         int hp = (int)(t.Life.ShengMing * c.Value.GetDoubleOrDefault("A"));
         int mp = (int)(t.Life.MoFa * c.Value.GetDoubleOrDefault("B")) - t.MP;
         if (mp < 0) mp = 0;
         t.AddHPAndMP(hp, mp);
         if (hp > 0)
         {
             result.Value["HP"] = hp;
             result.Value["ShengMing"] = t.HP;
         }
         if (mp > 0)
         {
             result.Value["MP"] = mp;
             result.Value["MoFa"] = t.MP;
         }
         result.ActionFlag |= ActionFlag.Supply;
         a.Action.Result = new List<ActionResult>() { result };
         a.Action.FightCount = FightAction.HasAction;
         m_actions.Add(a.Action);
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
    /// <summary>
    /// Set global game config data, such as API endpoints, given a valid input string
    /// </summary>
    /// <param name="data">Data to be used to set config; must conform to GameConfig model.</param>
    /// <param name="configTypeOverride">May be used to override config type in editor only (development, staging, production).</param>
    public static void SetGameConfig(string data, string configTypeOverride=null) {

        // Set config only if there is none set
        if(config != null) 
            return;

        // Set global config
        config = JsonReader.Deserialize<GameConfig>(data);
        
        // Set the current game config based on the environment
        #if UNITY_EDITOR
        
            currentConfig = config.local;

            // If override set, use that
            if(configTypeOverride != null) {
                if(configTypeOverride == "development")
                    currentConfig = config.development;
                else if(configTypeOverride == "staging")
                    currentConfig = config.staging;
                else if(configTypeOverride == "production")
                    currentConfig = config.production;
            }


        #elif DEVELOPMENT_BUILD
           currentConfig = config.development;
        #elif IS_PRODUCTION
           currentConfig = config.production;
        #else
           currentConfig = config.staging;
        #endif

    }
        public static PickByPriorityDescription GetDefaultTrashDescription(GameConfig gameConfig)
        {
            var result = new List<CardAcceptanceDescription>();
            result.Add(CardAcceptanceDescription.For(Cards.Curse));
            if (gameConfig.NeedsRuins)
            {
                result.Add(CardAcceptanceDescription.For(Cards.RuinedVillage));
                result.Add(CardAcceptanceDescription.For(Cards.RuinedMarket));
                result.Add(CardAcceptanceDescription.For(Cards.Survivors));
                result.Add(CardAcceptanceDescription.For(Cards.RuinedVillage));
                result.Add(CardAcceptanceDescription.For(Cards.AbandonedMine));
            }

            result.Add(CardAcceptanceDescription.For(Cards.Estate, CountSource.CountOfPile, Cards.Province, Comparison.GreaterThan, 2));

            if (gameConfig.useShelters)
            {
                result.Add(CardAcceptanceDescription.For(Cards.Hovel));
                result.Add(CardAcceptanceDescription.For(Cards.OvergrownEstate));
            }

            result.Add(CardAcceptanceDescription.For(Cards.Copper));

            return new PickByPriorityDescription(result.ToArray());
        }
Exemplo n.º 7
0
 /// <summary>
 /// 道具使用限制
 /// </summary>
 /// <param name="note"></param>
 /// <param name="gc"></param>
 /// <returns></returns>
 public static bool SupplyLimit(UserNote note, GameConfig gc)
 {
     Variant limit = gc.Value.GetVariantOrDefault("UserLimit");
     if (limit == null) return true;
     //补充类使用限制
     return CheckLevel(note, limit);
 }
Exemplo n.º 8
0
 public TeamInstanceBusiness(GameConfig gc, string difficulty)
 {
     m_members = Empty;
     int increment = Interlocked.Increment(ref __staticIncrement) & 0x00ffffff;
     int t = GetTimestampUtcNow();
     m_id = (((long)t) << 32) | ((UInt32)increment);
     m_gc = gc;
     m_difficulty = difficulty;
     m_movie = new List<Variant>();
     m_currentApcs = new List<EctypeApc>();
     foreach (var item in gc.Value.GetValueOrDefault<IList>("Movie"))
     {
         if (item is Variant)
         {
             m_movie.Add((Variant)item);
         }
     }
     Variant v = gc.Value.GetVariantOrDefault("Limit");
     if (v != null)
     {
         m_intoLimit = new IntoLimit(m_gc.ID, m_gc.Name, v);
         int maxStay = v.GetIntOrDefault("MaxStay");
         if (maxStay > 0)
         {
             OverTime = DateTime.UtcNow.AddSeconds(maxStay);
         }
     }
 }
Exemplo n.º 9
0
    void Start()
    {
        AudioManager.PlayBgm(this.bgmAudio);

        var config = new GameConfig
        {
            players = new PlayersConfig
            {
                players = new List<PlayerConfig>
                {
                    new PlayerConfig
                    {
                        name = "David",
                    },
                    new PlayerConfig
                    {
                        name = "Steven"
                    }
                }
            },
            stageLevelConfig = new StageLevelConfig
            {
                stages = new List<StageConfig>
                {
                    new StageConfig
                    {
                        levels = new List<LevelConfig>
                        {
                            new LevelConfig
                            {
                                enemyWaves = new List<EnemyWaveConfig>
                                {
                                    new EnemyWaveConfig
                                    {
                                        enemyCountMap = new List<EnemyCountConfig>
                                        {
                                            new EnemyCountConfig
                                            {
                                                name = "Bandit",
                                                count = 1
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }
            }
        };

        Stream fStream = new FileStream(@"Configs\xmlText.xml", FileMode.Open, FileAccess.ReadWrite);

        XmlSerializer xmlFormat = new XmlSerializer(typeof(GameConfig));
        //xmlFormat.Serialize(fStream, config);
        var configtest = xmlFormat.Deserialize(fStream);
        configtest.GetType();
    }
Exemplo n.º 10
0
 public ArenaSkill(GameConfig gc)
 {
     m_v = gc.Value;
     m_injurytype = m_v.GetIntOrDefault("InjuryType");
     m_rolelimit = m_v.GetIntOrDefault("RoleLimit");
     m_range = m_v.GetIntOrDefault("Range");
     m_coolingtime = m_v.GetIntOrDefault("CoolingTime");
 }
        public static StrategyDescription GetDefaultDescription(GameConfig gameConfig)
        {
            var result = new StrategyDescription(
                GetDefaultPurchaseOrder(gameConfig),
                GetDefaultTrashDescription(gameConfig));

            return result;
        }
Exemplo n.º 12
0
 /// <summary>
 /// 任务触发d
 /// </summary>
 /// <param name="pb"></param>
 /// <param name="gc"></param>
 public static void TaskBack(PlayerBusiness pb, GameConfig gc)
 {
     Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.Name, gc, 0, 0);
     if (task != null)
     {
         pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
     }
 }
 public static PickByPriorityDescription GetDefaultPurchaseOrder(GameConfig gameConfig)
 {
     return new PickByPriorityDescription(
         CardAcceptanceDescription.For(Cards.Province, CountSource.CountAllOwned, Cards.Gold, Comparison.GreaterThanEqual, 2),
         CardAcceptanceDescription.For(Cards.Duchy, CountSource.CountOfPile, Cards.Province, Comparison.LessThanEqual, 4),
         CardAcceptanceDescription.For(Cards.Estate, CountSource.CountOfPile, Cards.Province, Comparison.LessThanEqual, 2),
         CardAcceptanceDescription.For(Cards.Gold),
         CardAcceptanceDescription.For(Cards.Silver));
 }
Exemplo n.º 14
0
        public LauncherForm()
        {
            InitializeComponent();

            cmoDisplayMode.Items.AddRange(DisplayModesEnumerator.GetAvailableDisplayModes().ToArray());

            gameConfig = GameConfig.Load();

            UpdateControls();
        }
Exemplo n.º 15
0
 public static void ArenaInfo(GameConfig gc)
 {
     m_gc = gc;
     m_v = m_gc.Value;
     m_win = m_v.GetValue<IList>("Win");
     m_petnumber = m_v.GetValue<IList>("PetNumber");
     m_petlevel = m_v.GetValue<IList>("PetLevel");
     m_group = m_v.GetValue<IList>("Group");
     m_scene = m_v.GetValue<IList>("Scene");
     m_preparetime = m_v.GetValue<IList>("PrepareTime");
     m_gametime = m_v.GetValue<IList>("GameTime");
 }
Exemplo n.º 16
0
        public AttackParameter(GameConfig gc, int level)
        {
            m_gc = gc;
            this.Level = level;
            this.BufferID = gc.Value.GetStringOrDefault("BufferID");
            this.AddHitRate = gc.Value.GetDoubleOrDefault("AddHitRate");

            m_gcl = gc.Value.GetVariantOrDefault(level.ToString());
            this.A = m_gcl.GetDoubleOrDefault("A");
            this.B = m_gcl.GetDoubleOrDefault("B");
            this.C = m_gcl.GetDoubleOrDefault("C");
        }
Exemplo n.º 17
0
 public SceneSubEctype(GameConfig scene)
     : base(scene)
 {
     IsOverTime = true;
     m_showAll = false;
     Variant v = scene.Value.GetVariantOrDefault("Config");
     m_ectypeID = v.GetStringOrDefault("FatherScene");
     if (string.IsNullOrEmpty(m_ectypeID))
     {
         LogWrapper.Warn("father err:" + this.ID);
     }
 }
Exemplo n.º 18
0
  protected override void OnEnter(object onEnterParams = null) {
    // rotate player
    Rigidbody2D rigidbody = GameController.Instance.Player.GetComponent<Rigidbody2D>();
    SpinCoroutine = GameController.Instance.StartCoroutine(SpinPlayer(rigidbody));

    GameConfig = GameController.Instance.GameConfig;
    AudioSource audio = GameObject.Find("background_music").GetComponent<AudioSource>();
    AudioClip clip = GameConfig.win_loop;
    audio.Stop();
    audio.clip = clip;
    audio.Play();
  }
Exemplo n.º 19
0
 public SceneBattle(GameConfig scene)
     : base(scene)
 {
     m_showAll = true;
     Variant v = scene.Value.GetVariantOrDefault("Config");
     if (v != null)
     {
         m_maxStay = v.GetIntOrDefault("MaxStay");
         if (m_maxStay < 0) m_maxStay = 0;
         if (DeadDestination == null)
         {
             LogWrapper.Warn("Unknown dead go home:" + this.ID);
         }
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// 增加每日日常任务
        /// </summary>
        /// <param name="player"></param>
        /// <param name="gc"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private static int AddDayTask(PlayerBusiness player, GameConfig gc, int p)
        {
            PlayerEx dt = player.Value["DayTask"] as PlayerEx;
            Variant v_dt = dt.Value;
            //道具
            int daily = gc.Value.GetIntOrDefault("Daily");
            int total = v_dt.GetIntOrDefault("Total");
            int max = v_dt.GetIntOrDefault("Max");

            Variant mv = MemberAccess.MemberInfo(player.MLevel);
            if (mv != null)
            {
                max += mv.GetIntOrDefault("ShiBan") * 5;
            }

            if (total >= max)
            {
                //您今天的日常任务已经扩充到上限最大值,请明天再使用探险者石板
                return GoodsReturn.UseGoods8;
            }
            if (player.RemoveGoods(p, GoodsSource.DoubleUse))
            {
                if (total + daily <= max)
                {
                    v_dt.SetOrInc("Total", daily);
                }
                else
                {
                    v_dt["Total"] = max;
                }

                //如果不存在日常任务
                if (!TaskAccess.Instance.IsDayTask(player.ID, 2))
                {
                    GameConfig gn = GameConfigAccess.Instance.GetDayTaskOne(player.Level, 2);
                    if (gn != null)
                    {
                        DayTask(player, true);
                    }
                }
                dt.Save();
                player.Call(ClientCommand.UpdateActorR, new PlayerExDetail(dt));
                return 0;
            }
            return GoodsReturn.AnswerNoGood;
        }
Exemplo n.º 21
0
        /// <summary>
        /// 星力空瓶的使用
        /// </summary>
        /// <param name="player"></param>
        /// <param name="gc"></param>
        /// <param name="p"></param>
        private static void Bottles(PlayerBusiness player, GameConfig gc, Variant p)
        {
            Variant v = gc.Value;
            //需要星力值
            int outstar = v.GetIntOrDefault("OutStar");
            if (player.StarPower < outstar)
            {
                player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6));
                return;
            }
            Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
            //目标道具
            string goodsid = v.GetStringOrDefault("GoodsID");

            Variant tmp = new Variant();
            tmp.SetOrInc("Number" + p.GetIntOrDefault("H"), 1);
            dic.Add(goodsid, tmp);

            if (BurdenManager.IsFullBurden(player.B0, dic))
            {
                player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.BurdenB0Full));
                return;
            }

            if (!player.AddStarPower(-outstar, FinanceType.UseGoods))
            {
                player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6));
                return;
            }

            if (player.RemoveGoods(p.GetIntOrDefault("P"), GoodsSource.DoubleUse))
            {
                player.AddGoods(dic, GoodsSource.Bottles);
                player.UseGoodsR(true, goodsid);
                player.FinishNote(FinishCommand.StarBottle);
            }
            else
            {
                player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.UseGoods2));
            }
        }
Exemplo n.º 22
0
        public SceneApc(GameConfig config)
        {
            ID = config.ID;
            Name = config.Name;
            SubType = config.SubType;
            Variant v = config.Value;
            if (v != null)
            {
                SceneID = v.GetStringOrDefault("SceneID");
                ApcID = v.GetStringOrDefault("VisibleAPC");
                Count = v.GetIntOrDefault("Count");
                DelaySecond = v.GetIntOrDefault("DelaySecond");
                TotalCount = v.GetIntOrDefault("TotalCount");
                Batch = v.GetIntOrDefault("Batch");
                GrowSecond = v.GetIntOrDefault("GrowSecond");

                Range = RangeHelper.NewRectangle(v.GetVariantOrDefault("Range"), true);
            }

            m_showTime = new ConcurrentDictionary<int, DateTime>();
            m_activeApcs = new ConcurrentDictionary<int, ActiveApc>();
        }
Exemplo n.º 23
0
    void Awake()
    {
        if(instance != null) {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);

        levels = new LevelInfo[] {
            new LevelInfo(
                new Dictionary<PlantType,int>() { { PlantType.Tiny, 3 } },
                new Currency(1, 0, 0),
                new PlantType[] { PlantType.Medium, PlantType.Flower }),
            new LevelInfo(
                new Dictionary<PlantType,int>() { { PlantType.Tiny, 2}, {PlantType.Medium, 2}},
                new Currency(2, 0, 0),
                new PlantType[] { PlantType.Flower }),
            new LevelInfo(
                new Dictionary<PlantType,int>() { {PlantType.Flower, 3}, {PlantType.Medium, 2}},
                new Currency(4, 0, 0))
        };
    }
Exemplo n.º 24
0
        private static void HostMultiplayer()
        {
            var cts = new CancellationTokenSource();

            var player = new Player {
                Name = GetInput("Enter player name", ".+")
            };
            var opponent = new Player();

            var options = new GameConfig
            {
                Players = new[]
                {
                    player,
                    opponent
                }
            }
            .WithMapHeight(10)
            .WithMapWidth(10);

            var gameState = new Game(options);

            Info("Waiting for players...");

            var CONNECTING = new object();

            Listener.PlayerConnected += p =>
            {
                lock (CONNECTING)
                {
                    if (!Listener.WaitForPlayers)
                    {
                        return;
                    }
                    //Todo: handle players joining in a better way
                    Listener.WaitForPlayers = false;
                    gameState.Players[1]    = opponent = p;

                    foreach (var ship in opponent.Map.Fleet)
                    {
                        SetEnemyShipEvents(opponent, ship);
                    }

                    Msg($"{opponent.Name} Connected!");
                }
            };

            var hostTask = Listener.HostGame(gameState, cts.Token);



            for (var i = 0; i < gameState.NumberOfShips; i++)
            {
                SetPlayerShip(player);
                Console.Clear();
                player.Map.Draw(true);
            }



            var waitCount = 0;

            while (Listener.WaitForPlayers)
            {
                Console.Clear();
                // doesnt work
                Info($"Waiting for players{string.Join("", Enumerable.Repeat(".", waitCount).ToArray())}");
                waitCount++;
                Thread.Sleep(2000);

                if (waitCount != 10)
                {
                    continue;
                }

                if (GetInput("No one is joining. Keep waiting?", "y|Y|n|N").ToUpper() == "N")
                {
                    return;
                }
                else
                {
                    waitCount = 0;
                }
            }


            Listener.PlayerShot += s =>
            {
                if (!player.Map.Fire(s))
                {
                    EventQueue.Enqueue(() => Info($"{opponent.Name} miss"));
                }
            };

            //Init
            Draw(player.Map, opponent.Map, true);

            while (player.Map.HasActiveShips || opponent.Map.HasActiveShips)
            {
                EventQueue.Enqueue(Console.Clear);
                EventQueue.Enqueue(() => Draw(player.Map, opponent.Map, true));

                if (!opponent.Map.Fire(player, GetCoordinate()))
                {
                    EventQueue.Enqueue(() => Info($"{player.Name} miss"));
                }

                DoEvents();
            }

            cts.Cancel();
            hostTask.Wait();
        }
Exemplo n.º 25
0
 public SceneEctype(GameConfig scene)
     : base(scene)
 {
     m_showAll = false;
 }
Exemplo n.º 26
0
 //unpause the game
 public void resume()
 {
     GameConfig.setPaused(false);
 }
Exemplo n.º 27
0
        public static void RandomGames()
        {
            int total = 1;
            var watch = Stopwatch.StartNew();

            var gameConfig = new GameConfig()
            {
                StartPlayer      = -1,
                Player1Name      = "FitzVonGerald",
                Player1HeroClass = CardClass.PALADIN,
                Player1Deck      = new List <Card>()
                {
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Knight"),
                    Cards.FromName("Stormwind Knight")
                },
                Player2Name      = "RehHausZuckFuchs",
                Player2HeroClass = CardClass.PALADIN,
                Player2Deck      = new List <Card>()
                {
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Knight"),
                    Cards.FromName("Stormwind Knight")
                },
                FillDecks    = false,
                Shuffle      = true,
                SkipMulligan = false,
                Logging      = true,
                History      = true
            };

            int turns = 0;

            int[] wins = new[] { 0, 0 };
            for (int i = 0; i < total; i++)
            {
                var game = new Game(gameConfig);
                game.StartGame();

                game.Process(ChooseTask.Mulligan(game.Player1, new List <int>()));
                game.Process(ChooseTask.Mulligan(game.Player2, new List <int>()));

                game.MainReady();

                while (game.State != State.COMPLETE)
                {
                    List <PlayerTask> options = game.CurrentPlayer.Options();
                    PlayerTask        option  = options[Rnd.Next(options.Count)];
                    //Console.WriteLine(option.FullPrint());
                    game.Process(option);
                }
                turns += game.Turn;
                if (game.Player1.PlayState == PlayState.WON)
                {
                    wins[0]++;
                }
                if (game.Player2.PlayState == PlayState.WON)
                {
                    wins[1]++;
                }
                Console.WriteLine("game ended");
                // Console.Write(game.PowerHistory.ToString());
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"powerhistory.log")) {
                    file.WriteLine(game.PowerHistory.Print());
                }
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"logger.log"))
                {
                    foreach (LogEntry log in game.Logs)
                    {
                        file.WriteLine(log.ToString());
                    }
                }
            }

            watch.Stop();

            Console.WriteLine($"{total} games with {turns} turns took {watch.ElapsedMilliseconds} ms => " +
                              $"Avg. {watch.ElapsedMilliseconds / total} per game " +
                              $"and {watch.ElapsedMilliseconds / (total * turns)} per turn!");
            Console.WriteLine($"playerA {wins[0] * 100 / total}% vs. playerB {wins[1] * 100 / total}%!");
        }
Exemplo n.º 28
0
 public SettingsViewModel(GameConfig gameConfig, IGameConfigStorage gameConfigStorage)
 {
     GameConfig                  = gameConfig;
     _gameConfigStorage          = gameConfigStorage;
     GameConfig.PropertyChanged += GameConfigOnPropertyChanged;
 }
Exemplo n.º 29
0
 public void Init(WeaponConfig weapon)
 {
     gameConfig = ConfigManager.main.GetConfig("GameConfig") as GameConfig;
     config     = weapon;
 }
Exemplo n.º 30
0
 /// <summary>
 /// 实例化接口参数
 /// </summary>
 public Game_Txj()
 {
     game = games.GetGame("txj");                                   //获取游戏
     gc   = gcs.GetGameConfig(game.Id);                             //获取游戏参数
 }
Exemplo n.º 31
0
 /// <summary>
 /// 更新游戏配置
 /// </summary>
 /// <param name="gameConfig">游戏配置实体</param>
 public void UpdateGameConfig(GameConfig gameConfig)
 {
     aidePlatformData.UpdateGameConfig(gameConfig);
 }
Exemplo n.º 32
0
 void Init()
 {
     config         = ConfigManager.main.GetConfig("GameConfig") as GameConfig;
     playerPosition = ConfigManager.main.GetConfig("PlayerPosition") as PlayerPosition;
 }
Exemplo n.º 33
0
        //checks if a new game version is existing and downloads it
        private void GetNewGame()
        {
            bool needsFullVersion;
            GameConfig gameConfig = new GameConfig();
            VersionsConfig versionsConfig = new VersionsConfig();
            DialogResult res;

            //check if there is a game path directory
            StatusChanged(this,new StatusEventArgs("Checking game path..."));
            if (!Directory.Exists(updaterConfig.GamePath))
            {
                NeedsGamePath(this, EventArgs.Empty);
                return;
            }

            //load the configuration file of the game
            StatusChanged(this,new StatusEventArgs("Loading game configuration file..."));
            //if there is NO configuration file a full version is needed
            if (!gameConfig.Load(updaterConfig.GamePath + updaterConfig.GameConfigurationFile))
            {
                StatusChanged(this, new StatusEventArgs("No game found in selected directory!"));
                res = MessageBox.Show("In the chosen folder was no game found. Shall it be installed into " +
                    "the selected directory?", "Install?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == DialogResult.No)
                {
                    NeedsGamePath(this, EventArgs.Empty);
                    return;
                }
                needsFullVersion = true;
            }
            //if there is A configuration file an update is needed
            else
                needsFullVersion = false;

            //load the new versions available on the server
            StatusChanged(this,new StatusEventArgs("Checking new game versions..."));
            versionsConfig.LoadNewVersions(updaterConfig.ServerPath + updaterConfig.VersionsConfigurationFile,
                gameConfig.VersionNumber, needsFullVersion);

            //if there are new versions
            if (versionsConfig.VersionsForUpdate.Count == 0)
            {
                if (gameConfig.VersionNumber == GameConfig.DefaultVersionNumber)
                {
                    StatusChanged(this, new StatusEventArgs("Unable to install. No version found on server."));
                    MessageBox.Show("Unable to install. No version found on server.", "No version found",
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    OnClose(this, EventArgs.Empty);
                }
                else
                {
                    StatusChanged(this, new StatusEventArgs("No new Versions found!"));
                    UpdateFinished(this, EventArgs.Empty);
                }
                return;
            }

            //load files for download into list
            StatusChanged(this,new StatusEventArgs("Creating file lists..."));
            if (!LoadGameFilesIntoDownloadList(versionsConfig))
            {
                StatusChanged(this,new StatusEventArgs("Error on creating file lists for the game!"));
                MessageBox.Show("Error on creating file lists for the game!", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                OnClose(this, EventArgs.Empty);
                return;
            }

            //create temporary download directory
            StatusChanged(this,new StatusEventArgs("Creating temporary download directory..."));
            if (!CreateTempFolder())
            {
                StatusChanged(this,new StatusEventArgs("Error on creating temporary download directory!"));
                MessageBox.Show("Error on creating temporary download directory!", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                OnClose(this, EventArgs.Empty);
                return;
            }

            //start the download
            StatusChanged(this,new StatusEventArgs("Downloading..."));
            fileTransfer.DownloadFilesAsync(filesToDownload.Values.ToList(), true,
                new Uri(updaterConfig.ServerPath), updaterConfig.TempFolder + "/",
                delegate(FileTransferResult result) //callback function after download is completed
                {
                    filesToDownload.Clear();
                    //download successful
                    if (result == FileTransferResult.Success)
                        InstallGame(versionsConfig.LatestUpdate);
                    //download unsuccessful
                    else
                    {
                        MessageBox.Show("Download Failure! Please Try Again",
                            "Failure!",MessageBoxButtons.OK, MessageBoxIcon.Error);
                        OnClose(this, EventArgs.Empty);
                    }
                }
            );
        }
Exemplo n.º 34
0
    void OnLoadBtn()
    {
        if (mFileName.text == "")
        {
            return;
        }

        string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/";

        if (!Directory.Exists(_strFilePath))
        {
            Directory.CreateDirectory(_strFilePath);
        }


        for (int i = 0; i < mItemList.Count; i++)
        {
            Destroy(mItemList[i].gameObject);
        }
        mItemList.Clear();

        for (int i = 0; i < mNpcList.Count; i++)
        {
            Destroy(mNpcList[i].gameObject);
        }
        mNpcList.Clear();

        if (null != Block45Man.self.DataSource)
        {
            Block45Man.self.DataSource.Clear();
        }

        if (File.Exists(_strFilePath + mFileName.text + ".txt"))
        {
            using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + ".txt", FileMode.Open, FileAccess.Read))
            {
                BinaryReader _in = new BinaryReader(_fileStream);

                int readVersion = _in.ReadInt32();
                switch (readVersion)
                {
                case 2:
                    int Size = _in.ReadInt32();
                    for (int i = 0; i < Size; i++)
                    {
                        IntVector3 index = new IntVector3(_in.ReadInt32(), _in.ReadInt32(), _in.ReadInt32());
                        Block45Man.self.DataSource.SafeWrite(new B45Block(_in.ReadByte(), _in.ReadByte()), index.x, index.y, index.z, 0);
                    }
                    break;
                }
                _in.Close();
            }
        }

        if (File.Exists(_strFilePath + mFileName.text + "SubInfo.txt"))
        {
            using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + "SubInfo.txt", FileMode.Open, FileAccess.Read))
            {
                BinaryReader _in = new BinaryReader(_fileStream);

                int version = _in.ReadInt32();
                int count   = _in.ReadInt32();
                switch (version)
                {
                case 1:
                    for (int i = 0; i < count; i++)
                    {
                        Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());

                        CreateReq req = new CreateReq();
                        req.mIsLoad = true;
                        req.mType   = OpType.NpcSetting;
//						req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity);
//						req.mReq.ReqFinishWithReqHandler += OnSpawned;
//						mCreateReqList.Add(req);
                        GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject;
                        obj.transform.position = npcPos;
                        CreateMode(obj, req);
                    }
                    break;

                case 2:
                    for (int i = 0; i < count; i++)
                    {
                        Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());

                        CreateReq req = new CreateReq();
                        req.mIsLoad = true;
                        req.mType   = OpType.NpcSetting;
//						req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity);
//						req.mReq.ReqFinishWithReqHandler += OnSpawned;
//						mCreateReqList.Add(req);
                        GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject;
                        obj.transform.position = npcPos;
                        CreateMode(obj, req);
                    }
                    count = _in.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        Vector3    itemPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());
                        Quaternion ItemRot = Quaternion.Euler(new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()));
                        int        itemID  = _in.ReadInt32();

                        ItemProto itemData = ItemProto.GetItemData(itemID);
                        if (null == itemData || !itemData.IsBlock())
                        {
                            continue;
                        }

                        CreateReq req = new CreateReq();
                        req.mIsLoad = true;
                        req.mType   = OpType.ItemSetting;
                        req.mItemId = itemID;
//						req.mReq = AssetBundlesMan.Instance.AddReq(ItemData.GetItemData(itemID).m_ModelPath, itemPos, ItemRot);
//						req.mReq.ReqFinishWithReqHandler += OnSpawned;
//						mCreateReqList.Add(req);
                        GameObject obj = Instantiate(Resources.Load(ItemProto.GetItemData(itemID).resourcePath)) as GameObject;
                        obj.transform.position      = itemPos;
                        obj.transform.localRotation = ItemRot;
                        CreateMode(obj, req);

//						CreateMode(Instantiate(Resources.Load(ItemData.GetItemData(itemID).m_ModelPath)) as GameObject, req);
                    }
                    break;
                }
                _in.Close();
            }
        }
    }
Exemplo n.º 35
0
    void Save(string name)
    {
        if (name == "")
        {
            Debug.LogError("Inputname is null");
            return;
        }

        string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/";

        if (!Directory.Exists(_strFilePath))
        {
            Directory.CreateDirectory(_strFilePath);
        }

        _strFilePath += name + ".txt";

        using (FileStream fileStream = new FileStream(_strFilePath, FileMode.Create, FileAccess.Write))
        {
            BinaryWriter _out = new BinaryWriter(fileStream);
            if (_out == null)
            {
                Debug.LogError("On WriteRecord FileStream is null!");
                return;
            }

            if (Block45Man.self != null)
            {
                byte[] writeData = Block45Man.self.DataSource.ExportData();
                if (writeData != null)
                {
                    _out.Write(writeData);
                }
                else
                {
                    _out.Write(0);
                }
            }
            else
            {
                _out.Write(0);
            }

            _out.Close();
            fileStream.Close();
        }


        _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/" + name + "SubInfo.txt";
        using (FileStream fileStream = new FileStream(_strFilePath, FileMode.Create, FileAccess.Write))
        {
            BinaryWriter _out = new BinaryWriter(fileStream);
            if (_out == null)
            {
                Debug.LogError("On WriteRecord FileStream is null!");
                return;
            }
            _out.Write(mVersion);
            _out.Write(mNpcList.Count);
            for (int i = 0; i < mNpcList.Count; i++)
            {
                _out.Write(mNpcList[i].transform.position.x);
                _out.Write(mNpcList[i].transform.position.y);
                _out.Write(mNpcList[i].transform.position.z);
            }
            _out.Write(mItemList.Count);
            for (int i = 0; i < mItemList.Count; i++)
            {
                _out.Write(mItemList[i].transform.position.x);
                _out.Write(mItemList[i].transform.position.y);
                _out.Write(mItemList[i].transform.position.z);
                _out.Write(mItemList[i].transform.rotation.eulerAngles.x);
                _out.Write(mItemList[i].transform.rotation.eulerAngles.y);
                _out.Write(mItemList[i].transform.rotation.eulerAngles.z);
                _out.Write(mItemList[i].mItemID);
            }
            _out.Close();
            fileStream.Close();
        }
        ResetFileList();
    }
Exemplo n.º 36
0
 public void SaveSettings(GameConfig gameConfig)
 {
     this.gameConfig.Copy(gameConfig);
     this.gameConfig.RestartGame = true;
     SaveConfigurationFile();
 }
Exemplo n.º 37
0
 /// <summary>
 /// 任务触发
 /// </summary>
 /// <param name="OnlineBusiness"></param>
 /// <param name="gc"></param>
 public static void TaskStart(UserNote note, GameConfig gc)
 {
     if (note.Name == UserPlayerCommand.CreatePlayerSuccess)
     {
         Player model = note[0] as Player;
         if (!TaskAccess.Instance.TaskLimit(model.ID, model.Level, gc.ID, gc.Value))
             return;
         //激活创建任务
         TaskAccess.Instance.TaskBase(model.ID, model.RoleID, gc, 0, model.Level);
     }
     else
     {
         TaskStartBusiness(note.Player, gc);
     }
 }
Exemplo n.º 38
0
 public HanoiSolver(GameConfig config)
 {
     this.config = config;
     this.board  = new Board(config.Rods, config.SourceTowerIndex, config.DestTowerIndex);
     this.Init();
 }
Exemplo n.º 39
0
	protected override void OnInitialize ()
	{
		GameConfig = GameController.Instance.GameConfig;
	}
 private void Awake()
 {
     GameConfig.InitializePrefs();
 }
Exemplo n.º 41
0
    void FixedUpdate()
    {
        HPText.text    = "HP  " + Mathf.Ceil(ba.Ability.HP) + "/" + ba.Ability.MaxHP;
        rect.sizeDelta = new Vector2(ba.Ability.HP / ba.Ability.MaxHP * MaxW, rect.sizeDelta.y);

        //角色死亡处理
        DieScreen.SetActive(ba.Recovery);
        if (ba.Recovery)
        {
            return;
        }

        bool ExV = (GameConfig.ExS != "");

        ExBar.SetActive(ExV); ExSkill.SetActive(ExV);
        if (GameConfig.ExS != lSkill && ExV)
        {
            lSkill = GameConfig.ExS;
            SkillManager.Skill s = SkillManager.S.Find(m => m.Name == GameConfig.ExS);
            s.CD /= 5;
            ExSkill.GetComponent <MSBC>().s = s;
            ExSkill.GetComponent <MSBC>().ReLoad();
        }

        //Role Switcher
        if (Input.GetKeyUp(KeyCode.Q) || GameConfig.IsTouched(Switcher))
        {
            ControlRole = (ControlRole == 0) ? 1 : 0;
            RPGEvent rpg = GameConfig.Controller.GetComponent <RPGEvent>();
            GameConfig.Followers[0].character = rpg.character;
            GameConfig.Followers[0].Confirm();
            rpg.character = TeamController.Team.Mem[ControlRole].Name;
            rpg.Reload();
            if (ControlRole == 0)
            {
                Ability2 = ba.Ability;
            }
            if (ControlRole == 1)
            {
                Ability1 = ba.Ability;
            }
            Reset();
            SkillManager.PlaySkillAni(GameConfig.Controller.transform.localPosition,
                                      "Interactive\\Stars\\StarExplosion");
        }

        //Touch Hander
        foreach (Touch t in Input.touches)
        {
            if (t.phase == TouchPhase.Ended)
            {
                GraphicRaycaster gr   = this.GetComponent <GraphicRaycaster>();
                PointerEventData data = new PointerEventData(EventSystem.current);
                data.pressPosition = t.position;
                data.position      = t.position;
                List <RaycastResult> results = new List <RaycastResult>();
                gr.Raycast(data, results);

                GameConfig.TouchAt.Clear();
                foreach (RaycastResult rr in results)
                {
                    GameConfig.TouchAt.Add(rr.gameObject);
                }
            }
        }
    }
Exemplo n.º 42
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, GameConfig config)
        {
            //web helper
            builder.RegisterType <WebHelper>().As <IWebHelper>().InstancePerLifetimeScope();

            //user agent helper
            builder.RegisterType <UserAgentHelper>().As <IUserAgentHelper>().InstancePerLifetimeScope();

            //data layer
            builder.RegisterType <GameCoreConventionSetBuilder>().As <ICoreConventionSetBuilder>().SingleInstance();
            var dataSettingsManager  = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();

            builder.Register(c => dataSettingsManager.LoadSettings()).As <DataSettings>();
            builder.Register(x => new EfDataProviderManager(x.Resolve <DataSettings>())).As <BaseDataProviderManager>().InstancePerDependency();
            builder.Register(x => x.Resolve <BaseDataProviderManager>().LoadDataProvider()).As <IDataProvider>().InstancePerDependency();
            if (dataProviderSettings != null && dataProviderSettings.IsValid())
            {
                var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
                var dataProvider          = efDataProviderManager.LoadDataProvider();

                builder.Register <IDbContext>(c => new GameObjectContext(dataProvider)).InstancePerLifetimeScope();
            }
            else
            {
                builder.Register <IDbContext>(c => {
                    dataProviderSettings = dataSettingsManager.LoadSettings();
                    if (dataProviderSettings != null && dataProviderSettings.IsValid())
                    {
                        var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
                        var dataProvider          = efDataProviderManager.LoadDataProvider();
                        return(new GameObjectContext(dataProvider));
                    }
                    else
                    {
                        return(new GameObjectContext(null));
                    }
                }).InstancePerLifetimeScope();
            }


            //repositories
            builder.RegisterGeneric(typeof(EfRepository <>)).As(typeof(IRepository <>)).InstancePerLifetimeScope();

            //cache manager
            builder.RegisterType <PerRequestCacheManager>().As <ICacheManager>().InstancePerLifetimeScope();

            //static cache manager
            if (config.RedisCachingEnabled)
            {
                builder.RegisterType <RedisConnectionWrapper>().As <IRedisConnectionWrapper>().SingleInstance();
                builder.RegisterType <RedisCacheManager>().As <IStaticCacheManager>().InstancePerLifetimeScope();
            }
            else
            {
                builder.RegisterType <MemoryCacheManager>().As <IStaticCacheManager>().SingleInstance();
            }

            //work context
            builder.RegisterType <WebWorkContext>().As <IWorkContext>().InstancePerLifetimeScope();

            //services
            //builder.RegisterType<BackInStockSubscriptionService>().As<IBackInStockSubscriptionService>().InstancePerLifetimeScope();
            builder.RegisterType <GenericAttributeService>().As <IGenericAttributeService>().InstancePerLifetimeScope();
            //builder.RegisterType<FulltextService>().As<IFulltextService>().InstancePerLifetimeScope();
            //builder.RegisterType<MaintenanceService>().As<IMaintenanceService>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerAttributeFormatter>().As <ICustomerAttributeFormatter>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerAttributeParser>().As <ICustomerAttributeParser>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerAttributeService>().As <ICustomerAttributeService>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerService>().As <ICustomerService>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerRegistrationService>().As <ICustomerRegistrationService>().InstancePerLifetimeScope();
            //builder.RegisterType<CustomerReportService>().As<ICustomerReportService>().InstancePerLifetimeScope();
            builder.RegisterType <PermissionService>().As <IPermissionService>().InstancePerLifetimeScope();
            builder.RegisterType <AclService>().As <IAclService>().InstancePerLifetimeScope();
            builder.RegisterType <LocalizationService>().As <ILocalizationService>().InstancePerLifetimeScope();
            builder.RegisterType <LocalizedEntityService>().As <ILocalizedEntityService>().InstancePerLifetimeScope();
            builder.RegisterType <LanguageService>().As <ILanguageService>().InstancePerLifetimeScope();
            //builder.RegisterType<DownloadService>().As<IDownloadService>().InstancePerLifetimeScope();
            //builder.RegisterType<MessageTemplateService>().As<IMessageTemplateService>().InstancePerLifetimeScope();
            //builder.RegisterType<QueuedEmailService>().As<IQueuedEmailService>().InstancePerLifetimeScope();
            //builder.RegisterType<NewsLetterSubscriptionService>().As<INewsLetterSubscriptionService>().InstancePerLifetimeScope();
            //builder.RegisterType<CampaignService>().As<ICampaignService>().InstancePerLifetimeScope();
            //builder.RegisterType<EmailAccountService>().As<IEmailAccountService>().InstancePerLifetimeScope();
            //builder.RegisterType<EmailSender>().As<IEmailSender>().InstancePerLifetimeScope();
            //builder.RegisterType<ReturnRequestService>().As<IReturnRequestService>().InstancePerLifetimeScope();
            builder.RegisterType <EncryptionService>().As <IEncryptionService>().InstancePerLifetimeScope();
            builder.RegisterType <CookieAuthenticationService>().As <IAuthenticationService>().InstancePerLifetimeScope();
            builder.RegisterType <UrlRecordService>().As <IUrlRecordService>().InstancePerLifetimeScope();
            builder.RegisterType <DefaultLogger>().As <ILogger>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerActivityService>().As <ICustomerActivityService>().InstancePerLifetimeScope();
            builder.RegisterType <DateTimeHelper>().As <IDateTimeHelper>().InstancePerLifetimeScope();
            builder.RegisterType <SitemapGenerator>().As <ISitemapGenerator>().InstancePerLifetimeScope();
            builder.RegisterType <ScheduleTaskService>().As <IScheduleTaskService>().InstancePerLifetimeScope();
            //builder.RegisterType<ExportManager>().As<IExportManager>().InstancePerLifetimeScope();
            //builder.RegisterType<ImportManager>().As<IImportManager>().InstancePerLifetimeScope();
            //builder.RegisterType<PdfService>().As<IPdfService>().InstancePerLifetimeScope();
            //builder.RegisterType<UploadService>().As<IUploadService>().InstancePerLifetimeScope();
            builder.RegisterType <ThemeProvider>().As <IThemeProvider>().InstancePerLifetimeScope();
            builder.RegisterType <ThemeContext>().As <IThemeContext>().InstancePerLifetimeScope();
            builder.RegisterType <ExternalAuthenticationService>().As <IExternalAuthenticationService>().InstancePerLifetimeScope();
            builder.RegisterType <RoutePublisher>().As <IRoutePublisher>().SingleInstance();
            builder.RegisterType <EventPublisher>().As <IEventPublisher>().SingleInstance();
            builder.RegisterType <SubscriptionService>().As <ISubscriptionService>().SingleInstance();
            builder.RegisterType <SettingService>().As <ISettingService>().InstancePerLifetimeScope();
            builder.RegisterType <PageHeadBuilder>().As <IPageHeadBuilder>().InstancePerLifetimeScope();
            builder.RegisterType <ActionContextAccessor>().As <IActionContextAccessor>().InstancePerLifetimeScope();
            builder.RegisterType <MatchService>().As <IMatchService>().InstancePerLifetimeScope();
            builder.RegisterType <EcbExchangeRateProvider>().As <IExchangeRateProvider>().InstancePerLifetimeScope();
            builder.RegisterType <CurrencyService>().As <ICurrencyService>().InstancePerLifetimeScope();
            builder.RegisterType <OrderService>().As <IOrderService>().InstancePerLifetimeScope();
            builder.RegisterType <PaymentService>().As <IPaymentService>().InstancePerLifetimeScope();
            builder.RegisterType <PriceFormatter>().As <IPriceFormatter>().InstancePerLifetimeScope();

            //register all settings
            builder.RegisterSource(new SettingsSource());

            //installation service
            if (!DataSettingsHelper.DatabaseIsInstalled())
            {
                if (config.UseFastInstallationService)
                {
                    builder.RegisterType <SqlFileInstallationService>().As <IInstallationService>().InstancePerLifetimeScope();
                }
                else
                {
                    builder.RegisterType <CodeFirstInstallationService>().As <IInstallationService>().InstancePerLifetimeScope();
                }
            }

            //event consumers
            var consumers = typeFinder.FindClassesOfType(typeof(IConsumer <>)).ToList();

            foreach (var consumer in consumers)
            {
                builder.RegisterType(consumer)
                .As(consumer.FindInterfaces((type, criteria) =>
                {
                    var isMatch = type.IsGenericType && ((Type)criteria).IsAssignableFrom(type.GetGenericTypeDefinition());
                    return(isMatch);
                }, typeof(IConsumer <>)))
                .InstancePerLifetimeScope();
            }
        }
Exemplo n.º 43
0
 private void Awake()
 {
     _config = FindObjectOfType <GameConfig>();
     _camera = Camera.main;
 }
Exemplo n.º 44
0
 public void Initialize()
 {
     gameConfig = dataProvider.GetGameConfig();
 }
Exemplo n.º 45
0
 void onPause()
 {
     GameManager.enterState(GameScript.State.PAUSE.ToString());
     GameConfig.setPaused(true);
     FMG.Constants.fadeInFadeOut(pauseState, playState);
 }
Exemplo n.º 46
0
 public static GameViewModel Create([NotNull] GameConfig config) => Create(config, null);
Exemplo n.º 47
0
    // Start is called before the first frame update
    void Start()
    {
        if (detect_manager == null)
        {
            print(string.Format("{0} is nu!!", "detect_manager"));
        }

        if (audio_manager == null)
        {
            print(string.Format("{0} is nu!!", "audio_manager"));
        }

        //if (kinect == null)
        //{
        //    print(string.Format("{0} is nu!!", "kinect"));
        //}

        #region Game Config
        config = GameConfig.loadGameConfig();

        // 總共有幾輪
        ROUND = config.round1;

        // 每一輪要吃多少次
        NUMBER = config.number1;

        // 每一輪的時間上限
        ROUND_TIME = config.round_time1;

        // 題目出現後緩衝數秒再開始偵測
        QUESTION_BUFFER = config.question_buffer1;

        // 每次偵測的間隔時間
        DETECT_INTERVAL_TIME = config.detect_interval_time1;

        // 圈叉呈現時間
        YESNO_DISPLAY_TIME = config.yesno_display_time1;

        // 回饋呈現時間
        FEEDBACK_DISPLAY_TIME = config.feedback_display_time1;

        //回合結束等待時間
        ROUND_INTERVAL_TIME = config.round_interval_time1;

        // 分數呈現時間
        SCORE_DISPLAY_TIME = config.score_display_time1;

        #region 音樂大小設定
        // 背景音量
        BG_VOL = config.bg_vol1;

        // 正確回饋音量
        CORRECT_VOL = config.correct_vol1;

        // 錯誤回饋音量
        WRONG_VOL = config.wrong_vol1;

        // 成功回饋音量
        SUCCESS_VOL = config.success_vol1;

        // 失敗回饋音量
        FAIL_VOL = config.fail_vol1;
        #endregion
        #endregion

        #region 數據紀錄
        // story 1:小紅帽
        detect_manager.setStoryStage(1);

        // 動作正確次數-計數用字典
        //resetCount();

        game_record = new GameRecord();
        #endregion

        StartCoroutine(gameStart());
    }
Exemplo n.º 48
0
 public static GameViewModel Create([NotNull] GameConfig config, GameModel model)
 {
     Assert.IsNotNull(config, nameof(config));
     return(new GameViewModel(config, model ?? CreateModel(config)));
 }
Exemplo n.º 49
0
        public static void TestFullGames()
        {
            int maxGames = 100;
            int maxDepth = 10;
            int maxWidth = 14;

            int[] player1Stats = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            int[] player2Stats = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            var gameConfig = new GameConfig()
            {
                StartPlayer      = -1,
                Player1Name      = "FitzVonGerald",
                Player1HeroClass = CardClass.PALADIN,
                Player1Deck      = new List <Card>()
                {
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Knight"),
                    Cards.FromName("Stormwind Knight")
                },
                Player2Name      = "RehHausZuckFuchs",
                Player2HeroClass = CardClass.PALADIN,
                Player2Deck      = new List <Card>()
                {
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Blessing of Might"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Gnomish Inventor"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Goldshire Footman"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hammer of Wrath"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Hand of Protection"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Holy Light"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Ironforge Rifleman"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Light's Justice"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Lord of the Arena"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Nightblade"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Raid Leader"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stonetusk Boar"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormpike Commando"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Champion"),
                    Cards.FromName("Stormwind Knight"),
                    Cards.FromName("Stormwind Knight")
                },
                FillDecks    = false,
                Shuffle      = true,
                SkipMulligan = false,
                Logging      = false,
                History      = false
            };

            for (int i = 0; i < maxGames; i++)
            {
                var game = new Game(gameConfig);
                game.StartGame();

                var aiPlayer1 = new AggroScore();
                var aiPlayer2 = new AggroScore();

                List <int> mulligan1 = aiPlayer1.MulliganRule().Invoke(game.Player1.Choice.Choices.Select(p => game.IdEntityDic[p]).ToList());
                List <int> mulligan2 = aiPlayer2.MulliganRule().Invoke(game.Player2.Choice.Choices.Select(p => game.IdEntityDic[p]).ToList());

                game.Process(ChooseTask.Mulligan(game.Player1, mulligan1));
                game.Process(ChooseTask.Mulligan(game.Player2, mulligan2));

                game.MainReady();

                while (game.State != State.COMPLETE)
                {
                    while (game.State == State.RUNNING && game.CurrentPlayer == game.Player1)
                    {
                        List <OptionNode> solutions = OptionNode.GetSolutions(game, game.Player1.Id, aiPlayer1, maxDepth, maxWidth);
                        var solution = new List <PlayerTask>();
                        solutions.OrderByDescending(p => p.Score).First().PlayerTasks(ref solution);
                        foreach (PlayerTask task in solution)
                        {
                            game.Process(task);
                            if (game.CurrentPlayer.Choice != null)
                            {
                                break;
                            }
                        }
                    }
                    while (game.State == State.RUNNING && game.CurrentPlayer == game.Player2)
                    {
                        List <OptionNode> solutions = OptionNode.GetSolutions(game, game.Player2.Id, aiPlayer2, maxDepth, maxWidth);
                        var solution = new List <PlayerTask>();
                        solutions.OrderByDescending(p => p.Score).First().PlayerTasks(ref solution);
                        foreach (PlayerTask task in solution)
                        {
                            game.Process(task);
                            if (game.CurrentPlayer.Choice != null)
                            {
                                break;
                            }
                        }
                    }
                }

                player1Stats[(int)game.Player1.PlayState]++;
                player2Stats[(int)game.Player2.PlayState]++;

                Console.WriteLine($"{i}.Game: {game.State}, Player1: {game.Player1.PlayState} / Player2: {game.Player2.PlayState}");
            }

            Console.WriteLine($"Player1: {String.Join(",", player1Stats)}");
            Console.WriteLine($"Player2: {String.Join(",", player2Stats)}");
        }
Exemplo n.º 50
0
        protected override void Draw(double elapsed)
        {
            VertexBuffer.TotalDrawcalls = 0;
            EnableTextInput();
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            //
            if (world != null)
            {
                if (wireFrame)
                {
                    RenderState.Wireframe = true;
                }
                world.Renderer.Draw();
                RenderState.Wireframe = false;
            }
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var folder = FileDialog.ChooseFolder();
                    if (folder != null)
                    {
                        if (GameConfig.CheckFLDirectory(folder))
                        {
                            openLoad = true;
                            LoadData(folder);
                        }
                        else
                        {
                            //Error dialog
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (world != null)
            {
                if (ImGui.MenuItem("Change System (F6)"))
                {
                    sysIndex         = sysIndexLoaded;
                    openChangeSystem = true;
                }
            }
            if (ImGui.BeginMenu("View"))
            {
                if (ImGui.MenuItem("Debug Text", "", showDebug, true))
                {
                    showDebug = !showDebug;
                }
                if (ImGui.MenuItem("Wireframe", "", wireFrame, true))
                {
                    wireFrame = !wireFrame;
                }
                if (ImGui.MenuItem("Infocard", "", infocardOpen, true))
                {
                    infocardOpen = !infocardOpen;
                }
                if (ImGui.MenuItem("VSync", "", vSync, true))
                {
                    vSync = !vSync;
                    SetVSync(vSync);
                }
                ImGui.EndMenu();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            //Other Windows
            if (world != null)
            {
                if (showDebug)
                {
                    ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero);

                    ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar |
                                ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus);
                    ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname,
                                             camera.Position.X, camera.Position.Y, camera.Position.Z,
                                             DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers));
                    ImGui.End();
                }
                ImGui.SetNextWindowSize(new Vector2(100, 100), ImGuiCond.FirstUseEver);
                if (infocardOpen)
                {
                    if (ImGui.Begin("Infocard", ref infocardOpen))
                    {
                        var szX = Math.Max(20, ImGui.GetWindowWidth());
                        var szY = Math.Max(20, ImGui.GetWindowHeight());
                        if (icard == null)
                        {
                            icard = new InfocardControl(this, systemInfocard, szX);
                        }
                        icard.Draw(szX);
                    }
                    ImGui.End();
                }
            }
            //dialogs must be children of window or ImGui default "Debug" window appears
            if (openChangeSystem)
            {
                ImGui.OpenPopup("Change System");
                openChangeSystem = false;
            }
            bool popupopen = true;

            if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Combo("System", ref sysIndex, systems, systems.Length);
                if (ImGui.Button("Ok"))
                {
                    if (sysIndex != sysIndexLoaded)
                    {
                        camera.UpdateProjection();
                        camera.Free = false;
                        camera.Zoom = 5000;
                        Resources.ClearTextures();
                        curSystem      = GameData.GetSystem(systems[sysIndex]);
                        systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan);
                        if (icard != null)
                        {
                            icard.SetInfocard(systemInfocard);
                        }
                        GameData.LoadAllSystem(curSystem);
                        world.LoadSystem(curSystem, Resources);
                        sysIndexLoaded = sysIndex;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (openLoad)
            {
                ImGui.OpenPopup("Loading");
                openLoad = false;
            }
            popupopen = true;
            if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (world != null)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
Exemplo n.º 51
0
    static public ISkillBuff DoBuff(SkillInfo.Action buff_action, BattleCreature creature, BattleCreature target_creature, BattleSkill skill, int target_index, ISkillBuff parent)
    {
        switch (buff_action.actionType)
        {
        case eActionType.stun:
        case eActionType.hidden:
        case eActionType.sleep:
        {
            if (target_creature.InvokeImmune(eImmuneType.cc, skill.Creature.Info.AttackType, skill.Level) == true)
            {
                return(null);
            }

            int value = skill.GetValueWithTargetIndex(buff_action, target_index, -(target_creature.Level - skill.Level) * GameConfig.Get <int>("stun_level_decrease"));
            if (BattleBase.Instance.Rand.NextRange(1, 10000) > value)
            {
                TextManager.Instance.PushMessage(target_creature, Localization.Get("Miss"), eBuffColorType.Immune, eTextPushType.Normal);
                return(null);
            }

            float duration = skill.GetDuration(buff_action, target_index);
            Buff  buff     = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
                TextManager.Instance.PushMessage(target_creature, Localization.Get(buff_action.actionType.ToString()), eBuffColorType.Stun, eTextPushType.Normal);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            return(buff);
        }

        case eActionType.ignore_defense_damage:
        case eActionType.ignore_defense_damaged:
        case eActionType.worldboss:
        case eActionType.shield:
        case eActionType.immune:
        case eActionType.provoke:
        case eActionType.buff:
        case eActionType.buff_percent:
        {
            int value = skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            if (buff_action.statType == eStatType.AttackSpeed && duration > 0f)
            {
                buff.Duration *= (1f + value * 0.0001f);
            }

            return(buff);
        }

        case eActionType.debuff:
        case eActionType.debuff_percent:
        {
            eImmuneType immune_type = eImmuneType.debuff;
            switch (buff_action.actionType)
            {
            default:
                if (target_creature.InvokeImmune(immune_type, skill.Creature.Info.AttackType, skill.Level) == true)
                {
                    return(null);
                }
                break;
            }

            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();

            if (buff_action.statType == eStatType.AttackSpeed && duration > 0f)
            {
                buff.Duration *= (1f - value * 0.0001f);
            }

            return(buff);
        }

        case eActionType.dot_damage:
        {
            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, creature.GetDamageValue());

            value = Mathf.RoundToInt(value * (1f + (creature.GetValue(eStatType.IncreaseDamagePercent) - creature.GetValue(eStatType.DecreaseDamagePercent)) * 0.0001f));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();

            return(buff);
        }

        case eActionType.dot_damage_mana:
        {
            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float decrease = (10000 - (target_creature.Level - skill.Level) * GameConfig.Get <int>("mana_level_decrease")) * 0.0001f;
            value = Mathf.RoundToInt(value * (1f + (creature.GetValue(eStatType.IncreaseDamagePercent) - creature.GetValue(eStatType.DecreaseDamagePercent)) * 0.0001f + decrease));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();
            return(buff);
        }

        case eActionType.dot_heal:
        {
            int value = skill.GetValueWithTargetIndex(buff_action, target_index, creature.GetDamageValue());
            value = Mathf.RoundToInt(value * (1f + creature.GetValue(eStatType.IncreaseDamagePercent) * 0.0001f));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            return(buff);
        }

        case eActionType.dot_heal_mana:
        {
            int   value    = skill.GetValueWithTargetIndex(buff_action, target_index, 0);
            float decrease = (10000 - (target_creature.Level - skill.Level) * GameConfig.Get <int>("mana_level_decrease")) * 0.0001f;
            value = Mathf.RoundToInt(value * (1f + creature.GetValue(eStatType.IncreaseDamagePercent) * 0.0001f) * decrease);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            return(buff);
        }
        }
        return(null);
    }
Exemplo n.º 52
0
 private void GetRandomEquip(ref List <BattleDropData> list, Soldier_soldier data)
 {
     if (this.equip_talent_enable)
     {
         int num = (int)(((data.EquipRate * this.mDropData.EquipProb) * 100f) * (1f + GameLogic.Self.m_EntityData.attribute.EquipDrop.Value));
         if (this.equip_must_drop)
         {
             if (data.CharID > 0x1388)
             {
                 List <BattleDropData> dropList = this.GetDropList();
                 int num2  = 0;
                 int count = dropList.Count;
                 while (num2 < count)
                 {
                     if ((dropList[num2].type == FoodType.eEquip) && (dropList[num2].data != null))
                     {
                         LocalSave.EquipOne one = dropList[num2].data as LocalSave.EquipOne;
                         if ((one != null) && (one.data.Position != 1))
                         {
                             list.Add(dropList[num2]);
                             this.equip_must_drop = false;
                             return;
                         }
                     }
                     num2++;
                 }
                 this.GetRandomEquip(ref list, data);
             }
         }
         else
         {
             this.level_dropequip += num;
             this.level_dropequip  = MathDxx.Clamp(this.level_dropequip, 0L, (long)(1E+08f * GameConfig.GetEquipDropMaxRate()));
             if (GameLogic.Random(0, 0x5f5e100) < this.level_dropequip)
             {
                 this.level_dropequip = 0L;
                 List <BattleDropData> dropList = this.GetDropList();
                 list.AddRange(dropList);
             }
             LocalSave.Instance.SaveExtra.SetEquipDropRate(this.level_dropequip);
         }
     }
 }
Exemplo n.º 53
0
 public SceneArena(GameConfig scene)
     : base(scene)
 {
     m_showAll = true;
     m_pets = new ConcurrentDictionary<string, ConcurrentDictionary<string, Pet>>();
 }
Exemplo n.º 54
0
 private void Start()
 {
     instance    = this;
     this.config = base.GetComponent <GameConfig>();
 }
Exemplo n.º 55
0
        /// <summary>
        /// 任务触发
        /// </summary>
        /// <param name="note"></param>
        /// <param name="gc"></param>
        public static void TaskStartBusiness(PlayerBusiness pb, GameConfig gc, bool IsCall = true)
        {
            if (!TaskAccess.Instance.TaskLimit(pb.ID, pb.Level, gc.ID, gc.Value))
            {
                return;
            }
            int loopcount = 0;
            if (gc.Value.GetIntOrDefault("TaskType") == 8)
            {
                loopcount = pb.WeekTotal(8) + 1;
            }

            Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, loopcount, pb.Level);

            if (IsCall && task != null)
            {
                pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
            }
        }
Exemplo n.º 56
0
 /// <summary>
 /// 实例化接口参数
 /// </summary>
 public Game_Zwj()
 {
     game = games.GetGame("zwj");                                   //获取游戏
     gc   = gcs.GetGameConfig(game.Id);                             //获取游戏参数
 }
Exemplo n.º 57
0
 public override void start()
 {
     base.start();
     mGameConfig  = new GameConfig();
     mGameUtility = new GameUtility();
 }
Exemplo n.º 58
0
        public static void ThreadSafetyTest()
        {
            Console.WriteLine("Test started");
            int i = 0;

            while (i < TESTCOUNT)
            {
                int num   = System.Environment.ProcessorCount * 2;
                var tasks = new Task[num];
                var cts   = new CancellationTokenSource();
                var token = cts.Token;
                for (int j = 0; j < tasks.Length; j++)
                {
                    tasks[j] = new Task(() =>
                    {
                        var config = new GameConfig
                        {
                            Player1HeroClass     = (CardClass)rnd.Next(2, 11),
                            Player2HeroClass     = (CardClass)rnd.Next(2, 11),
                            FillDecks            = true,
                            FillDecksPredictably = true,
                            Shuffle      = false,
                            SkipMulligan = true,
                            History      = false,
                            Logging      = true,
                        };
                        var game = new Game(config);
                        game.StartGame();
                        //List<PlayerTask> optionHistory = new List<PlayerTask>();
                        //Queue<LogEntry> logs = new Queue<LogEntry>();
                        PlayerTask option = null;
                        try
                        {
                            do
                            {
                                //while (game.Logs.Count > 0)
                                // logs.Enqueue(game.Logs.Dequeue());
                                game = game.Clone(true);
                                List <PlayerTask> options = game.CurrentPlayer.Options();
                                option = options[rnd.Next(options.Count)];
                                //optionHistory.Add(option);
                                game.Process(option);
                            } while (game.State != State.COMPLETE);
                        }
                        catch (Exception e)
                        {
                            //ShowLog(logs, LogLevel.DEBUG);
                            Program.ShowLog(game, LogLevel.DEBUG);
                            Console.WriteLine(e.Message);
                            Console.WriteLine(e.Source);
                            Console.WriteLine(e.TargetSite);
                            Console.WriteLine(e.StackTrace);
                            Console.WriteLine($"LastOption: {option?.FullPrint()}");
                            cts.Cancel();
                        }
                        if (token.IsCancellationRequested)
                        {
                            token.ThrowIfCancellationRequested();
                        }

                        Interlocked.Increment(ref i);
                    }, token);
                }

                for (int j = 0; j < tasks.Length; j++)
                {
                    tasks[j].Start();
                }

                Task.WaitAll(tasks);


                if (i % (TESTCOUNT / 10) == 0)
                {
                    Console.WriteLine($"{((double) i / TESTCOUNT) * 100}% done");
                }
            }
        }
Exemplo n.º 59
0
        //installs the new game version
        private void InstallGame(string latestUpdate)
        {
            GameConfig gameConfig = new GameConfig();

            //move new files to game direcotry
            StatusChanged(this,new StatusEventArgs("Installing new files..."));
            if (!MoveFilesToGameFolder(updaterConfig.TempFolder))
            {
                StatusChanged(this,
                    new StatusEventArgs("Error on moving files to game directory! Installation not completed"));
                MessageBox.Show("Error on moving files to game directory! Installation not completed.", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                OnClose(this, EventArgs.Empty);
                return;
            }

            //delete old files from game directory
            StatusChanged(this,new StatusEventArgs("Deleting old files..."));
            if (!DeleteOldFiles())
            {
                StatusChanged(this,new StatusEventArgs("Error on deleting old files! Installation not completed."));
                MessageBox.Show("Error on deleting old files! Installation not completed.", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                OnClose(this, EventArgs.Empty);
                return;
            }

            //save the new game configuration file
            StatusChanged(this,new StatusEventArgs("Writing game configuration file..."));
            if (!gameConfig.Save(updaterConfig.GamePath + updaterConfig.GameConfigurationFile, latestUpdate))
            {
                StatusChanged(this,
                    new StatusEventArgs("Error writing game configuration file! Installation not completed."));
                MessageBox.Show("Error writing game configuration file! Installation not completed.", "Error!",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                OnClose(this, EventArgs.Empty);
                return;
            }

            //delete the temporary download directory
            if (!DeleteTempFolder())
                StatusChanged(this,
                    new StatusEventArgs("Error on deleting temporary download directory! But installation completed."));
            else
                StatusChanged(this,new StatusEventArgs("Update completed!"));

            //fire event UpdateFinished
            UpdateFinished(this, EventArgs.Empty);
        }
Exemplo n.º 60
0
 private void Construct(GameConfig config)
 {
     _config = config;
 }