Beispiel #1
0
    // On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._actor = target;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            // Register turn start listener
            target.AddTurnStartListener(this);
        }
    }
Beispiel #2
0
 private void checkManna(BattleContext context, int tick)
 {
     foreach (var player in context.players.players)
     {
         if (_lastManna[player.id] != player.manna.value)
         {
             var evt = context.output.enqueueByFactory <MannaChangeEvent>();
             evt.ownerId = player.id;
             evt.manna   = player.manna.value;
             evt.tick    = tick;
         }
     }
 }
Beispiel #3
0
        public static AutohostMode GetMode(this BattleContext ctx)
        {
            var conf = GetConfig(ctx);

            if (conf != null)
            {
                return(conf.AutohostMode);
            }
            else
            {
                return(AutohostMode.None);
            }
        }
Beispiel #4
0
    public void TestCard()
    {
        BattleContext context = DataManager.Instance.BattleContext;

        if (null != context && context.Player.Power.Property >= _elementCard.Cost.Property)
        {
            Debug.Log("testing card");
            ElementCardPlayEvent cardEvent = new ElementCardPlayEvent();
            cardEvent.Card    = _elementCard;
            cardEvent.Targets = null;
            EventManager.TriggerEvent(BattleManager.PLAY_ELEMENT_CARD, cardEvent);
        }
    }
 protected override void OnExecute()
 {
     battleContext = GameEntry.Context.Battle;
     GameEntry.Event.OnViewPointerClick.AddListener(OnViewPointerClick);
     GameEntry.Event.OnViewPointerEnter.AddListener(OnViewPointerEnter);
     GameEntry.Event.OnViewPointerExit.AddListener(OnViewPointerExit);
     battleContext.alreadyPlayerMonsterHovered = false;
     battleContext.playerMonsters.ForEach(m => m.Selectable = !battleContext.monsterBattleTurnDatas[m].actionDone);
     if (battleContext.playerMonsters.All(m => battleContext.monsterBattleTurnDatas[m].actionDone))
     {
         onAllPlayerMonstersActionDone?.Raise(this, null);
     }
 }
Beispiel #6
0
 public IEnumerator <YieldInstruction> Hit(BattleContext context)
 {
     DungeonScene.EventEnqueueFunction <BattleEvent> function = (StablePriorityQueue <GameEventPriority, Tuple <GameEventOwner, Character, BattleEvent> > queue, Priority maxPriority, ref Priority nextPriority) =>
     {
         //include the universal effect here
         DataManager.Instance.UniversalEvent.AddEventsToQueue(queue, maxPriority, ref nextPriority, DataManager.Instance.UniversalEvent.OnHits);
         AddEventsToQueue <BattleEvent>(queue, maxPriority, ref nextPriority, OnHits);
     };
     foreach (Tuple <GameEventOwner, Character, BattleEvent> effect in DungeonScene.IterateEvents <BattleEvent>(function))
     {
         yield return(CoroutineManager.Instance.StartCoroutine(effect.Item3.Apply(effect.Item1, effect.Item2, context)));
     }
 }
Beispiel #7
0
    // On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._target = target;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            // register decorator
            target.UnderAttackDecoratorList.AddItem(this);
        }
    }
Beispiel #8
0
 public IEnumerator <YieldInstruction> Hit(BattleContext context)
 {
     DungeonScene.EventEnqueueFunction <BattleEvent> function = (StablePriorityQueue <GameEventPriority, EventQueueElement <BattleEvent> > queue, Priority maxPriority, ref Priority nextPriority) =>
     {
         //include the universal effect here
         DataManager.Instance.UniversalEvent.AddEventsToQueue(queue, maxPriority, ref nextPriority, DataManager.Instance.UniversalEvent.OnHits, null);
         ZoneManager.Instance.CurrentMap.MapEffect.AddEventsToQueue(queue, maxPriority, ref nextPriority, ZoneManager.Instance.CurrentMap.MapEffect.OnHits, null);
         AddEventsToQueue <BattleEvent>(queue, maxPriority, ref nextPriority, OnHits, null);
     };
     foreach (EventQueueElement <BattleEvent> effect in DungeonScene.IterateEvents <BattleEvent>(function))
     {
         yield return(CoroutineManager.Instance.StartCoroutine(effect.Event.Apply(effect.Owner, effect.OwnerChar, context)));
     }
 }
