コード例 #1
0
        private async Task <List <InGameUser> > CreateInGameUsersBasedOnUserNameAsync(List <string> userNames, Game game)
        {
            var users = new List <InGameUser>();

            foreach (var username in userNames)
            {
                var user = context.Users
                           .Where(u => u.UserName == username)
                           .SingleOrDefault();
                var inGameUserCheck = context.InGameUsers
                                      .Where(i => i.GameId == game.Id)
                                      .Where(i => i.UserName == username)
                                      .SingleOrDefault();

                if (user != null && inGameUserCheck == null)
                {
                    var inGameUser = new InGameUser
                    {
                        UserId   = user.Id,
                        UserName = user.UserName,
                        GameId   = game.Id,
                        Gender   = user.Gender
                    };
                    users.Add(inGameUser);
                    await context.InGameUsers.AddAsync(inGameUser);
                }
            }
            return(users);
        }
コード例 #2
0
ファイル: MenuInGame.cs プロジェクト: pb0/ID0_Test
    public MenuInGame(FSM parentFsm, UIManager2 panel1, UIManager2 panel2)
        : base(parentFsm, panel1, panel2, "MenuInGame.fsm")
    {
        timeClient = TimeManager.Instance.Create();

        InitUI();

        int stageId = (int)parentFsm.Variables["stageId"];

        /*
        // ddong
        if (stageId < 2000)
        {
            stageId += 2000;
        }
        */

        InitStage(stageId, out stageEntity, out gameEntity);

        Rect fieldArea = UI.GetFieldArea();
        field = CreateField(stageEntity, fieldArea, timeClient, fsm);

        // ddong
        int subClassCode = 11;
        int level = 1;
        int trainLevel = 1;

        this.subClassEntity = TableLoader.GetTable<SubClassEntity>().Get(subClassCode);
        ClassLevelEntity levelEntity = TableLoader.GetTable<ClassLevelEntity>().Get(subClassEntity.classCode, level);
        TrainLevelEntity trainLevelEntity = TableLoader.GetTable<TrainLevelEntity>().Get(subClassEntity.classCode, trainLevel);
        FieldObjectEntity objectField = TableLoader.GetTable<FieldObjectEntity>().Get(subClassEntity.objectCode);

        Rect puzzleArea = UI.GetPuzzleArea();
        CreatePuzzle(puzzleArea, timeClient, subClassCode, out puzzleRecord, out puzzlePanel);

        user = CreateUser(stageEntity, UI, fsm);
        heroCharacter = CreateCharacter(objectField, levelEntity, trainLevelEntity, subClassEntity, user, puzzlePanel, itemDropManager, UI.AddBuffIcon, UI.RemoveBuffIcon, fsm);
        itemDropManager = new ConsumableSpawn(stageEntity.gameModeCode, levelEntity.consumableTier);

        Func<float> getLifeDrainRate = (() => gameEntity.defaultHP);
        new PlayerCharacter(user, heroCharacter, getLifeDrainRate, fsm);
        /*
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.HP, OnCharacterHPChanged);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.HP, UI.ChangeHP);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.MP, UI.ChangeMana);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.Armor, UI.ChangeShield);
        */

        UI.InitCommendSlots(fsm, heroCharacter);

        field.AddPlayerCharacter(heroCharacter);
        field.FocusOnForced(heroCharacter, 0);
        puzzlePanel.SetQueue(user.commandQueue);

        var screenPosTable = TableLoader.GetTable<ScreenPositionEntity2>();
        var hpToPos = screenPosTable.Values.Select(x => new KeyValuePair<float, float>(x.hp, x.screenPos));
        convertHPRatioToScreenPos = new RangeConvertor(hpToPos).Convert;

        SetFocusTarget(heroCharacter);
    }
コード例 #3
0
ファイル: PlayerCharacter.cs プロジェクト: pb0/ID0_Test
 public PlayerCharacter(InGameUser user, HeroCharacter heroCharacter, Func<float> getLifeDrainRate, FSM parentFsm)
 {
     this.user = user;
     this.heroCharacter = heroCharacter;
     this.getLifeDrainRate = getLifeDrainRate;
     this.parentFsm = parentFsm;
     heroCharacter.InitFSM("PlayerCharacter.fsm", this, false);
 }
