Пример #1
0
    public override void Execute(Context context, FightHandler fightHandler)
    {
        if (ConditionValid(context, fightHandler))
        {
            Debug.Log("Deal Damage Effect executed");
            foreach (int targetId in targets.GetTargets(context))
            {
                try
                {
                    Entity source = fightHandler.Entities[sources.GetTargets(context)[0]];
                    Entity target = fightHandler.Entities[targetId];
                    float  damage = value * (100.0f + source.Stats[Stat.Damage]) / (100.0f + target.Stats[Stat.Armor]);
                    fightHandler.FireEvent(new EntityStatChangedEvent(targetId, targetId, Stat.Hp, -1 * (int)damage));
                }
                catch (Exception)
                {
                    Debug.LogWarning("Début debuggage : ");
                    Debug.LogWarning("Debuggage : " + fightHandler);
                    Debug.LogWarning("Debuggage : " + fightHandler.Entities);
                    Debug.LogWarning("Debuggage : " + fightHandler.Entities[0]);
                    Debug.LogWarning("Debuggage : " + targetId);
                    Debug.LogWarning("Fin debuggage : ");
                }
            }

            foreach (int sourceId in sources.GetTargets(context))
            {
                Entity source = fightHandler.Entities[sourceId];//TODO SCALING THREAT
                fightHandler.FireEvent(new EntityStatChangedEvent(sourceId, sourceId, Stat.Threat, value));
            }
        }
    }
Пример #2
0
    static void Main(string[] args)
    {
        Logger.Init();
        Logger.Info("game service start...");
        string confPath = System.AppDomain.CurrentDomain.BaseDirectory;

        string confFile = System.IO.Path.Combine(confPath, "conf/gs.json");

        GameServer gameServer = new GameServer();

        gameServer.Init(confFile);
        RoomManager  roomManager = new RoomManager(confFile);
        FightHandler fight       = new FightHandler(gameServer, roomManager);

        //var confData = JsonUtils.DecodeCps(confFile);
        //fight.CreateRoom(new Stream.CreateRoom() { GameID = confData.RegConf.GameID, SvcName = confData.RegConf.SvcName, PodName = confData.RegConf.PodName, RoomInfo = new Stream.RoomInfo() {

        //}, Ttl = 86400, WatchSetting = new WatchSetting() { } });
        gameServer.Bind(fight);

        int pid = System.Diagnostics.Process.GetCurrentProcess().Id;

        File.WriteAllText(System.IO.Path.Combine(confPath, "gameServer.dll_pid"), pid.ToString());

        Logger.Info("game service run...");
        gameServer.Run();
        gameServer.WaitOver();
        Logger.Info("game service over...");
    }
Пример #3
0
 public override void OnEvent(Event newEvent, FightHandler fightHandler)
 {
     if (newEvent is EntityDiesEvent entityDiesEvent)
     {
         if (fightHandler.Entities[entityDiesEvent.TargetId].Stats[Stat.isBoss] == 1)
         {
             Debug.Log("End Fight Rule activated");
             Debug.Log("Victory to the player");
             Run.run.BossVictory();
             //TODO Fin du match
         }
         else if (fightHandler.Entities[entityDiesEvent.TargetId].Stats[Stat.isHero] == 1)
         {
             int heroAliveCount = 0;
             foreach (KeyValuePair <int, Entity> entry in fightHandler.Entities)
             {
                 Entity entity = entry.Value;
                 if (entity.Stats[Stat.isHero] == 1 && entity.Stats[Stat.Alive] == 1)
                 {
                     heroAliveCount++;
                 }
             }
             if (heroAliveCount == 0)
             {
                 Debug.Log("End Fight Rule activated");
                 Debug.Log("Defeat");
                 Run.run.BossDefeat();
                 //TODO end of run
             }
         }
     }
 }
Пример #4
0
    static void Main(string[] args)
    {
        Logger.Init();
        Logger.Info("game service start...");

        string confPath = System.AppDomain.CurrentDomain.BaseDirectory;
        string confFile = System.IO.Path.Combine(confPath, "conf/gs.json");

        GameServer gameServer = new GameServer();

        gameServer.Init(confFile);
        RoomManager  roomManager = new RoomManager(confFile);
        Metrics      metrics     = new Metrics(confFile);
        FightHandler fight       = new FightHandler(gameServer, roomManager, metrics);

        gameServer.Bind(fight, metrics);

        int pid = System.Diagnostics.Process.GetCurrentProcess().Id;

        File.WriteAllText(System.IO.Path.Combine(confPath, "gameServer.dll_pid"), pid.ToString());

        Logger.Info("game service run...");
        gameServer.Run();
        gameServer.WaitOver();
        Logger.Info("game service over...");
    }
