Пример #1
0
 protected override void setParameter()
 {
     observeSkill = HealSkillMasterManager.getInstance().getHealSkillFromId(OBSERVE_SKILL_ID);
     this.heal    = observeSkill.getRawHeal();
     this.cost    = observeSkill.getRawCost();
     this.delay   = observeSkill.getRawDelay();
 }
Пример #2
0
 //clickNumber: some skills need to be used more than once [for instance 'smokeTeleport']
 public void performSkill(Character character, int skill, Vector3 mousePos, Character targetCharacter)
 {
     if (skill == Constants.bomb)
     {
         GameObject newBomb = Instantiate(bombPrefab, character.transform.position, Quaternion.identity) as GameObject;
         newBomb.transform.parent = character.transform;
         BombSkill bomb = newBomb.GetComponent <BombSkill>();
         bomb.setParameters(character, mousePos);
         bomb.startSkill();
     }
     else if (skill == Constants.smokeTeleport)
     {
         SmokeTeleport smoke = character.GetComponentInChildren <SmokeTeleport>();
         if (smoke == null)
         {
             GameObject newSmoke = Instantiate(smokePrefab, character.transform.position, Quaternion.identity) as GameObject;
             newSmoke.transform.parent = character.transform;
             smoke = newSmoke.GetComponent <SmokeTeleport>();
             smoke.setParameters(character, mousePos);
             smoke.startSkill();
         }
         else
         {
             smoke.setParameters(character, mousePos);
             smoke.secondCast();
         }
     }
     else if (skill == Constants.magicMirror)
     {
         GameObject newMagicMirror = Instantiate(magicMirrorPrefab, character.transform.position, Quaternion.identity) as GameObject;
         newMagicMirror.transform.parent = character.transform;
         MagicMirror mm = newMagicMirror.GetComponent <MagicMirror>();
         mm.setParameters(character);
         mm.startSkill();
     }
     else if (skill == Constants.earthquake)
     {
         GameObject newEarthquake = Instantiate(earthquakePrefab, character.transform.position, Quaternion.identity) as GameObject;
         newEarthquake.transform.parent = character.transform;
         EarthquakeSkill earthquake = newEarthquake.GetComponent <EarthquakeSkill>();
         earthquake.setParameters(character, mousePos);
         earthquake.startSkill();
     }
     else if (skill == Constants.heal)
     {
         GameObject newHeal = Instantiate(healPrefab, character.transform.position, Quaternion.identity) as GameObject;
         newHeal.transform.parent = character.transform;
         HealSkill heal = newHeal.GetComponent <HealSkill>();
         heal.setParameters(character, targetCharacter);
         heal.startSkill();
     }
     else if (skill == Constants.fireball)
     {
         GameObject newFireball = Instantiate(fireballPrefab, character.transform.position, Quaternion.identity) as GameObject;
         newFireball.transform.parent = character.transform;
         FireballSkill fireball = newFireball.GetComponent <FireballSkill>();
         fireball.setParameters(character, mousePos);
         fireball.startSkill();
     }
 }
    void LoadSkills()
    {
        for (int i = 0; i < skills.Length; i++)
        {
            skills[i] = new HealSkill();
        }

        skills[1] = new DefaultAttack();
    }
Пример #4
0
    void DoHealHeuristic(List <Node> nodesWithUnits, HealSkill hs, Unit aiUnit)
    {
        foreach (Node nodeWithUnit in nodesWithUnits)
        {
            // Only accept units that are the same allegiance to heal
            if (nodeWithUnit.unit?.GetAllegiance() == aiUnit.GetAllegiance())
            {
                Unit currentUnit = nodeWithUnit.unit;

                // Skip if at full health
                if (currentUnit.GetCurrentHealth() == currentUnit.GetStartingHealth())
                {
                    continue;
                }

                if (currentUnit == aiUnit)
                {
                    // Edge case when healing self. Don't move;
                    Node castNode = nodeWithUnit;
                    // Calculate the value for the node's heal heuristic.
                    float newHealH = hs.m_HealAmount + (currentUnit.GetStartingHealth() - currentUnit.GetCurrentHealth()) * aiUnit.GetHeuristicCalculator().m_HealWeighting;

                    if (castNode != null)
                    {
                        AddOrUpdateHeuristic(
                            newHealH,
                            castNode,
                            aiUnit,
                            new HealSkillTarget(hs, nodeWithUnit));
                    }
                }
                else
                {
                    // Get nodes in the area that the AI unit could heal friendly units from.
                    List <Node> nodesCastable = Grid.m_Instance.GetNodesWithinRadius(hs.m_CastableDistance, nodeWithUnit);

                    // Go through each of the nodes the AI unit could heal from and add the heal heuristic to them.
                    for (int j = 0; j < nodesCastable.Count; j++)
                    {
                        Node castNode = nodesCastable[j];

                        // Calculate the value for the node's heal heuristic.
                        float newHealH = hs.m_HealAmount + (currentUnit.GetStartingHealth() - currentUnit.GetCurrentHealth()) * aiUnit.GetHeuristicCalculator().m_HealWeighting;

                        if (castNode != null)
                        {
                            AddOrUpdateHeuristic(
                                newHealH,
                                castNode,
                                aiUnit,
                                new HealSkillTarget(hs, nodeWithUnit));
                        }
                    }
                }
            }
        }
    }
