Exemplo n.º 1
0
 public Ability AddAction(AbilityAction action)
 {
     action.SetOwner(mOwner, Id);
     mActions.Add(action);
     MaxRange = Mathf.Min(MaxRange, action.MaxRange);
     return(this);
 }
Exemplo n.º 2
0
 private void RemoveAbility(AbilityAction aa)
 {
     for (int i = 0; i < aa.tiles.Count; i++)
     {
         aa.tiles[i].tilehelper.Undo();
     }
 }
Exemplo n.º 3
0
        IEnumerator PlayCards()
        {
            var encounter = Container.GetMatch().CurrentPlayer as Encounter;

            for (int i = 0; i < encounter.party.Count; i++)
            {
                var monster = encounter.party[i] as Monster;
                var cards   = monster.monsterCards;

                foreach (var card in cards)
                {
                    card.turnsRemaining--;
                    if (card.turnsRemaining <= 0)
                    {
                        var abilities = card.GetAspects <Ability>();
                        foreach (var ability in abilities)
                        {
                            var action = new AbilityAction(ability);
                            Container.Perform(action);

                            card.turnsRemaining = card.frequency;
                            yield return(true);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
    public AbilityActionStatus Perform(CharacterProperty target)
    {
        mTarget = target;

        mOwner.ReduceMP(mCost);

        if (CoodDownLeft <= 0)
        {
            mLastTime = Time.time;

            for (int i = 0; i < mActions.Count; i++)
            {
                mActions [i].Init();
            }

            currentIndex = 0;


            for (currentIndex = 0; currentIndex < mActions.Count; currentIndex++)
            {
                AbilityAction action = mActions [currentIndex];
                action.SetTarget(mTarget);
                action.Execute();
                AbilityActionStatus status = action.status;
                if (status != AbilityActionStatus.Success)
                {
                    return(status);
                }
            }
        }

        return(AbilityActionStatus.Success);
    }
Exemplo n.º 5
0
    //Al lanzar el hechizo aplica la acción de la habilidad
    void OnPrepareCastSpell(object sender, object args)
    {
        var action   = args as CastSpellAction;
        var ability  = action.spell.GetAspect <Ability> ();
        var reaction = new AbilityAction(ability);

        container.AddReaction(reaction);
    }
Exemplo n.º 6
0
 public void DrawNotCastedAbility(Ability ability, Tile tile)
 {
     Refresh();
     noCast        = true;
     abilityNoCast = new AbilityAction(ability, tile, ability.DrawIndicator(tile));
     noCast        = false;
     noCastSet     = true;
 }
Exemplo n.º 7
0
        private void Verify(
            GameEntity attacker,
            GameEntity victim,
            GameEntity sensor,
            SenseType attackerSensed,
            SenseType victimSensed,
            AbilityAction abilityAction,
            GameManager manager,
            int?damage,
            GameEntity weapon      = null,
            string expectedMessage = "")
        {
            var languageService = manager.Game.Services.Language;

            var appliedEffects = new List <GameEntity>();

            if (damage.HasValue)
            {
                using (var damageEffectEntity = manager.CreateEntity())
                {
                    var entity = damageEffectEntity.Referenced;

                    var appliedEffect = manager.CreateComponent <EffectComponent>(EntityComponent.Effect);
                    appliedEffect.Amount           = damage.Value;
                    appliedEffect.EffectType       = EffectType.PhysicalDamage;
                    appliedEffect.AffectedEntityId = victim.Id;

                    entity.Effect = appliedEffect;

                    appliedEffects.Add(entity);
                }

                if (weapon != null)
                {
                    using (var weaponEffectEntity = manager.CreateEntity())
                    {
                        var entity = weaponEffectEntity.Referenced;

                        var appliedEffect = manager.CreateComponent <EffectComponent>(EntityComponent.Effect);
                        appliedEffect.Amount           = damage.Value;
                        appliedEffect.EffectType       = EffectType.Activate;
                        appliedEffect.TargetEntityId   = weapon.Id;
                        appliedEffect.AffectedEntityId = victim.Id;

                        entity.Effect = appliedEffect;

                        appliedEffects.Add(entity);
                    }
                }
            }

            var attackEvent = new AttackEvent(sensor, attacker, victim, attackerSensed, victimSensed,
                                              appliedEffects, abilityAction, weapon,
                                              ranged: weapon != null && (weapon.Item.Type & ItemType.WeaponRanged) != 0, hit: damage.HasValue);

            Assert.Equal(expectedMessage, languageService.GetString(attackEvent));
        }
Exemplo n.º 8
0
    public override void KillCharacter(Character character)
    {
        AbilityAction aa = actions.Find(x => x.character == character);


        World.indicator.RemoveAbility(aa.ability, aa.tile);
        units.Remove(character);
        aiUnits.RemoveAll(x => x.character == character);
        aiUnits.Remove(character.GetComponent <AI_Spider>());
        actions.Remove(aa);
    }
Exemplo n.º 9
0
    public void RemoveAbility(Ability ability, Tile tile)
    {
        int index = activeAbilitys.FindIndex(x => (x.ability == ability && x.tile == tile));

        if (index != -1)
        {
            AbilityAction aa = activeAbilitys[index];
            RemoveAbility(aa);
            activeAbilitys.RemoveAt(index);
            Refresh();
        }
    }
Exemplo n.º 10
0
        private void OnPreparePlayToBoard(object sender, object args)
        {
            var action = (PlayToBoardAction)args;

            // TODO: Do we need to set priority levels for these reactions?
            foreach (var card in action.Cards)
            {
                var ability = card.GetAttribute <Ability>();
                if (ability != null && ability.Type == AbilityType.WhenPlayed)
                {
                    var reaction = new AbilityAction(ability);
                    Container.AddReaction(reaction);
                }
            }
        }
Exemplo n.º 11
0
        private void OnPrepareCastSpell(object sender, object args)
        {
            var action  = (CastSpellAction)args;
            var ability = action.Card.GetAttribute <Ability>();

            if (ability == null || ability.Type != AbilityType.WhenPlayed)
            {
                Debug.LogWarning($"CastSpellAction - No ability found for card {action.Card.Data.CardName}");
                return;
            }

            var reaction = new AbilityAction(ability);

            Container.AddReaction(reaction);
        }
Exemplo n.º 12
0
 public AttackEvent(
     GameEntity sensorEntity, GameEntity attackerEntity, GameEntity victimEntity,
     SenseType attackerSensed, SenseType victimSensed, IReadOnlyList <GameEntity> appliedEffects,
     AbilityAction abilityAction, GameEntity weaponEntity, bool ranged, bool hit)
 {
     SensorEntity   = sensorEntity;
     AttackerEntity = attackerEntity;
     VictimEntity   = victimEntity;
     AttackerSensed = attackerSensed;
     VictimSensed   = victimSensed;
     AppliedEffects = appliedEffects;
     AbilityAction  = abilityAction;
     WeaponEntity   = weaponEntity;
     Ranged         = ranged;
     Hit            = hit;
 }
Exemplo n.º 13
0
 public void LiuBeiAbtestmock()
 {
     {
         Player        p        = new LiuBei(0);
         Player[]      ls       = new Player[1];
         Attack        fakeCard = mocks.DynamicMock <Attack>(CardSuit.Club, (byte)1);
         IGame         fakeGame = mocks.DynamicMock <IGame>();
         AbilityAction fakeAb   = mocks.DynamicMock <AbilityAction>(fakeCard, ls);
         ls[0] = new ZhangFei(1);
         using (mocks.Ordered())
         {
             p.handCards.Remove(fakeCard);
         }
         mocks.ReplayAll();
         p.ability(fakeAb, fakeGame);
     }
 }
Exemplo n.º 14
0
 public void DoAbilitys()
 {
     currentUnit++;
     if (currentUnit >= actions.Count)
     {
         FinishedAIAbilitys();
         return;
     }
     if (actions[currentUnit].Ready())
     {
         AbilityAction aa = actions[currentUnit];
         actions.RemoveAt(currentUnit);
         currentUnit--;
         CastAbility(aa);
     }
     else
     {
         DoAbilitys();
     }
 }
Exemplo n.º 15
0
        void OnPerformPlayCardAction(object sender, object args)
        {
            var action = args as PlayCardAction;

            if (!CardType.Effective.Contains(action.card.Type))
            {
                return;
            }

            var abilities = action.card.GetAspects <Ability>();

            if (abilities != null)
            {
                foreach (var ability in abilities)
                {
                    var reaction = new AbilityAction(ability);
                    Container.AddReaction(reaction);
                }
            }
        }
Exemplo n.º 16
0
        private void OnPerformNextTurn(object sender, object args)
        {
            foreach (var card in passives)
            {
                if (card == null)
                {
                    return;
                }

                var abilities = card.GetAspects <Ability>();
                if (abilities != null)
                {
                    foreach (var ability in abilities)
                    {
                        var reaction = new AbilityAction(ability);
                        reaction.Priority = 5;
                        Container.AddReaction(reaction);
                    }
                }
            }
        }
Exemplo n.º 17
0
    public AbilityActionStatus Update()
    {
        if (currentIndex < mActions.Count)
        {
            for (; currentIndex < mActions.Count; currentIndex++)
            {
                AbilityAction action = mActions [currentIndex];
                action.SetTarget(mTarget);
                action.Execute();
                AbilityActionStatus status = action.status;
                if (status != AbilityActionStatus.Success)
                {
                    return(status);
                }
            }
        }

        if (onExit != null)
        {
            onExit.OnNext(this);
        }

        return(AbilityActionStatus.Success);
    }
Exemplo n.º 18
0
        private void randomInputResponse()
        {
            UserAction action;
            int        r = random.Next();

            switch (r % 10)
            {
            case 1:
                action = new CardAction(randomCard());
                break;

            case 2:
                if (random.Next() % 2 == 0)
                {
                    action = new YesOrNoAction(true);
                }
                else
                {
                    action = new YesOrNoAction(false);
                }
                break;

            case 3:
                action = new AbilityAction(randomCard(), randomPlayer());
                break;

            case 4:
                action = new AbilityActionSun(randomCard());
                break;

            default:
                action = new UseCardAction(randomCard(), randomPlayer());
                break;
            }
            game.processUserInput(game.curPhase.playerID, action);
        }
Exemplo n.º 19
0
 public virtual void OnTargetedByAbility(ref AbilityAction action)
 {
 }
Exemplo n.º 20
0
 public virtual void OnHitByAbility(ref AbilityAction action)
 {
 }
Exemplo n.º 21
0
    public void ChooseActions()
    {
        // Clears previous lists.
        abilityActions.Clear();
        movementActions.Clear();
        allies.Clear();
        enemies.Clear();

        // Finds allies and enemies.
        for (int i = 0; i < gameManager.Factions.Count; i++)
        {
            if (i == character.Faction)
            {
                allies = gameManager.Factions[i].Units;
            }
            else
            {
                enemies.AddRange(gameManager.Factions[i].Units);
            }
        }

        // Percentage of current health to max health used to determine how healthy a character is.
        healthiness = character.Health / character.MaxHealth;

        // Find locations to move to.
        moveLocations = character.MyLocation.FindPossibleMoves((int)character.Movement, character.Speed);
        // Find possible abilities to use.
        abilities = character.Abilities;

        // Creates a list of movement actions with scores.
        ScoreMovementActions();

        // Chooses a movement action from that list
        chosenMovement = ChooseMovementAction();

        // Creates a list of ability actions based off the chosen movement action
        ScoreAbilityActions();

        // Chooses an ability action from that list.
        chosenAbility = ChooseAbilityAction();
    }
Exemplo n.º 22
0
 public void CastAbility(AbilityAction aa)
 {
     CastAbility(aa.character, aa.ability, aa.tile);
 }
Exemplo n.º 23
0
    //The main function! This EXACT coroutine will be executed, even across frames.
    //See GameAction.cs for more information on how this function should work!
    public override IEnumerator TakeAction()
    {
        #if UNITY_EDITOR
        if (caller.abilities == null)
        {
            Debug.LogError($"A monster without abilites tried to activate ability {abilityIndex}", caller);
            yield break;
        }
        #else
        if (caller.abilites == null)
        {
            yield break;
        }
        #endif

        Ability toCast = caller.abilities[abilityIndex];

        caller.other = toCast.connections;
        bool          keepCasting = true;
        AbilityAction action      = this;
        caller.connections.OnCastAbility.BlendInvoke(toCast.connections.OnCastAbility, ref action, ref keepCasting);

        if (!keepCasting)
        {
            caller.other = null;
            yield break;
        }



        if (toCast.currentCooldown > 0)
        {
            Debug.Log($"Console: You cannot cast {toCast.displayName}, it still has {toCast.currentCooldown} turns left.");
            caller.other = null;
            yield break;
        }

        bool canFire = false;

        UIController.singleton.OpenTargetting(toCast.targeting, (b) => canFire = b);
        yield return(new WaitUntil(() => !UIController.WindowsOpen));

        if (canFire)
        {
            //Ready to cast!
            caller.connections.OnTargetsSelected.BlendInvoke(toCast.connections.OnTargetsSelected, ref toCast.targeting, ref toCast);

            for (int i = toCast.targeting.affected.Count - 1; i >= 0; i--)
            {
                toCast.targeting.affected[i].connections.OnTargetedByAbility.Invoke(ref action);
            }

            //Take out the costs
            caller.LoseResources(toCast.stats.costs);

            caller.connections.OnPreCast.BlendInvoke(toCast.connections.OnPreCast, ref toCast);

            toCast.Cast(caller);

            caller.connections.OnPostCast.BlendInvoke(toCast.connections.OnPostCast, ref toCast);

            for (int i = toCast.targeting.affected.Count - 1; i >= 0; i--)
            {
                toCast.targeting.affected[i].connections.OnHitByAbility.Invoke(ref action);
            }

            caller.energy -= 100;
        }

        caller.other = null;
    }
Exemplo n.º 24
0
 public virtual void OnCastAbility(ref AbilityAction action, ref bool canContinue)
 {
 }
Exemplo n.º 25
0
        protected virtual string ToVerb(AbilityAction abilityAction)
        {
            string verb;

            switch (abilityAction)
            {
            case AbilityAction.Punch:
                verb = "punch";
                break;

            case AbilityAction.Kick:
                verb = "kick";
                break;

            case AbilityAction.Touch:
                verb = "touch";
                break;

            case AbilityAction.Headbutt:
                verb = "headbutt";
                break;

            case AbilityAction.Claw:
                verb = "claw";
                break;

            case AbilityAction.Bite:
                verb = "bite";
                break;

            case AbilityAction.Suck:
                verb = "suck";
                break;

            case AbilityAction.Sting:
                verb = "sting";
                break;

            case AbilityAction.Hug:
                verb = "squeeze";
                break;

            case AbilityAction.Trample:
                verb = "trample";
                break;

            case AbilityAction.Spit:
                verb = "spit at";
                break;

            case AbilityAction.Throw:
                verb = "throw";
                break;

            case AbilityAction.Shoot:
                verb = "shoot at";
                break;

            case AbilityAction.Digestion:
                verb = "digest";
                break;

            case AbilityAction.Spell:
                verb = "cast a spell at";
                break;

            case AbilityAction.Breath:
                verb = "breath at";
                break;

            case AbilityAction.Gaze:
                verb = "gaze at";
                break;

            case AbilityAction.Scream:
                verb = "scream at";
                break;

            case AbilityAction.Explosion:
                verb = "explode";
                break;

            case AbilityAction.Chop:
                verb = "chop";
                break;

            case AbilityAction.Bludgeon:
                verb = "bludgeon";
                break;

            case AbilityAction.Slash:
                verb = "slash";
                break;

            case AbilityAction.Poke:
                verb = "poke";
                break;

            case AbilityAction.Hit:
                verb = "hit";
                break;

            case AbilityAction.Impale:
                verb = "impale";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(abilityAction), abilityAction, message: null);
            }

            return(verb);
        }
Exemplo n.º 26
0
 public void SendAbility(AbilityAction abilityAction)
 {
     _photonView.RPC("GetAbility", RpcTarget.All, abilityAction.AbilityActionData);
 }
Exemplo n.º 27
0
 public void GetAbility(Dictionary <string, string> abilityAction)
 {
     AbilityAction.AbilityActionDeserialize(abilityAction);
     Unit.ActiveUnit.AbilityUse = new AbilityUse();
     Unit.ActiveUnit.AbilityUse.ExecuteNextStage();
 }
Exemplo n.º 28
0
 public AbilityActionInstance(AbilityAction actionTemplate, Character caster, List <Character> targets)
 {
     Template = actionTemplate;
     Caster   = caster;
     Targets  = targets;
 }
Exemplo n.º 29
0
 public void ChangeAction(AbilityAction action)
 {
     this.action = action;
 }