void RateFireLocation(PlanOfAttack poa, AttackOption option)
    {
        if (poa.ability != null)
        {
            AbilityRange range = poa.ability.GetComponent <AbilityRange>();
            List <Tile>  tiles = range.GetTilesInRange(owner.board);
            option.targets = tiles;
            for (int i = 0; i < tiles.Count; ++i)
            {
                Tile tile = tiles[i];
                if (!poa.ability.GetComponent <AbilityEffectTarget>().IsTarget(tile))
                {
                    continue;
                }

                bool isMatch = IsAbilityTargetMatch(poa, tile);
                if (isMatch && poa.ability.GetComponent <BaseAbilityEffect>() is HealAbilityEffect)
                {
                    if (tile.content.GetComponent <Health>().FullHP)
                    {
                        option.AddMark(tile, false);
                        option.AddMark(tile, false);
                    }
                    else
                    {
                        option.AddMark(tile, isMatch);
                    }
                }
                option.AddMark(tile, isMatch);
            }
        }
    }
예제 #2
0
 protected override void OnDeactivate()
 {
     Context.Inventory.Detach(this);
     Context.Inventory.Deactivate();
     AbilityRange.Dispose();
     Mode.Deactivate();
     Config?.Dispose();
 }
예제 #3
0
 public override void Enter()
 {
     base.Enter();
     unit = owner.currentUnit;
     ar   = unit.attackRange1;
     SelectTiles();
     //if (ar.directionOriented)
     //RefreshSecondaryStatPanel(pos);
 }
예제 #4
0
 public override void Enter()
 {
     base.Enter ();
     ar = turn.ability.GetComponent<AbilityRange> ();
     SelectTiles ();
     statPanelController.ShowPrimary (turn.actor.gameObject);
     if (ar.directionOriented)
         RefreshSecondaryStatPanel (pos);
 }
예제 #5
0
 public override void Enter()
 {
     base.Enter();
     ar = turn.ability.GetComponent <AbilityRange>();
     SelectTiles();
     statPanelController.ShowPrimary(turn.actor.gameObject);
     if (ar.directionOriented)
     {
         RefreshSecondaryStatPanel(pos);
     }
 }
예제 #6
0
    public override void Enter()
    {
        base.Enter();
        range = turn.ability.GetComponent <AbilityRange>();
        area  = turn.ability.GetComponent <AbilityArea>();
        SelectCells();
        statPanelController.ShowPrimary(turn.actor.gameObject);

        if (range.directionOriented)
        {
            RefreshSecondaryStatPanel(currentCell);
        }
    }
예제 #7
0
 void NextAr()
 {
     if (arNum == 1)
     {
         arNum = 2;
         ar    = unit.attackRange2;
     }
     else
     {
         arNum = 1;
         ar    = unit.attackRange1;
     }
 }
예제 #8
0
 public override void Enter()
 {
     base.Enter();
     ar = turn.ability.GetComponent <AbilityRange>();
     SelectTiles();
     statPanelController.ShowPrimary(turn.actor.gameObject);
     if (ar.directionOriented)
     {
         RefreshSecondaryStatPanel(pos);
     }
     if (driver.Current == Drivers.Computer)
     {
         StartCoroutine(ComputerHighlightTarget());
     }
 }
예제 #9
0
    // setup tiles to be target
    void FindTargets()
    {
        AbilityRange ar = turn.phaser.GetComponent <AbilityRange>();

        AbilityEffectTarget[] targeters = turn.phaser.GetComponents <AbilityEffectTarget>();

        if (ar is SelfAbilityRange)
        {
            if (IsTarget(turn.actor.tile, targeters))
            {
                owner.ChangeState <ConfirmAbilityTargetState>();
                return;
            }
            else
            {
                owner.ChangeState <CategorySelectionState>();                // the ability cannot use;
                return;
            }
        }

        else if (ar is InfiniteAbilityRange)
        {
            turn.targets = new List <Tile>();

            for (int i = 0; i < tiles.Count; ++i)
            {
                if (IsTarget(tiles[i], targeters))
                {
                    turn.targets.Add(tiles[i]);
                }
            }

            OnFire(null, new InfoEventArgs <int>(0));
        }
        else
        {
            turn.targets = new List <Tile>();

            for (int i = 0; i < tiles.Count; ++i)
            {
                if (IsTarget(tiles[i], targeters))
                {
                    turn.targets.Add(tiles[i]);
                }
            }
        }
    }