Пример #5
0
    public void StartNextBoss()
    {
        GameManager.fightHandler = new FightHandler();
        Entity boss = EntityFactory.BuildNewEntity(Run.run.CurrentDungeon.CurrentBoss.Definition);

        fightHandler.Entities.Add(boss.Id, boss);

        //Update boss
        bossObject.GetComponent <BossBehaviour>().InitBoss(Run.run.CurrentDungeon.CurrentBoss, boss);


        int index = 0;

        foreach (Hero hero in Run.run.Team)
        {
            Entity heroEntity = EntityFactory.BuildNewEntity(hero.Definition);
            GameManager.fightHandler.Entities.Add(heroEntity.Id, heroEntity);

            //Update Hero
            heroObjects[index].GetComponent <HeroesBehaviour>().InitHero(hero, heroEntity);



            index++;
        }



        pulled = false;
    }
Пример #6
0
 public override void OnEvent(Event newEvent, FightHandler fightHandler)
 {
     if (newEvent is EntityStatChangedEvent statChangedEvent)
     {
         Debug.Log("EntityStatChanged rule activated with stat : " + statChangedEvent.StatId);
         fightHandler.Entities[statChangedEvent.TargetId].Stats[statChangedEvent.StatId] += statChangedEvent.ValueChange;
     }
 }
        public void testFightEndsWhenOneFighterHas0LifePointsOrLess()
        {
            Mocks.MockMonster living = new Mocks.MockMonster(0, 0, 10, null, null);
            Mocks.MockMonster dead   = new Mocks.MockMonster(0, 0, 0, null, null);
            FightHandler      fh     = new FightHandler(living, dead);

            Assert.IsFalse(fh.continueFight());
        }
        public void testFightDoesntEndWhenOneFighterHasMoreThan0LifePoints()
        {
            Mocks.MockMonster living     = new Mocks.MockMonster(0, 0, 10, null, null);
            Mocks.MockMonster living_bis = new Mocks.MockMonster(0, 0, 10, null, null);
            FightHandler      fh         = new FightHandler(living, living_bis);

            Assert.IsTrue(fh.continueFight());
        }
Пример #9
0
 public override bool IsValid(Context context, FightHandler fightHandler)
 {
     if (fightHandler.Entities[context.HolderId].Stats[Stat.Alive] == Value)
     {
         return(true);
     }
     return(false);
 }
Пример #10
0
 public MobaClient(InitRequest initRequest) : base(initRequest)
 {
     account = new AccountHandler();
     player  = new PlayerHandler();
     select  = new SelectHandler();
     fight   = new FightHandler();
     player.StartSelectEvent += select.StartSelect;
     select.StartFightEvent   = fight.StartFight;
 }
Пример #11
0
        public MobaClient(InitRequest initRequest) : base(initRequest)
        {
            Account = new AccountHandler();
            Player  = new PlayerHandler();
            Select  = new SelectHandler();
            Fight   = new FightHandler();

            Player.StartSelectEvent = Select.StartSelect;
            Select.StartFightEvent  = Fight.StartSelect;
        }
Пример #12
0
 public override void ActivateSkill(Character activator, List <Character> targets)
 {
     //HistoryHandler.AddToCurrentAction(activator.Name + " CASTS " + _name + "\n");
     for (int i = 0; i < targets.Count; i++)
     {
         FightHandler.AttackEnemy(activator, targets[i]);
         FightHandler.AttackEnemy(activator, targets[i]);
     }
     activator.CurrMana -= _mpCost;
 }
Пример #13
0
 public override void ActivateSkill(Character activator, List <Character> targets)
 {
     for (int i = 0; i < targets.Count; i++)
     {
         int totalDamage = activator.Offense.Strength + activator.HeldWeapon.MagicMod + _damage;
         //HistoryHandler.AddToCurrentAction(activator.Name + " CASTS " + _name + ", and DEALS " + Mathf.Abs(targets[i].Defense.CalculateDamage(totalDamage, _element, false)).ToString() + " to " + targets[i].Name + "\n");
         FightHandler.AbilityEnemy(totalDamage, _element, targets[i]);
     }
     activator.CurrMana -= _mpCost;
 }