コード例 #4
0
ファイル: MenuInGame.cs プロジェクト: pb0/ID0_Test
    public MenuInGame(FSM parentFsm, UIManager2 panel1, UIManager2 panel2)
        : base(parentFsm, panel1, panel2, "MenuInGame.fsm")
    {
        timeClient = TimeManager.Instance.Create();

        InitUI();

        int stageId = (int)parentFsm.Variables["stageId"];
        InitStage(stageId, out stageEntity, out gameEntity);

        Rect fieldArea = UI.GetFieldArea();
        itemDropManager = new ItemDropManager(stageEntity.GameModeType, stageEntity.ConsumableTier);
        field = CreateField(stageEntity, fieldArea, timeClient, itemDropManager, fsm);

        // ddong
        CharacterSelect characterSelect = new CharacterSelect()
        {
            heroLevel = SaveData.level,
            heroId = GetClassCode(SaveData.selectClass),
            equipIds = ArrayTool.Create<int>(),
        };
        this.heroEntity = TableLoader.GetTable<ItemHeroEntity>().Get(characterSelect.heroId);

        Rect puzzleArea = UI.GetPuzzleArea();
        CreatePuzzle(stageEntity, heroEntity.HeroType, puzzleArea, timeClient, out puzzleRecord, out puzzlePanel);

        user = CreateUser(stageEntity, UI, fsm);
        heroCharacter = CreateCharacter(characterSelect, user, puzzlePanel, itemDropManager, UI.AddBuffIcon, UI.RemoveBuffIcon);
        user.SetCharacter(heroCharacter);
        puzzlePanel.SetOwner(heroCharacter);

        Func<float> getLifeDrainRate = (() => gameEntity.DefaultLifeDrainRate + gameEntity.LifeDrainRateIncrease * timeClient.time);
        new PlayerCharacter(user, heroCharacter, getLifeDrainRate, fsm);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.HP, OnCharacterHPChanged);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.HP, UI.ChangeHP);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.MP, UI.ChangeMana);
        heroCharacter.Status.RegisterOnChangeEvent(HeroCharacter.Character.Armor, UI.ChangeShield);

        UI.InitCommendSlots(fsm, heroCharacter);

        field.AddPlayerCharacter(heroCharacter);
        field.FocusOnForced(heroCharacter, 0);
        puzzlePanel.SetQueue(user.commandQueue);

        SetFocusTarget(heroCharacter);

        // ddong
        CutInStarter = StartCutIn;
    }
コード例 #5
0
ファイル: HeroCharacter.cs プロジェクト: pb0/ID0_Test
    public HeroCharacter(ObjectField objectField, ItemHeroEntity heroEntity, ItemHeroLevel itemHeroLevel, int[] equipIds, bool toLeft, InGameUser user, PuzzlePanel puzzlePanel, Buff.Handle onBuff, Buff.Handle onDeBuff)
        : base(E_OverlapEvent.Collision, objectField, toLeft)
    {
        this.heroEntity = heroEntity;
        this.user = user;
        this.puzzlePanel = puzzlePanel;

        InitStat(itemHeroLevel.Level, equipIds);
        InitStatus(onBuff, onDeBuff);
        RegistActions();

        int skillId = heroEntity.ActiveSkill1;
        SkillCommand skillCommand = InitSkill(this, skillId, itemHeroLevel.Level);
        AddCommandSet("skill", 1, false, E_CommandConsume.Skill, null).TryAdd(skillCommand);
    }
コード例 #6
0
ファイル: HeroCharacter.cs プロジェクト: pb0/ID0_Test
    public HeroCharacter(FieldObjectEntity objectField, SubClassEntity subClassEntity, ClassLevelEntity levelEntity, TrainLevelEntity trainLevelEntity, bool toLeft, InGameUser user, PuzzlePanel puzzlePanel, Buff.Handle onBuff, Buff.Handle onDeBuff, FSM parentFsm)
        : base(objectField, toLeft, parentFsm)
    {
        this.subClassEntity = subClassEntity;
        this.user = user;
        this.puzzlePanel = puzzlePanel;

        this.stat = new Stat2<HeroStatType>(StatGenerator.ExportData<HeroStatType>(levelEntity, trainLevelEntity));
        this.status = InitStatus(this, stat, subClassEntity);

        Register(stat);
        Register(status);

        /*
        RegisterDeathCondition(x => x.Get(HeroStatusType.hp) == 0);
        RegisterBuffHandler(onBuff, onDeBuff);

        RegistActions();

        SkillCommand skillCommand = InitSkill(this, skillId, itemHeroLevel.Level);
        AddCommandSet("skill", 1, false, E_CommandConsume.Skill, null).TryAdd(skillCommand);
         * */
    }
