示例#1
0
    public static Entity CreateShield(this Pool pool, Entity owner)
    {
        var e = pool.CreateEntity()
                .AddShield(owner)
                .AddHealth(10000)
                .AddImmortal(Time.time + 9999f)
                .IsFriendly(owner.isFriendly)
                .IsNotFriendly(owner.isNotFriendly)
                .AddResource("Shield");

        return(e.AddCoroutine(ShieldHelper.GetCoroutine(e)));
    }
    public void executeSkill(SkillBase skillBase, int skillbarIndex)
    {
        string skillName = skillBase.name;

        // check if skill is off cooldown
        if (skillCooldowns.ContainsKey(skillName) && skillCooldowns[skillName] > 0f)
        {
            Debug.Log(skillBase.name + " is not off cooldown yet.");
            return;
        }

        // check if we have the mana for this skill
        if (!ManaHelper.HasEnoughMana(skillBase.manaCost))
        {
            Debug.Log("Not enough mana to cast " + skillBase.name);
            return;
        }

        if (skillName == SkillNames.CANNON)
        {
            // fetch the target position
            Vector3 target         = GetComponent <TargetingModeController> ().GetGroundTargetPosition();
            bool    successfulShot = ShootCannonball(target);

            if (successfulShot)
            {
                StartSkillCooldown(skillName, skillBase.cooldown, skillbarIndex);
            }
        }
        else if (skillName == SkillNames.MYSTIC_BULWARK)
        {
            ManaHelper.SpendMana(skillBase.manaCost);
            StartSkillCooldown(skillName, skillBase.cooldown, skillbarIndex);

            ShieldHelper.SetShield(skillBase.shield);
        }
    }