Пример #14
0
 public override void Execute(Context context, FightHandler fightHandler)
 {
     if (ConditionValid(context, fightHandler))
     {
         Debug.Log("Gain threat  Effect executed");
         foreach (int targetId in targets.GetTargets(context))
         {
             fightHandler.FireEvent(new EntityStatChangedEvent(targetId, targetId, Stat.Threat, value));
         }
     }
 }
Пример #15
0
        /// <summary>
        /// 攻击动作
        /// </summary>
        /// <param name="game"></param>
        /// <param name="MyPos">攻击方</param>
        /// <param name="YourPos">被攻击方</param>
        /// <param name="IsMyAction">动作发起方</param>
        /// <returns></returns>
        public static List <string> Fight(ActionStatus game, int MyPos, int YourPos, bool IsMyAction)
        {
            game.battleEvenetHandler.事件池.Clear();
            //FIGHT#1#2
            string        actionCode    = ActionCode.strFight + CardUtility.strSplitMark + MyPos + CardUtility.strSplitMark + YourPos;
            List <string> ActionCodeLst = new List <string>();

            ActionCodeLst.Add(actionCode);
            ActionCodeLst.AddRange(FightHandler.Fight(MyPos, YourPos, game, IsMyAction));
            ActionCodeLst.AddRange(game.battleEvenetHandler.事件处理(game));
            return(ActionCodeLst);
        }
Пример #16
0
 public MobaClient(InitRequest initRequest) : base(initRequest)
 {
     account = new AccountHandler();
     player  = new PlayerHandler();
     select  = new SelectHander();
     fight   = new FightHandler();
     //一但调用player开始选人就会调用select.startselect
     //行为函数
     //方法注册到事件
     player.StartSelectEvent = select.StartSelect;
     select.StartFightEvent  = fight.StartFight;
 }
Пример #17
0
    public override void OnEvent(Event newEvent, FightHandler fightHandler)
    {
        if (newEvent is SpellCastEvent spellCastEvent)
        {
            Debug.Log("Spell Cast rule activated");

            ListeningEffect newListeningEffect = new ListeningEffect(newEvent.TargetId,
                                                                     new InstantTrigger(), new InstantTrigger(), spellCastEvent.SpellCast.Effects);
            fightHandler.ListeningEffects.Add(newListeningEffect);
            fightHandler.FireEvent(new ListeningEffectPlacedEvent(spellCastEvent.TargetId,
                                                                  spellCastEvent.SourceId, newListeningEffect.Id));
        }
    }
Пример #18
0
 public override void Execute(Context context, FightHandler fightHandler)
 {
     if (ConditionValid(context, fightHandler))
     {
         Debug.Log("Revive Effect executed");
         if (fightHandler.Entities[context.HolderId].Stats[Stat.Alive] == 0)
         {
             int resetHp = fightHandler.Entities[context.HolderId].Stats[Stat.Hp];
             fightHandler.FireEvent(new EntityStatChangedEvent(context.HolderId, context.HolderId, Stat.Hp, -1 * resetHp + 1));
             fightHandler.FireEvent(new EntityStatChangedEvent(context.HolderId, context.HolderId, Stat.Alive, 1));
         }
     }
 }
Пример #19
0
 public override void Execute(Context context, FightHandler fightHandler)
 {
     if (ConditionValid(context, fightHandler))
     {
         Debug.Log("Taunt Effect executed");
         foreach (Entity entity in fightHandler.Entities.Values)
         {
             if (entity.Id != context.SourceId)
             {
                 int threadDrop = entity.Stats[Stat.Threat];
                 fightHandler.FireEvent(new EntityStatChangedEvent(entity.Id, entity.Id, Stat.Threat, -1 * threadDrop));
             }
         }
     }
 }
Пример #20
0
    //called when grid setup is complete, start battle on grid
    public void StartFight(int enemies, CameraFollow battleCam)
    {
        _gridCamera = battleCam;
        //Camera.main.enabled = false;
        _gridUI.gameObject.SetActive(false);

        //_gridCamera.Init();
        _gridCamera.HardResetCamera();

        FightHandler.Init(enemies, _playerCharacters);
        _battleUI.gameObject.SetActive(true);
        _battleUI.Init(_gridCamera);
        WorldGridHandler.WorldInstance.ResetPanels();
        //Debug.Log("starting Player Control");
    }