예제 #10
0
 public void ProjectileAb()
 {
     ar = (AbilityRange)FindObjectOfType <PlayerHandler>().Range;
     if (ar.RangeType == AbilityRange.RangeTypes.Bullet)
     {
         Bullet bullet = Instantiate(bulletPrefab, BulletFirepoint.position, BulletFirepoint.rotation).GetComponent <Bullet>();
         animator.SetBool("isProtection", true);
         bullet.PP.damage = ar.Power;
         bullet.PP.speed  = ar.speed;
         bullet.Setup();
     }
     else if (ar.RangeType == AbilityRange.RangeTypes.Fireball)
     {
         animator.SetBool("isFireBall", true);
     }
     else if (ar.RangeType == AbilityRange.RangeTypes.SmallBullet)
     {
     }
 }
예제 #11
0
        private void PlanDirectionIndependent(PlanOfAttack poa)
        {
            Tile         startTile    = actor.tile;
            var          map          = new Dictionary <Tile, AttackOption>();
            AbilityRange abilityRange = poa.ability.GetComponent <AbilityRange>();
            List <Tile>  moveOptions  = GetMoveOptions();

            // Loop on the move options (movement range).
            for (int i = 0; i < moveOptions.Count; ++i)
            {
                Tile moveTile = moveOptions[i];
                actor.Place(moveTile);
                List <Tile> fireOptions = abilityRange.GetTilesInRange(bc.board);

                // Loop on the fire options (ability range).
                for (int j = 0; j < fireOptions.Count; ++j)
                {
                    Tile         fireTile     = fireOptions[j];
                    AttackOption attackOption = null;
                    if (map.ContainsKey(fireTile))
                    {
                        attackOption = map[fireTile];
                    }
                    else
                    {
                        attackOption           = new AttackOption();
                        attackOption.target    = fireTile;
                        attackOption.direction = actor.dir;
                        map[fireTile]          = attackOption;
                        RateFireLocation(poa, attackOption);
                    }

                    attackOption.AddMoveTarget(moveTile);
                }
            }

            // Place the actor back to the initial tile. If we didn't do this, the
            // AI would be out of sync with the visuals.
            actor.Place(startTile);
            var list = new List <AttackOption>(map.Values);

            PickBestOption(poa, list);
        }
예제 #12
0
    public override void Enter()
    {
        base.Enter();


        ar = turn.phaser.GetComponent <AbilityRange>();
        //選取技能範圍
        SelectTiles();
        statPanelController.ShowPrimary(turn.actor.gameObject);



        if (ar.directionOriented)
        {
            RefreshSecondaryStatPanel(pos);
        }
        else
        {
            StartCoroutine(DirectToAreaSelection());
        }
    }
예제 #13
0
 public AbilityData(string guid, string name, string displayNameLocalizationKey, string displayNameText, string descriptionLocalizationKey, string descriptionText, string iconAssetGuid, string iconFileName,
                    AbilityType type, AbilityRange range, UnitCommand.CommandType actionType, bool isFullRoundAction, string durationLocalizationKey = null, string durationLocalizationText = null,
                    string savingThrowLocalizationKey = null, string savingThrowLocalizationText = null)
 {
     Guid = guid;
     Name = name;
     DisplayNameLocalizationKey = displayNameLocalizationKey;
     DisplayNameText            = displayNameText;
     DescriptionLocalizationKey = descriptionLocalizationKey;
     DescriptionText            = descriptionText;
     IconAssetGuid               = iconAssetGuid;
     IconFileName                = iconFileName;
     Type                        = type;
     Range                       = range;
     ActionType                  = actionType;
     IsFullRoundAction           = isFullRoundAction;
     DurationLocalizationKey     = durationLocalizationKey;
     DurationLocalizationText    = durationLocalizationText;
     SavingThrowLocalizationKey  = savingThrowLocalizationKey;
     SavingThrowLocalizationText = savingThrowLocalizationText;
 }
예제 #14
0
    void PlanDirectionIndependent(PlanOfAttack poa)
    {
        Tile startTile = actor.tile;
        Dictionary <Tile, AttackOption> map = new Dictionary <Tile, AttackOption>();
        AbilityRange ar          = poa.ability.GetComponent <AbilityRange>();
        List <Tile>  moveOptions = GetMoveOptions();

        for (int i = 0; i < moveOptions.Count; ++i)
        {
            Tile moveTile = moveOptions[i];
            actor.Place(moveTile);
            List <Tile> fireOptions = ar.GetTilesInRange(bc.board);

            for (int j = 0; j < fireOptions.Count; ++j)
            {
                Tile         fireTile = fireOptions[j];
                AttackOption ao       = null;
                if (map.ContainsKey(fireTile))
                {
                    ao = map[fireTile];
                }
                else
                {
                    ao            = new AttackOption();
                    map[fireTile] = ao;
                    ao.target     = fireTile;
                    ao.direction  = actor.dir;
                    RateFireLocation(poa, ao);
                }

                ao.AddMoveTarget(moveTile);
            }
        }

        actor.Place(startTile);
        List <AttackOption> list = new List <AttackOption>(map.Values);

        PickBestOption(poa, list);
    }