Пример #5
0
        protected override void addInstance(string[] datas)
        {
            var skill = new HealSkill(datas);

            dataTable.Add(skill);

            SkillBookDataManager.getInstance().setData(skill);
            progressTable.Add(int.Parse(datas[0]), new ActiveSkillProgress());
        }
    /// <summary>
    /// Select a skill.
    /// </summary>
    /// <param name="skill"> The skill being selected. </param>
    public void SkillSelection(BaseSkill skill, SkillButton button)
    {
        if (ParticlesManager.m_Instance.m_ActiveSkill != null)        // || (ParticlesManager.m_Instance.m_ActiveSkill.m_Skill != null && ParticlesManager.m_Instance.m_ActiveSkill.m_Targets != null))
        {
            Debug.LogWarning($"<color=#9c4141>[Skill]</color> {ParticlesManager.m_Instance.m_ActiveSkill.m_Skill.m_SkillName} is currently active!");
            return;
        }
        // Don't allow progress if the character is an enemy (player can mouse over for info, but not use the skill)
        if (m_SelectedUnit.GetAllegiance() == Allegiance.Enemy)
        {
            return;
        }

        // Make sure the player has a unit selected.
        if (m_SelectedUnit != null)
        {
            // Check if the skill being cast is the heal skill.
            HealSkill hs = skill as HealSkill;
            if (hs != null)
            {
                // Check if this unit has Pestilence's passive (should be Pestilence but you never know).
                PestilencePassive pesPassive = m_SelectedUnit.GetPassiveSkill() as PestilencePassive;
                if (pesPassive != null)
                {
                    // If there is no heal resource remaining, output warning about it and leave function.
                    if (pesPassive.GetHealResource() < pesPassive.m_HealResourceCastCost)
                    {
                        Debug.LogWarning("Not enough heal resource for Pestilence to heal with.");
                        return;
                    }
                }
            }

            // Make sure the unit can afford to cast the skill and the skill isn't on cooldown before selecting it.
            // Just in case.
            if (m_SelectedUnit.GetActionPoints() >= skill.m_Cost && skill.GetCurrentCooldown() == 0)
            {
                foreach (SkillButton b in UIManager.m_Instance.m_SkillSlots)
                {
                    b.m_LightningImage.materialForRendering.SetFloat("_UIVerticalPan", 0);
                }
                button.m_LightningImage.materialForRendering.SetFloat("_UIVerticalPan", 1);

                // Update the GameManager's fields
                m_SelectedSkill  = skill;
                m_TargetingState = TargetingState.Skill;

                // Get the new affectable area.
                m_maxSkillRange = Grid.m_Instance.GetNodesWithinRadius(m_SelectedSkill.m_CastableDistance + m_SelectedSkill.m_AffectedRange, Grid.m_Instance.GetNode(m_SelectedUnit.transform.position), true);

                UpdateSkillPreview(null);
            }
        }
    }
Пример #7
0
    protected override void Awake()
    {
        base.Awake();
        hp = GetComponent <HeartHealthContainer> ();
        hp.transform.parent = transform;
        hp.SetMaxHealth(3);
        rope           = null;
        attackCollider = transform.Find("AttackCollider").gameObject;
        interactor     = GetComponent <Interactor>();
        commander      = GetComponent <PlayerCommander>();
        ropeController = GetComponent <RopeController>();

        skill               = new HeroSkill[3];
        skill[0]            = new HealSkill();
        skill[1]            = new HealSkill();
        skill[2]            = new HealSkill();
        directionalDeadZone = 0.40f;
    }
