示例#1
0
    private void PopulateAbilityCategory(string categoryName, List <AbilityTemplate> abilities)
    {
        if (abilities.Count < 1)
        {
            return;
        }

        var categoryInstance = Instantiate(AbilityCategoryPrefab, AbilityCategoryPrefab.transform.position,
                                           Quaternion.identity);

        categoryInstance.transform.SetParent(AbilityCategoryParent);

        categoryInstance.GetComponentsInChildren <TextMeshProUGUI>()[1].text =
            $"{GlobalHelper.Capitalize(categoryName)}";

        var abilityParent = categoryInstance.GetComponentsInChildren <RectTransform>(true)[7];

        abilityParent.GetComponent <LayoutElement>().preferredHeight = 30 * abilities.Count;

        foreach (var ability in abilities)
        {
            if (ability.StartingAbility)
            {
                continue;
            }

            var instance = Instantiate(AvailableAbilityPrefab, StartingAbilityPrefab.transform.position,
                                       Quaternion.identity);

            instance.transform.SetParent(abilityParent);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[0].text =
                GlobalHelper.CapitalizeAllWords(ability.Name);
        }
    }
示例#2
0
    private void LoadStartingAbilitiesForSpecies(EntityTemplate species)
    {
        GlobalHelper.DestroyAllChildren(SpeciesStartingAbilityParent);

        var startingAbilities = new List <AbilityTemplate>();

        foreach (var bodyPartName in species.Parts)
        {
            var partAbilities = AbilityStore.GetAbilitiesByBodyPart(bodyPartName);

            if (partAbilities == null)
            {
                continue;
            }

            startingAbilities.AddRange(partAbilities);
        }

        foreach (var ability in startingAbilities)
        {
            var instance = Instantiate(StartingAbilityPrefab, StartingAbilityPrefab.transform.position,
                                       Quaternion.identity);

            instance.transform.SetParent(SpeciesStartingAbilityParent);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[0].text = GlobalHelper.CapitalizeAllWords(ability.Name);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[1].text = ability.Description;
        }
    }
示例#3
0
        public override void Use(Entity target)
        {
            var message = $"{AbilityOwner.Name} attacks {target.Name} with {GlobalHelper.CapitalizeAllWords(Name)}!";

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.SendMessageToConsole, this, message);

            eventMediator.SubscribeToEvent(GlobalHelper.TargetHit, this);

            AbilityOwner.MeleeAttackWithSlot(target, EquipLocation.Shield);

            AbilityOwner.SubtractActionPoints(ApCost);

            eventMediator.UnsubscribeFromEvent(GlobalHelper.TargetHit, this);
        }
示例#4
0
    private void LoadStartingAbilitiesForBackground(CharacterBackground background)
    {
        GlobalHelper.DestroyAllChildren(BackgroundStartingAbilityParent);

        var backgroundAbilities = AbilityStore.GetAbilitiesByBackground(background);

        foreach (var ability in backgroundAbilities)
        {
            var instance = Instantiate(StartingAbilityPrefab, StartingAbilityPrefab.transform.position,
                                       Quaternion.identity);

            instance.transform.SetParent(BackgroundStartingAbilityParent);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[0].text = GlobalHelper.CapitalizeAllWords(ability.Name);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[1].text = ability.Description;
        }
    }
    private void PopulateAllAbilities()
    {
        GlobalHelper.DestroyAllChildren(AbilityCategoryParent);

        var abilities = GameManager.Instance.Player.Abilities;

        foreach (var ability in abilities)
        {
            var abilityParent = AbilityCategoryParent;

            //abilityParent.GetComponent<LayoutElement>().preferredHeight = 30 * abilities.Count;

            var instance = Instantiate(AvailableAbilityPrefab, abilityParent.transform.position,
                                       Quaternion.identity);

            instance.transform.SetParent(abilityParent);

            instance.transform.GetComponentsInChildren <TextMeshProUGUI>()[0].text =
                GlobalHelper.CapitalizeAllWords(ability.Key);
        }
    }
示例#6
0
        public virtual void Use(Entity target)
        {
            //todo testing for prototype - assumes combat ability

            //todo message assumes combat ability
            var message = $"{AbilityOwner.Name} attacks {target.Name} with {GlobalHelper.CapitalizeAllWords(Name)}!";

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.SendMessageToConsole, this, message);

            if (Range < 2)
            {
                AbilityOwner.AttackWithAbility(target, this);
            }
            else
            {
                AbilityOwner.RangedAttack(target);
            }

            AbilityOwner.SubtractActionPoints(ApCost);
        }
示例#7
0
        public override void Use(Entity target)
        {
            var message = $"{AbilityOwner.Name} attacks {target.Name} with {GlobalHelper.CapitalizeAllWords(Name)}!";

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.SendMessageToConsole, this, message);

            var chargeDirection = Direction.GetDirection(AbilityOwner.Position, target.Position);

            var combatManager = Object.FindObjectOfType <CombatManager>();

            var map = combatManager.Map;

            var targetTile = map.GetTileAt(target.Position);

            Tile destination = null;

            switch (chargeDirection.Type)
            {
            case Direction.Types.UP:
                destination = targetTile.GetAdjacentTileByDirection(Direction.DOWN);
                break;

            case Direction.Types.UP_RIGHT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.DOWN_LEFT);
                break;

            case Direction.Types.RIGHT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.LEFT);
                break;

            case Direction.Types.DOWN_RIGHT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.UP_LEFT);
                break;

            case Direction.Types.DOWN:
                destination = targetTile.GetAdjacentTileByDirection(Direction.UP);
                break;

            case Direction.Types.DOWN_LEFT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.UP_RIGHT);
                break;

            case Direction.Types.LEFT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.RIGHT);
                break;

            case Direction.Types.UP_LEFT:
                destination = targetTile.GetAdjacentTileByDirection(Direction.DOWN_RIGHT);
                break;

            case Direction.Types.NONE:
                Debug.LogError("No direction for Helmet Charge!");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            AbilityOwner.MoveTo(destination, 0); //todo might look goofy with default walk animation

            AbilityOwner.MeleeAttack(target);

            AbilityOwner.SubtractActionPoints(ApCost);
        }