Beispiel #9
0
    // Turn start
    public virtual void StartTurn(BattleContext mgr)
    {
        //重置減傷值
        this._defence.Property = 0;

        //回合開始事件通知
        List <IActorTurnStartListener> listeners = new List <IActorTurnStartListener>();

        listeners.AddRange(_turnStartListeners.GetAll());
        foreach (IActorTurnStartListener listener in listeners)
        {
            listener.OnTurnStart();
        }
    }
Beispiel #10
0
    // On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        int originalHP = target.HealthPoint.Property;

        HealingPercentage healingEffect = new HealingPercentage();

        healingEffect.BoostedRatio    = this._boostedRatio;
        healingEffect.GeneralRatio    = this._generalRatio;
        healingEffect.SuppressedRatio = this._suppressedRatio;

        healingEffect.RunAction(source, target, card, manager);

        // add armor
        target.Armor.Property += (target.HealthPoint.Property - originalHP);
    }
Beispiel #11
0
    //On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        int drop = _generalDrop;

        if (Utilities.IsOvercominInteraction(Utilities.GetElement(target.Element), Utilities.GetElement(card.Element)))
        {
            drop = _overcomingDrop;
        }
        else if (Utilities.IsOvercominInteraction(Utilities.GetElement(card.Element), Utilities.GetElement(target.Element)))
        {
            drop = _interactingDrop;
        }

        target.Armor.Property -= drop;
    }
Beispiel #12
0
    // decorate
    public AttackInfo Decorate(Actor source, Actor target, AttackInfo value, BattleContext mgr)
    {
        if (value.Attack > 0)
        {
            // run attack effect
            Attack attack = new Attack();
            attack.BasicAttack      = (int)(value.Attack * _ratio);
            attack.BoostedAttack    = (int)(value.Attack * _ratio);
            attack.SuppressedAttack = (int)(value.Attack * _ratio);

            attack.RunAction(target, source, this._card, mgr);
        }

        return(value);
    }
Beispiel #13
0
    //On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        int incrememnt = _generalAddition;

        if (Utilities.IsGeneratingInteraction(Utilities.GetElement(target.Element), Utilities.GetElement(card.Element)))
        {
            incrememnt = _boostedAddition;
        }
        else if (Utilities.IsGeneratingInteraction(Utilities.GetElement(card.Element), Utilities.GetElement(target.Element)))
        {
            incrememnt = _suppressedAddition;
        }

        target.Armor.Property += incrememnt;
    }
        public BattleController(BattleContext context)
        {
            var random = new Random();

            Layer = new Layer2D();
            Scene = new Scene();
            coordinateConverter = new ModelToViewCoordinateConverter();
            headerFont          = Engine.Graphics.CreateFont("Fonts/Header.aff");
            planeFont           = Engine.Graphics.CreateFont("Fonts/Body.aff");

            var background = new GeometryObject2D()
            {
                Shape = new RectangleShape
                {
                    DrawingArea = new RectF(0, 0, 1280, 720),
                },
                Color           = new Color(255, 255, 255),
                DrawingPriority = -2
            };

            Layer.AddObject(background);

            var localPlayerProfileObject = new TextureObject2D()
            {
                Position = new Vector2DF(1280, 720),
            };
            var remotePlayerProfileObject = new TextureObject2D()
            {
                Position = new Vector2DF(0, 0),
                Angle    = 180,
            };

            Layer.AddObject(localPlayerProfileObject);
            Layer.AddObject(remotePlayerProfileObject);

            for (int i = 0; i < context.LocalPlayer.Tokens.Length; i++)
            {
                var token = context.LocalPlayer.Tokens[i];
                ShowToken(random, token, localPlayerProfileObject, i);
            }
            for (int i = 0; i < context.RemotePlayer.Tokens.Length; i++)
            {
                var token = context.RemotePlayer.Tokens[i];
                ShowToken(random, token, remotePlayerProfileObject, i);
            }

            Scene.AddLayer(Layer);
        }