Пример #21
0
    public override void WhatDo()
    {
        Debug.Log("What Do Called");
        if (_currTarget == null || _currTarget.IsDead)
        {
            _currTarget = FightHandler.FindRandomEnemy(_me, _me.Team);
        }

        //Debug.Log("what do");

        _hasAttacked   = false;
        _hasMoved      = false;
        _currentAction = 0;

        ContinueTurn();
    }
Пример #22
0
 public override void Execute(Context context, FightHandler fightHandler)
 {
     if (ConditionValid(context, fightHandler))
     {
         Debug.Log("Healing  Effect executed");
         foreach (int targetId in targets.GetTargets(context))
         {
             Entity source  = fightHandler.Entities[sources.GetTargets(context)[0]];
             float  healing = value * (100.0f + source.Stats[Stat.Healing]) / (100.0f);
             fightHandler.FireEvent(new EntityStatChangedEvent(targetId, targetId, Stat.Hp, (int)healing));
         }
         foreach (int sourceId in sources.GetTargets(context))
         {
             fightHandler.FireEvent(new EntityStatChangedEvent(sourceId, sourceId, Stat.Threat, value));
         }
     }
 }
Пример #23
0
 public override void OnAfterEvent(Event newEvent, FightHandler fightHandler)
 {
     if (newEvent is EntityStatChangedEvent statChangedEvent)
     {
         if (statChangedEvent.StatId == Stat.Hp)
         {
             if (fightHandler.Entities[newEvent.TargetId].Stats[Stat.Hp] <= 0 &&
                 fightHandler.Entities[newEvent.TargetId].Stats[Stat.Alive] == 1)
             {
                 Debug.Log("Death rule activated");
                 fightHandler.FireEvent(new EntityStatChangedEvent(newEvent.TargetId, newEvent.TargetId, Stat.Alive, -1));
                 if (fightHandler.Entities[newEvent.TargetId].Stats[Stat.Alive] == 0)
                 {
                     fightHandler.FireEvent(new EntityDiesEvent(newEvent.TargetId, newEvent.SourceId));
                 }
             }
         }
     }
 }
Пример #24
0
 public override void OnAfterEvent(Event newEvent, FightHandler fightHandler)
 {
     Debug.Log("Debug 1 ");
     if (newEvent is EntityStatChangedEvent statChangedEvent)
     {
         Debug.Log("Debug 2 ");
         if (statChangedEvent.StatId == Stat.Hp)
         {
             Debug.Log("Debug 3 : Current Hp : " + fightHandler.Entities[newEvent.TargetId].Stats[Stat.Hp]);
             Debug.Log("Debug 3 : Max Hp : " + fightHandler.Entities[newEvent.TargetId].EntityDefinition.BaseStats[Stat.Hp]);
             if (fightHandler.Entities[newEvent.TargetId].Stats[Stat.Hp] >
                 fightHandler.Entities[newEvent.TargetId].EntityDefinition.BaseStats[Stat.Hp])
             {
                 Debug.Log("OverHealing rule activated");
                 fightHandler.Entities[newEvent.TargetId].Stats[Stat.Hp] =
                     fightHandler.Entities[newEvent.TargetId].EntityDefinition.BaseStats[Stat.Hp];
             }
         }
     }
 }
Пример #25
0
 public override void OnAfterEvent(Event newEvent, FightHandler fightHandler)
 {
 }
Пример #26
0
        /// <summary>
        /// 处理对方的动作
        /// </summary>
        /// <param name="ActionCommand"></param>
        /// <param name="game"></param>
        public static void Process(string ActionCommand, ActionStatus game)
        {
            string[] actField = ActionCommand.Split(CardUtility.strSplitMark.ToCharArray());
            switch (ActionCode.GetActionType(ActionCommand))
            {
            case ActionCode.ActionType.Card:
                CardEffect.ReRunEffect(1, game, actField);
                break;

            case ActionCode.ActionType.UseMinion:
                int Pos    = int.Parse(actField[2]);
                var minion = (MinionCard)CardUtility.GetCardInfoBySN(actField[1]);
                minion.初始化();
                game.AllRole.YourPublicInfo.BattleField.PutToBattle(Pos, minion);
                Buff.ResetBuff(game);
                break;

            case ActionCode.ActionType.UseWeapon:
                game.AllRole.YourPublicInfo.Hero.Weapon = (WeaponCard)CardUtility.GetCardInfoBySN(actField[1]);
                break;

            case ActionCode.ActionType.UseSecret:
                game.AllRole.YourPublicInfo.Hero.SecretCount++;;
                break;

            case ActionCode.ActionType.UseAbility:
                break;

            case ActionCode.ActionType.Fight:
                //FIGHT#1#2
                FightHandler.Fight(int.Parse(actField[2]), int.Parse(actField[1]), game, false);
                break;

            case ActionCode.ActionType.Point:
                IAtomicEffect point = new PointEffect();
                point.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Health:
                IAtomicEffect health = new HealthEffect();
                health.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Status:
                IAtomicEffect status = new StatusEffect();
                status.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Transform:
                IAtomicEffect transform = new TransformEffect();
                transform.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Attack:
                IAtomicEffect attack = new AttackEffect();
                attack.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.HitSecret:
                SecretCard.ReRunSecret(game, actField);
                break;

            case ActionCode.ActionType.Control:
                ControlEffect.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Summon:
                SummonEffect.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Crystal:
                CrystalEffect.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.WeaponPoint:
                WeaponPointEffect.ReRunEffect(game, actField);
                break;

            case ActionCode.ActionType.Settle:
                ActionStatus.Settle(game);
                break;
            }
        }