コード例 #7
0
ファイル: MenuInGame.cs プロジェクト: pb0/ID0_Test
    static HeroCharacter CreateCharacter(FieldObjectEntity objectField, ClassLevelEntity levelEntity, TrainLevelEntity trainLevelEntity, SubClassEntity subClassEntity, InGameUser user, PuzzlePanel puzzlePanel, ConsumableSpawn itemDropManager, System.Action<StatusEffectEntity2> addBuffIcon, System.Action<StatusEffectEntity2> removeBuffIcon, FSM parentFsm)
    {
        Buff.Handle onBuff = delegate(Buff buff)
        {
            if (addBuffIcon != null)
            {
                addBuffIcon(buff.statusEffectEntity);
            }
        };
        Buff.Handle onDeBuff = delegate(Buff buff)
        {
            if (removeBuffIcon != null)
            {
                removeBuffIcon(buff.statusEffectEntity);
            }
        };
        HeroCharacter heroCharacter = new HeroCharacter(objectField, subClassEntity, levelEntity, trainLevelEntity, false, user, puzzlePanel, onBuff, onDeBuff, parentFsm);

        {
            Action action = ActionPattern.Create("Vector(Self; [HeroStatType.moveSpeed]; 0; 0; false)").Generate(heroCharacter.Stat);
            heroCharacter.Fire(action, null);
            heroCharacter.PauseMoving();
        }

        for (int i = 0; i < 4; i++)
        {
            heroCharacter.AddItemSlot(i, user.commandQueue);
        }

        {
            heroCharacter.AddAction(Action.E_Type.Money,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Money; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.Exp,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Exp; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.GetConsumable,
                delegate(float value, GameInstance firer, string[] param)
                {
                    if (RandomTool.IsIn(value))
                    {
                        var itemCommand = new ItemCommand(itemDropManager.Pick());
                        if (itemCommand != null)
                        {
                            heroCharacter.TryAddItem(itemCommand);
                        }
                    }
                    return null;
                }
            );
        }

        return heroCharacter;
    }
コード例 #8
0
ファイル: MenuInGame.cs プロジェクト: pb0/ID0_Test
 static InGameUser CreateUser(StageEntity2 stageEntity, UIInGameState ui, FSM fsm)
 {
     InGameUser user = new InGameUser(stageEntity, ui.ChangeGold, new ChargedAttackManager(fsm).OnChargedAttack);
     return user;
 }
コード例 #9
0
ファイル: MenuInGame.cs プロジェクト: pb0/ID0_Test
    static HeroCharacter CreateCharacter(CharacterSelect characterSelect, InGameUser user, PuzzlePanel puzzlePanel, ItemDropManager itemDropManager, System.Action<StatusEffectEntity> addBuffIcon, System.Action<StatusEffectEntity> removeBuffIcon)
    {
        ItemHeroEntity heroEntity = TableLoader.GetTable<ItemHeroEntity>().Get(characterSelect.heroId);
        ObjectField objectField = TableLoader.GetTable<ObjectField>().Get(heroEntity.FieldObject);
        ItemHeroLevel heroLevelEntity = TableLoader.GetTable<ItemHeroLevel>().Get(heroEntity.HeroType, characterSelect.heroLevel);

        Buff.Handle onBuff = delegate(Buff buff)
        {
            if (addBuffIcon != null)
            {
                addBuffIcon(buff.statusEffectEntity);
            }
        };
        Buff.Handle onDeBuff = delegate(Buff buff)
        {
            if (removeBuffIcon != null)
            {
                removeBuffIcon(buff.statusEffectEntity);
            }
        };
        HeroCharacter heroCharacter = new HeroCharacter(objectField, heroEntity, heroLevelEntity, characterSelect.equipIds, false, user, puzzlePanel, onBuff, onDeBuff);

        {
            Action action = ActionPattern.Create("Vector(Self; [WalkSpeed]; 0; 0; false)").Generate(heroCharacter.Stat);
            heroCharacter.Fire(action, null);
            heroCharacter.PauseMoving();
        }

        for (int i = 0; i < 4; i++)
        {
            heroCharacter.AddItemSlot(i, user.commandQueue);
        }

        {
            heroCharacter.AddAction(Action.E_Type.Money,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Money; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.Exp,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; Exp; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.GetKey,
                delegate(float value, GameInstance firer, string[] param)
                {
                    Action action = ActionPattern.Create("Action(User; GetKey; {0})").Generate(heroCharacter.Stat, value);
                    if (action != null)
                    {
                        heroCharacter.Fire(action, null);
                    }
                    return null;
                }
            );
            heroCharacter.AddAction(Action.E_Type.GetConsumable,
                delegate(float value, GameInstance firer, string[] param)
                {
                    if (RandomTool.IsIn(value))
                    {
                        var itemCommand = itemDropManager.DropItem();
                        if (itemCommand != null)
                        {
                            heroCharacter.TryAddItem(itemCommand);
                        }
                    }
                    return null;
                }
            );
        }

        return heroCharacter;
    }