Beispiel #15
0
    // On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._target = target;
        this._target.AttackEnable.Property = false;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            target.FocusAble.Property = false;

            // add turn start listener
            target.AddTurnStartListener(this);
        }
    }
Beispiel #16
0
    public void Destroy()
    {
        if (null != this._battleContext)
        {
            this._battleContext.ActorList    = null;
            this._battleContext.CurrentActor = null;
            this._battleContext.EnemyList    = null;
            this._battleContext.Player       = null;
            this._battleContext = null;
            this._battleContext.HightLightCardsList = null;
        }

        EventManager.StopListening(END_TURN, EndTurn);
        EventManager.StopListening(PLAY_ELEMENT_CARD, OnElementCardPlayed);
        EventManager.StopListening(PLAY_ULTIMATE_CARD, OnUltimateCardPlayed);
    }
Beispiel #17
0
    // 當效果被附加至對象對被呼叫
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        //根據機率附加新效果
        float result = Random.Range(0f, 1f);

        if (result <= _probability)
        {
            DamagePerTurn effect = new DamagePerTurn();
            effect.GeneralDamage    = _generalDamage;
            effect.BoostedDamage    = _boostedDamage;
            effect.SuppressedDamage = _suppressedDamage;
            effect.Turns            = _turns;

            effect.RunAction(source, target, card, manager);
        }
    }
Beispiel #18
0
 // On effect added the the actor
 public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
 {
     // 檢查 相生 順向
     if (Utilities.IsGeneratingInteraction(Utilities.GetElement(target.Element), Utilities.GetElement(card.Element)))
     {
         target.HealthPoint.Property += (int)(target.HealthPoint.Property * _boostedRatio);
     }
     // 檢查 相生 逆向
     else if (Utilities.IsGeneratingInteraction(Utilities.GetElement(card.Element), Utilities.GetElement(target.Element)))
     {
         target.HealthPoint.Property += (int)(target.HealthPoint.Property * _suppressedRatio);
     }
     else
     {
         target.HealthPoint.Property += (int)(target.HealthPoint.Property * _generalRatio);
     }
 }
Beispiel #19
0
    // On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._actor   = target;
        this._element = card.Element;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            // register turn start listener
            target.AddTurnStartListener(this);

            // register decorator
            target.AttackDecoratorList.AddItem(this);
        }
    }
Beispiel #20
0
        public BattleContext GetContext()
        {
            var ret = new BattleContext();

            ret.AutohostName = Founder.Name;
            ret.Map          = MapName;
            ret.Mod          = ModName;
            ret.Players      = Users.Where(x => x.SyncStatus != SyncStatuses.Unknown).Select(x => new PlayerTeam()
            {
                AllyID = x.AllyNumber, Name = x.Name, LobbyID = x.LobbyUser.LobbyID, TeamID = x.TeamNumber, IsSpectator = x.IsSpectator
            }).ToList();

            ret.Bots = Bots.Select(x => new BotTeam()
            {
                BotName = x.Name, AllyID = x.AllyNumber, TeamID = x.TeamNumber, Owner = x.owner, BotAI = x.aiLib
            }).ToList();
            return(ret);
        }
Beispiel #21
0
    //On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._target = target;
        this._source = source;
        this._card   = card;
        this._mgr    = manager;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            target.AttackDecoratorList.AddItem(this);

            //register turn start listener
            target.AddTurnStartListener(this);
        }
    }