예제 #15
0
    public override List <Tile> getTilesInArea(Board board, Point pos)
    {
        AbilityRange ar = GetComponent <AbilityRange>();

        return(ar.getTilesInRange(board));
    }
예제 #16
0
    //when position matters, facing angle does not. Checks every possible move position and firing range to decide best use of ability
    bool IsDirectionIndependent(PlanOfAttack poa)
    {
        AbilityRange range = poa.ability.GetComponent <AbilityRange>();

        return(!range.directionOriented);
    }
예제 #17
0
    //check if position matters when using an ability. currently, will move at random if position is independent
    bool IsPositionIndependent(PlanOfAttack poa)
    {
        AbilityRange range = poa.ability.GetComponent <AbilityRange>();

        return(range.positionOriented == false);
    }
예제 #18
0
    public void display(GameObject obj)
    {
        bool levelDataFound = false;
        bool bonusFound     = false;

        string levelText = "";
        string bonusText = "";

        AbilityGeneralData generalData = obj.GetComponent <AbilityGeneralData>();

        if (generalData)
        {
            nameLabel.text        = generalData.abilityName;
            categoryLabel.text    = generalData.abilityCategoryText;
            descriptionLabel.text = generalData.abilityDescription;
        }

        AbilityCostData costData = obj.GetComponent <AbilityCostData>();

        if (costData)
        {
            int costPanels = 0;

            if (costData.abilityMentalCost == 0 && costData.abilityPhysicalCost == 0)
            {
                costPanel.SetActive(false);
            }
            else
            {
                costPanel.SetActive(true);
            }

            if (costData.abilityMentalCost > 0)
            {
                mentalCostPanel.SetActive(true);
                costPanels++;
            }
            else
            {
                mentalCostPanel.SetActive(false);
            }

            if (costData.abilityPhysicalCost > 0)
            {
                physicalCostPanel.SetActive(true);
                costPanels++;
            }
            else
            {
                physicalCostPanel.SetActive(false);
            }

            if (costPanels == 0)
            {
                costPanel.SetActive(false);
            }
            else
            {
                costPanel.SetActive(true);

                if (costPanels > 1)
                {
                    separatorPanel.SetActive(true);
                }
                else
                {
                    separatorPanel.SetActive(false);
                }
            }

            mentalCostLabel.text   = costData.abilityMentalCost.ToString();
            physicalCostLabel.text = costData.abilityPhysicalCost.ToString();
        }

        AbilityRange abilityRange = obj.GetComponent <AbilityRange>();

        if (abilityRange)
        {
            rangeTypeLabel.text = abilityRange.getAbilityRangeDescription();
        }

        AbilityArea abilityArea = obj.GetComponent <AbilityArea>();

        if (abilityArea)
        {
            areaTypeLabel.text = abilityArea.getAbilityAreaDescription();
        }

        for (int i = 0; i < obj.transform.childCount; ++i)
        {
            Transform child = obj.transform.GetChild(i);

            if (child.name == "Bonus")
            {
                string levelChildName;

                AbilityLevelData abilityLevelData = child.GetComponent <AbilityLevelData>();

                if (abilityLevelData != null)
                {
                    levelDataFound = true;
                    levelText      = "Nivel " + abilityLevelData.level.ToString();

                    levelChildName = "Level " + abilityLevelData.level;

                    for (int j = 0; j < child.transform.childCount; ++j)
                    {
                        Transform bonusChild = child.transform.GetChild(j);

                        if (bonusChild.name == levelChildName)
                        {
                            AbilityBonus[] abilityBonusList = bonusChild.GetComponents <AbilityBonus>();
                            foreach (AbilityBonus abilityBonus in abilityBonusList)
                            {
                                bonusFound = true;

                                if (bonusText != "")
                                {
                                    bonusText += "\n";
                                }
                                bonusText += abilityBonus.getAbilityBonusDescription();
                            }

                            break;
                        }
                    }
                }
            }

            foreach (Transform effectChild in effectsPanel.transform)
            {
                Destroy(effectChild.gameObject);
            }
            if (child.name == "Effects")
            {
                for (int j = 0; j < child.childCount; ++j)
                {
                    Transform childEffect = child.transform.GetChild(j);

                    GameObject effectPanelObject = Instantiate(effectPanelPrefab);
                    effectPanelObject.transform.SetParent(effectsPanel.transform);
                    effectPanelObject.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                    effectPanelObject.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                    EffectPanel effectPanel = effectPanelObject.GetComponent <EffectPanel>();

                    if (effectPanel)
                    {
                        AbilityPower abilityPower = childEffect.GetComponent <AbilityPower>();
                        if (abilityPower)
                        {
                            effectPanel.powerLabel.gameObject.SetActive(true);

                            effectPanel.powerLabel.text = abilityPower.getAbilityPower().ToString() + "%";
                        }
                        else
                        {
                            effectPanel.powerLabel.gameObject.SetActive(false);
                        }

                        AbilityHitRate abilityHitRate = childEffect.GetComponent <AbilityHitRate>();
                        if (abilityHitRate)
                        {
                            effectPanel.hitRateLabel.gameObject.SetActive(true);

                            effectPanel.hitRateLabel.text = abilityHitRate.getAbilityHitRateDescription();
                        }
                        else
                        {
                            effectPanel.hitRateLabel.gameObject.SetActive(false);
                        }
                    }
                }
            }
        }

        if (levelDataFound)
        {
            levelPanel.gameObject.SetActive(true);
            levelLabel.text = levelText;
        }
        else
        {
            levelPanel.gameObject.SetActive(false);
        }

        if (bonusFound)
        {
            CentralPanelSeparator.SetActive(true);
            bonusLabel.gameObject.SetActive(true);
            bonusLabel.text = bonusText;
        }
        else
        {
            CentralPanelSeparator.SetActive(false);
            bonusLabel.gameObject.SetActive(false);
            bonusLabel.text = "";
        }
    }