Пример #27
0
 public virtual void OnEvent(Event newEvent, FightHandler fightHandler)
 {
 }
Пример #28
0
    void Start()
    {
        // Subscriptions

        interaction                   = player.GetComponent <Interaction>();
        interaction.onVomit          += triggeredVomit;
        interaction.onMop2Vomit      += triggeredMop2Vomit;
        interaction.onCousin2Fight   += triggeredCousin2Fight;
        interaction.onSixPack2Fridge += triggeredSixPack2Fridge;
        interaction.onBeer2Dj        += triggeredBeer2Dj;

        /*public event Action onVomit;
         * public event Action onMop2Vomit;
         * public event Action onFight;
         * public event Action onCousin2Fight;
         * public event Action onSixPack2Fridge;
         * public event Action onBeer2Dj;*/
        interaction.onGetMop      += triggeredGetMop;
        interaction.onGetSixPack  += triggeredGetSixPack;
        interaction.onGetDrink    += triggeredGetDrink;
        interaction.onGetCousin   += triggeredGetCousin;
        interaction.onDropMop     += triggeredDropMop;
        interaction.onDropSixPack += triggeredDropSixPack;
        interaction.onDropDrink   += triggeredDropDrink;
        interaction.onDropCousin  += triggeredDropCousin;
        interaction.onFever       += triggeredFever;


        fightHandler             = handlerObject.GetComponent <FightHandler>();
        fightHandler.onNewFight += triggeredFight;

        // handlePeople = handlerObject.GetComponent<HandlePeople>();

        // Counters
        countersObject = transform.Find("Counters").gameObject;
        counter        = countersObject.GetComponent <Counters>();

        // Bar manager
        statBarManagerObject = transform.Find("StatBarManager").gameObject;
        statBarManager       = statBarManagerObject.GetComponent <StatBarManager>();

        // Bar objects and statbars
        safetyBarObject = transform.Find("StatBars/Safety").gameObject;
        statBarSafety   = safetyBarObject.GetComponent <StatBar>();

        boozeBarObject = transform.Find("StatBars/Booze").gameObject;
        statBarBooze   = boozeBarObject.GetComponent <StatBar>();

        cleannessBarObject = transform.Find("StatBars/Cleanness").gameObject;
        statBarCleanness   = cleannessBarObject.GetComponent <StatBar>();

        djFokusBarObject = transform.Find("StatBars/DJFokus").gameObject;
        statBarDjFokus   = djFokusBarObject.GetComponent <StatBar>();


        // Initializing bars
        statBarManager.InitializeStatBar(statBarSafety, statSafety);
        statBarManager.InitializeStatBar(statBarBooze, statBooze);
        statBarManager.InitializeStatBar(statBarCleanness, statCleanness);
        statBarManager.InitializeStatBar(statBarDjFokus, statDjFokus);

        // Automatically starting to decrease
        statBarManager.PeriodicallyChangeStatBar(statBarDjFokus, -0.02f);

        // Dynamic coroutine to reduce booze bar depending of the amount of npcs
        statBarManager.PeriodicallyChangeStatBarDependingOnPeople(statBarBooze, -0.003f);
        statBarManager.PeriodicallyChangeStatBarDependingOnFights(statBarSafety, -0.01f);
    }
Пример #29
0
 private void Awake()
 {
     Instance = this;
 }
Пример #30
0
 public override void Attack(Character target)
 {
     FightHandler.AttackEnemy(this, target);
     return;
 }