Beispiel #22
0
        override public void preTick(BattleContext context, int tick, int deltaTick)
        {
            base.preTick(context, tick, deltaTick);

            _temp.length = 0;
            foreach (ActorsGroup e in Enum.GetValues(typeof(ActorsGroup)).Cast <ActorsGroup>())
            {
                context.actors.group(e).GetComponentsInChildren(typeof(BattleComponent), true, true, _temp);

                foreach (BattleComponent item in _temp)
                {
                    item.update(tick, deltaTick);
                    if (item.needRemove)
                    {
                        item.Dispose();
                    }
                }
            }
        }
 override public void preTick(BattleContext context, int tick, int deltaTick)
 {
     _temp.length = 0;
     context.actors.buildings.getActors(typeof(BattleBuilding), _temp);
     foreach (BattleBuilding item in _temp)
     {
         var regenComponent = item.GetComponent <UnitRegenComponent>();
         if (regenComponent != null)
         {
             if (regenComponent.regen(deltaTick))
             {
                 var evt = context.output.enqueueByFactory <BuildingChangeUnitEvent>();
                 evt.objectId = item.objectId;
                 evt.units    = regenComponent.units;
                 evt.tick     = tick;
             }
         }
     }
 }
Beispiel #24
0
    public void ComboCardPolymery()
    {
        ComboCardUIController.SetVisible(false);
        Debug.Log("play combo");

        BattleContext context = DataManager.Instance.BattleContext;

        if (null != context)
        {
            UltimateCardPlayEvent cardEvent = new UltimateCardPlayEvent();

            cardEvent.Card    = ComboCardUIController.GetCardInstance();
            cardEvent.Targets = null;

            bool isPlayable = false;
            ListenableList <ElementCardInstance> handHeldSet = context.Player.HandheldSet;
            int totalCnt = handHeldSet.GetCount();
            for (int i = 0; i < totalCnt; i++)
            {
                for (int j = 0; j < totalCnt; j++)
                {
                    if (cardEvent.Card.IsCardPlayable(handHeldSet.Get(i), handHeldSet.Get(j)))
                    {
                        isPlayable          = true;
                        cardEvent.LeftCard  = handHeldSet.Get(i);
                        cardEvent.RightCard = handHeldSet.Get(j);
                        EventManager.TriggerEvent(BattleManager.PLAY_ULTIMATE_CARD, cardEvent);
                        break;
                    }
                    else if (cardEvent.Card.IsCardPlayable(handHeldSet.Get(j), handHeldSet.Get(i)))
                    {
                        isPlayable          = true;
                        cardEvent.LeftCard  = handHeldSet.Get(j);
                        cardEvent.RightCard = handHeldSet.Get(i);
                        EventManager.TriggerEvent(BattleManager.PLAY_ULTIMATE_CARD, cardEvent);
                        break;
                    }
                }
            }

            Debug.Log("IsCombo Card Played: " + isPlayable.ToString());
        }
    }
Beispiel #25
0
        override public void preTick(BattleContext context, int tick, int deltaTick)
        {
            _buildings.length = 0;
            context.actors.buildings.getActors(typeof(BattleBuilding), _buildings);

            _units.length = 0;
            context.actors.units.getActors(typeof(BattleUnit), _units);

            foreach (var building in _buildings)
            {
                var component = building.GetComponent <BuildingAttackDefenseComponent>();
                if (component != null && component.canAttack)
                {
                    var        range       = component.range;
                    BattleUnit target      = null;
                    double     minDistance = int.MaxValue;
                    foreach (BattleUnit unit in _units)
                    {
                        if (unit.ownerId != building.ownerId)
                        {
                            var distance = unit.transform.positionDistance(building.transform);
                            if (distance <= range)
                            {
                                if (distance < minDistance)
                                {
                                    minDistance = distance;
                                    target      = unit;
                                }
                            }
                        }
                    }
                    if (target != null)
                    {
                        component.attack(target);

                        var evt = context.output.enqueueByFactory <BuildingAttackEvent>();
                        evt.objectId = building.objectId;
                        evt.targetId = target.objectId;
                        evt.tick     = tick;
                    }
                }
            }
        }