Пример #8
0
    public override void Activate(MonsterCharacter character, int index)
    {
        if (character.SkillCooldowns[index] > 0)
        {
            Sounds.CreateSound(FailSound);
            return;
        }

        if (character.ChargePoints < ChargeCost)
        {
            Messaging.GUI.ScreenMessage.Invoke("NOT ENOUGH CHARGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        if (character.SoftDamage <= 0)
        {
            Messaging.GUI.ScreenMessage.Invoke("NO ACCUMULATED DAMAGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        int HealPerTick = (int)(character.SoftDamage * Portion / ActiveTime / 50);

        if (HealPerTick <= 0)
        {
            Messaging.GUI.ScreenMessage.Invoke("NOT ENOUGH ACCUMULATED DAMAGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        Sounds.CreateSound(ActivationSound);

        HealSkill s = Instantiate(this, character.transform);

        s.targetCharacter = character;
        s.healPerTick     = HealPerTick;

        character.ChargePoints         -= ChargeCost;
        character.SoftDamage            = 0;
        character.SkillCooldowns[index] = ActiveTime;
    }
Пример #9
0
        /// <summary>
        /// スキル効果範囲(Extent)がSINGLEの場合の対象を決定します
        /// </summary>
        /// <returns>対象のリスト</returns>
        /// <param name="useSkill">使用するスキル</param>
        private IBattleable decideHealSingleTarget(HealSkill useSkill)
        {
            //keyに可能性値、要素に対象をもつdictionary
            Dictionary <float, IBattleable> characterAndProbalities = new Dictionary <float, IBattleable>();
            float sumProbality = 0;

            List <IBattleable> targets = BattleManager.getInstance().getCharacterInRange(user, useSkill.getRange());

            foreach (IBattleable target in targets)
            {
                //敵対勢力→論外
                if (!target.isHostility(user.getFaction()))
                {
                    //HPの減った割合が可能性値
                    float probality = 1 - ((float)target.getHp() / (float)target.getMaxHp());
                    probality = (probality <= 0) ? 0.001f : probality;
                    characterAndProbalities.Add(probality, target);
                    sumProbality += probality;
                }
            }

            //乱数判定
            float rand        = UnityEngine.Random.Range(0, sumProbality);
            var   probalities = characterAndProbalities.Keys;

            foreach (float probality in probalities)
            {
                if (probality >= rand)
                {
                    return(characterAndProbalities[probality]);
                }
                else
                {
                    rand -= probality;
                }
            }
            throw new InvalidOperationException("cannot decideHealTarget");
        }
Пример #10
0
        private FieldPosition decideAreaHealTarget(HealSkill useSkill)
        {
            //keyのposにいる友好的なキャラクターのリスト
            Dictionary <FieldPosition, List <IBattleable> > posCharacters = new Dictionary <FieldPosition, List <IBattleable> >();
            //keyのposの可能性値
            Dictionary <FieldPosition, float> posProbalities = new Dictionary <FieldPosition, float>();
            //可能性値の合計
            int fieldPosMax = Enum.GetNames(typeof(FieldPosition)).Length;
            //現在のpos
            FieldPosition nowPos = BattleManager.getInstance().searchCharacter(user);

            //ループ変数の設定
            int index = BattleManager.getInstance().restructionPositionValue(nowPos, -1 * useSkill.getRange());

            int maxIndex = BattleManager.getInstance().restructionPositionValue(nowPos, useSkill.getRange());

            //2つのdictionaryの設定
            float probalitySum = 0;

            for (; index < maxIndex; index++)
            {
                //範囲にいるキャラクターの取得
                var   targets          = BattleManager.getInstance().getAreaCharacter((FieldPosition)index);
                float areaProbalitySum = 0;

                //リストの初期化
                posCharacters.Add((FieldPosition)index, new List <IBattleable>());
                int hpSum    = 0;
                int maxHpSum = 0;
                //友好的なキャラクターを検索してdictionaryに追加
                foreach (IBattleable target in targets)
                {
                    if (!target.isHostility(user.getFaction()))
                    {
                        hpSum    += target.getHp();
                        maxHpSum += target.getMaxHp();
                        posCharacters[(FieldPosition)index].Add(target);
                    }
                }
                //HPが減っている割合を計算→可能性値にする
                areaProbalitySum = 1 - ((float)hpSum / (float)maxHpSum);
                posProbalities.Add((FieldPosition)index, areaProbalitySum);
                probalitySum += areaProbalitySum;
            }

            //乱数判定
            float rand  = UnityEngine.Random.Range(0, probalitySum);
            var   poses = posCharacters.Keys;

            foreach (FieldPosition pos in poses)
            {
                if (posProbalities[pos] > rand)
                {
                    return(pos);
                }
                else
                {
                    rand += posProbalities[pos];
                }
            }

            throw new InvalidOperationException("cannot decide HealAreaCharacter");
        }
Пример #11
0
 public HealSkillTarget(HealSkill healSkill, Node node)
 {
     m_Skill      = healSkill;
     m_TargetNode = node;
 }
Пример #12
0
    /// <summary>
    /// Activate one of the unit's skills.
    /// </summary>
    /// <param name="skill"> The skill to activate. </param>
    public void ActivateSkill(BaseSkill skill, Node castLocation)
    {
        Debug.Log($"<color=#9c4141>[Skill] </color>{PlayerManager.m_Instance.GetSelectedUnit().name} casts {skill.m_SkillName}" +
                  $" {(castLocation.unit ? $"at {castLocation.unit.name}" : "")} ({castLocation.m_NodeHighlight.name})");
        // Doing my own search cause List.Find is gross.
        for (int i = 0; i < m_Skills.Count; ++i)
        {
            // Check if the unit has the skill being cast.
            if (m_Skills[i].m_SkillName == skill.m_SkillName)
            {
                skill.m_AffectedNodes = Grid.m_Instance.GetNodesWithinRadius(m_Skills[i].m_AffectedRange, castLocation, true);
                skill.m_CastNode      = castLocation;
                if (m_PassiveSkill != null)
                {
                    DamageSkill ds = skill as DamageSkill;

                    // Check if skill being cast is a damage skill.
                    if (ds != null)
                    {
                        // Make sure the skill knows what units it will affect, so we can check them for the passive.
                        List <Unit> hitUnits = ds.FindAffectedUnits();

                        if (m_PassiveSkill.GetAffectSelf() == false)
                        {
                            // Check which units meet the prerequisits for the unit's passive.
                            foreach (Unit u in hitUnits)
                            {
                                foreach (InflictableStatus status in m_StatusEffects)
                                {
                                    if (status.CheckPrecondition(TriggerType.OnDealDamage) == true)
                                    {
                                        status.TakeEffect(this);
                                    }
                                }

                                // Add extra damage to the skill from status effect (if there is any).
                                if (m_DealExtraDamage > 0)
                                {
                                    ds.AddExtraDamage(m_DealExtraDamage);
                                }

                                if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage, u))
                                {
                                    m_PassiveSkill.TakeEffect(u);
                                }
                                if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage))
                                {
                                    m_PassiveSkill.TakeEffect();
                                }
                            }
                        }
                        else
                        {
                            if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage, this))
                            {
                                m_PassiveSkill.TakeEffect(this);
                            }
                            if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage))
                            {
                                m_PassiveSkill.TakeEffect(this);
                            }
                        }
                    }
                    HealSkill hs = skill as HealSkill;
                    if (hs != null)
                    {
                        PestilencePassive pp = m_PassiveSkill as PestilencePassive;
                        if (pp != null)
                        {
                            pp.UseHealResource();
                            StatusEffectTooltipManager.m_Instance.UpdatePassive();
                        }
                    }
                }
                if (skill.m_IsMagic)
                {
                    // TODO Play cast system
                }
                skill.CastSkill();
                transform.LookAt(castLocation.worldPosition);

                // Play skill animation
                m_animator.SetTrigger("TriggerSkill");

                // Play the damage sound effect.
                //FMODUnity.RuntimeManager.PlayOneShot(m_Skills[i].m_CastEvent, transform.position);
                return;
            }
        }

        Debug.LogError("Skill " + skill.m_SkillName + " couldn't be found in " + gameObject.name + ".");
    }