예제 #19
0
    public void Load(CardRecipe data)
    {
        AbilityManaCost abilityManaCost = GetComponent <AbilityManaCost>();

        if (abilityManaCost == null)
        {
            abilityManaCost = gameObject.AddComponent <AbilityManaCost>();
        }

        AbilityEffectTarget abilityEffectTarget = GetComponent <AbilityEffectTarget>();

        if (abilityEffectTarget != null)
        {
            DestroyImmediate(abilityEffectTarget, true);
        }

        BaseAbilityEffect abilityEffect = GetComponent <BaseAbilityEffect>();

        if (abilityEffect != null)
        {
            DestroyImmediate(abilityEffect, true);
        }

        BaseAbilityPower power = GetComponent <BaseAbilityPower>();

        if (power != null)
        {
            DestroyImmediate(power, true);
        }

        AbilityRange range = GetComponent <AbilityRange>();

        if (range != null)
        {
            DestroyImmediate(range, true);
        }

        if (data == null)
        {
            Name = "";
            Desc = "";
            abilityManaCost.amount = 0;
            abilityEffectTarget    = gameObject.AddComponent <DefaultAbilityEffectTarget>();
            abilityEffect          = gameObject.AddComponent <DamageAbilityEffect>();
            power            = gameObject.AddComponent <PhysicalAbilityPower>();
            power.Power      = 0;
            range            = gameObject.AddComponent <ConstantAbilityRange>();
            range.horizontal = 0;
            this.data        = Resources.Load("Recipes/CardRecipes/Empty Card Data") as CardRecipe;
            ID           = GetInstanceID();
            visualEffect = null;
            return;
        }
        Name = data.Name;
        Desc = data.Description;
        abilityManaCost.amount = data.AbilityManaCost;
        abilityEffectTarget    = gameObject.AddComponent(Type.GetType(data.AbilityEffectTarget)) as AbilityEffectTarget;

        if (data.AbilityEffect.Contains("InflictStatus"))
        {
            string ae     = "InflictStatusAbilityEffect";
            string status = string.Format("{0}StatusEffect", data.AbilityEffect.Substring(13, data.AbilityEffect.Length - 26));

            InflictStatusAbilityEffect effect = gameObject.AddComponent(Type.GetType(ae)) as InflictStatusAbilityEffect;
            effect.statusName = status;
            abilityEffect     = effect;
        }
        else
        {
            abilityEffect = gameObject.AddComponent(Type.GetType(data.AbilityEffect)) as BaseAbilityEffect;
        }

        power            = gameObject.AddComponent(Type.GetType(data.AbilityPower)) as BaseAbilityPower;
        power.Power      = data.BasePower;
        range            = gameObject.AddComponent(Type.GetType(data.AbilityRange)) as AbilityRange;
        range.horizontal = data.AbilityRangeHorizontal;
        this.data        = data;
        ID           = GetInstanceID();
        visualEffect = data.ParticleEffect;
    }