Beispiel #26
0
        private void addBuildings(BattleAction action, BattleContext context)
        {
            foreach (var record in context.configuration.buildings)
            {
                var battleObject = context.actors.factory.buildingFactory.instantiate(typeof(BattleBuilding));
                context.actors.buildings.AddComponent(battleObject);
                battleObject.initialize(record, context.configuration);

                var evt = context.output.enqueueByFactory <BuildingCreateEvent>();
                evt.objectId   = battleObject.objectId;
                evt.buildingId = battleObject.info.Id;
                evt.level      = battleObject.level;
                evt.ownerId    = battleObject.ownerId;
                evt.tick       = action.tick;
                evt.x          = battleObject.transform.x;
                evt.y          = battleObject.transform.y;
                evt.units      = battleObject.units.count;
            }
        }
Beispiel #27
0
        protected override BattleContext CreateContext(GameEventOwner owner, Character ownerChar, BattleContext context)
        {
            Character target = (AffectTarget ? context.Target : context.User);
            int       damage = context.GetContextStateInt <DamageDealt>(0);

            if (damage > 0 && ownerChar != context.User)
            {
                //the attack needs to face the foe, and *auto-target*
                Dir8 attackDir = DirExt.GetDir(ownerChar.CharLoc, target.CharLoc);
                ownerChar.CharDir = attackDir;
                Loc frontLoc = ownerChar.CharLoc + attackDir.GetLoc() * FrontOffset;

                SkillData entry = DataManager.Instance.GetSkill(InvokedMove);

                DungeonScene.Instance.LogMsg(String.Format(Msg.ToLocal(), ownerChar.GetDisplayName(false), context.User.GetDisplayName(false)));

                BattleContext newContext = new BattleContext(BattleActionType.Skill);
                newContext.User      = ownerChar;
                newContext.UsageSlot = BattleContext.FORCED_SLOT;

                newContext.StartDir = newContext.User.CharDir;

                //fill effects
                newContext.Data         = new BattleData(entry.Data);
                newContext.Data.ID      = InvokedMove;
                newContext.Explosion    = new ExplosionData(entry.Explosion);
                newContext.HitboxAction = entry.HitboxAction.Clone();
                //make the attack *autotarget*; set the offset to the space between the front loc and the target
                newContext.HitboxAction.HitOffset = target.CharLoc - frontLoc;
                newContext.Strikes = entry.Strikes;
                newContext.Item    = new InvItem();
                //don't set move message, just directly give the message of what the move turned into

                //add a tag that will allow the moves themselves to switch to their offensive versions
                newContext.ContextStates.Set(new FollowUp());


                return(newContext);
            }

            return(null);
        }
Beispiel #28
0
        private bool TryCastSkill()
        {
            if (this.target != null)
            {
                BattleContext context = new BattleContext(this.owner.Map.Battle)
                {
                    Target = this.target,
                    Caster = this.owner,
                };

                Skill skill = this.owner.FindSkill(context, SkillType.Skill);
                if (skill != null)
                {
                    this.owner.CastSkill(context, skill.Define.ID);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #29
0
    // On effect added the the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext context)
    {
        int hpchange = 0;

        // 檢查 相生 順向
        if (Utilities.IsGeneratingInteraction(Utilities.GetElement(target.Element), Utilities.GetElement(card.Element)))
        {
            hpchange += _boostedHealing;
        }
        // 檢查 相生 逆向
        else if (Utilities.IsGeneratingInteraction(Utilities.GetElement(card.Element), Utilities.GetElement(target.Element)))
        {
            hpchange += _suppressedHealing;
        }
        else
        {
            hpchange += _generalHealing;
        }
        target.HealthPoint.Property += hpchange;
    }
Beispiel #30
0
    //On effect added to the actor
    public void RunAction(Actor source, Actor target, Card card, BattleContext manager)
    {
        this._target = target;
        this._source = source;
        this._card   = card;
        this._mgr    = manager;

        this._effect                 = new ArmorDrop();
        this._effect.GeneralDrop     = _generalDrop;
        this._effect.OvercomingDrop  = _overcomingDrop;
        this._effect.InteractingDrop = _interactingDrop;

        // add to effect list
        bool isInsertSuccess = target.BuffList.TryInsert(this);

        if (isInsertSuccess)
        {
            //register turn start listener
            target.AddTurnStartListener(this);
        }
    }