Example #1
0
    //解析技能行为
    private AbilityInput CreateAbilityInput(Ability ability)
    {
        // 非指向性技能,妲己一技能
        AbilityBehavior abilityBehavior = ability.GetAbilityBehavior();

        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_NO_TARGET) != 0)
        {
            return(CreateAbilityNoTargetInput(abilityBehavior));
        }

        // 指向性技能:妲己二技能
        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_UNIT_TARGET) != 0)
        {
            return(CreateAbilityTargetInput(abilityBehavior));
        }

        // 点施法类型,王昭君大招
        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_POINT) != 0)
        {
            return(CreateAbilityPointInput(abilityBehavior));
        }

        BattleLog.LogError("技能[%s]中有未定义的Input类型", ability.GetConfigName());
        return(null);
    }
Example #2
0
        private void AddNewAbility(GameObject abilityPrefab)
        {
            AbilityBehavior abilityBehavior = abilityPrefab ? abilityPrefab.GetComponent <AbilityBehavior>() : null;
            Ability         ability         = abilityBehavior ? abilityBehavior.ability : null;

            if (ability != null)
            {
                int ID = GenerateNewID();
                abilityIDList.Add(ID);
                ability.ID = ID;
                if (abilityPrefab)
                {
                    ability.prefab           = abilityPrefab;
                    ability.useDefaultEffect = false;
                }

                if (string.IsNullOrEmpty(ability.name.Trim()))
                {
                    ability.name = "Ability " + ID;
                }
                abilityList.Add(ability);
                SelectAbility(abilityList.Count - 1);
                abilityBehavior.ability = ability;
                EditorUtility.SetDirty(abilityBehavior);
                GUI.changed = true;
                //if (newSelectID != -1) SelectTower(newSelectID);
            }
        }
Example #3
0
    public override bool IsTrue(TBTWorkingData wData)
    {
        BattleBehaviorWorkingData behaviorData = wData as BattleBehaviorWorkingData;
        BattleUnit             source          = behaviorData.owner;
        AutoCastAbilityRequest request         = behaviorData.request as AutoCastAbilityRequest;
        Unit    target  = request.target;
        Ability ability = request.ability;

        //目标是自己,不用转身
        if (target == source)
        {
            return(false);
        }

        AbilityBehavior abilityBehavior = ability.GetAbilityBehavior();

        //无目标技能类型
        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_NO_TARGET) != 0)
        {
            //如果是线性或者扇形,虽然是无目标类型,也需要转向目标
            if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_DIRECTIONAL) != 0 ||
                (abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_SECTOR_AOE) != 0)
            {
                return(true);
            }

            return(false);
        }
        return(true);
    }
Example #4
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();
            AbilityBehavior abilityHolder = (AbilityBehavior)target;
            Ability         ability       = abilityHolder.ability;

            if (ability == null)
            {
                return;
            }

            if (GUILayout.Button("Show In Editor"))
            {
                AbilityEditorWindow.Init();
                AbilityEditorWindow.window.Select(ability.name, abilityHolder.gameObject);
            }

            //EditorGUI.BeginChangeCheck();


            //ability.name = EditorGUILayout.TextField("Name:", ability.name);

            //if(EditorGUI.EndChangeCheck())
            //{
            //    EditorUtility.SetDirty(abilityHolder);
            //    AbilityEditorWindow.Init();
            //}

            //base.OnInspectorGUI();
        }
Example #5
0
        public string GetAbilityBehavior(bool ForFile)
        {
            string DOTA_ABILITY_BEHAVIOR   = "";
            string AbilityBehaviorForFiles = "";

            if (AbilityBehavior.Contains("NoTarget"))
            {
                DOTA_ABILITY_BEHAVIOR    = "DOTA_ABILITY_BEHAVIOR_NO_TARGET";
                AbilityBehaviorForFiles += "notarget";
            }
            else if (AbilityBehavior.Contains("TargetSystem"))
            {
                DOTA_ABILITY_BEHAVIOR    = "DOTA_ABILITY_BEHAVIOR_NO_TARGET";
                AbilityBehaviorForFiles += "targetsystem";
            }
            else if (AbilityBehavior.Contains("Point"))
            {
                DOTA_ABILITY_BEHAVIOR    = "DOTA_ABILITY_BEHAVIOR_POINT";
                AbilityBehaviorForFiles += "point";
            }
            else if (AbilityBehavior.Contains("Targeted"))
            {
                DOTA_ABILITY_BEHAVIOR    = "DOTA_ABILITY_BEHAVIOR_UNIT_TARGET";
                AbilityBehaviorForFiles += "targeted";
            }

            if (AbilityBehavior.Contains("Instant"))
            {
                //DOTA_ABILITY_BEHAVIOR += " | DOTA_ABILITY_BEHAVIOR_DONT_CANCEL_MOVEMENT";
                AbilityBehaviorForFiles += "_instant";
            }
            if (AbilityBehavior.Contains("Channeled"))
            {
                DOTA_ABILITY_BEHAVIOR   += " | DOTA_ABILITY_BEHAVIOR_CHANNELLED";
                AbilityBehaviorForFiles += "_channeled";
            }

            if (AbilityBehavior.Contains("AOE"))
            {
                DOTA_ABILITY_BEHAVIOR += " | DOTA_ABILITY_BEHAVIOR_AOE";
                //AbilityBehaviorForFiles += "_aoe";
            }

            if (AbilityBehavior.Contains("Toggle"))
            {
                DOTA_ABILITY_BEHAVIOR += " | DOTA_ABILITY_BEHAVIOR_TOGGLE";
                //AbilityBehaviorForFiles += "_aoe";
            }


            if (ForFile)
            {
                return(AbilityBehaviorForFiles);
            }

            return(DOTA_ABILITY_BEHAVIOR);
        }
Example #6
0
        private string Point()
        {
            string Return = "";

            if (AbilityBehavior.Contains("Point"))
            {
                Return += "\n	local point			= self:GetCursorPosition()";
            }

            return(Return);
        }
Example #7
0
    void Awake()
    {
        particles = GetComponentsInChildren <ParticleSystem>();

        AbilityBehavior ab = GetComponent <AbilityBehavior>();

        if (ab && ab.ability.effect.duration > .1f)
        {
            duration = ab.ability.effect.duration;
        }
    }
Example #8
0
        /// <summary>
        ///     Checks if given ability has given ability behaviour flag
        /// </summary>
        /// <param name="ability"></param>
        /// <param name="flag"></param>
        /// <param name="abilityName"></param>
        /// <returns></returns>
        public static bool IsAbilityBehavior(this Ability ability, AbilityBehavior flag, string abilityName = null)
        {
            var             name = abilityName ?? ability.Name;
            AbilityBehavior data;

            if (AbilityBehaviorDictionary.TryGetValue(name, out data))
            {
                return(data.HasFlag(flag));
            }
            data = ability.AbilityBehavior;
            AbilityBehaviorDictionary.Add(name, data);
            return(data.HasFlag(flag));
        }
Example #9
0
    private void Start()
    {
        _linecastCache     = new RaycastHit2D[1];
        _healthUI.maxValue = _healthUI.value = HitPoints;
        _animator          = GetComponent <Animator>();
        _ability           = GetComponent <AbilityBehavior>();

        Debug.Assert(_animator != null, "Animator not found");
        Debug.Assert(_ability != null, "Ability not found");
        Debug.Assert(_unitBody != null, "UnitBody is null");
        Debug.Assert(_healthUI != null, "HealthUI is null");
        Debug.Assert(_healthText != null, "HealthText is null");
        Debug.Assert(_obstacleLayerMask != 0, "ObstacleLayerMask is not set");
    }
Example #10
0
        private string GetAOERadius()
        {
            string Return = "";

            if (AbilityBehavior.Contains("AOE"))
            {
                Return += "\n";
                Return += "\nfunction " + CodeName + ":GetAOERadius()";
                Return += "\n	return self:GetSpecialValueFor( \"AoERadius\" )";
                Return += "\nend";
            }

            return(Return);
        }
Example #11
0
        public static AbilityBehavior GetAbility(string label, AbilityBehavior Ab_holder)
        {
            GameObject go = (GameObject)EditorGUILayout.ObjectField(label, Ab_holder == null ? null : Ab_holder.gameObject, typeof(GameObject));

            if (go)
            {
                AbilityBehavior holder = go.GetComponent <AbilityBehavior>();
                if (holder)
                {
                    Ab_holder = holder;
                    return(Ab_holder);
                }
            }

            return(null);
        }
Example #12
0
        public static AbilityBehavior GetAbility(AbilityBehavior Ab_holder, float startX, float startY)
        {
            GameObject go = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 60, startY, Ab_holder ? 80 : 200, height), Ab_holder == null ? null : Ab_holder.gameObject, typeof(GameObject));

            if (go)
            {
                AbilityBehavior holder = go.GetComponent <AbilityBehavior>();
                if (holder)
                {
                    Ab_holder = holder;
                    return(Ab_holder);
                }
            }

            return(null);
        }
Example #13
0
        private string GetVictims()
        {
            string Return = "";

            if (AbilityBehavior.Contains("AOE"))
            {
                Return += "\n	-- DOTA_UNIT_TARGET_TEAM_FRIENDLY; DOTA_UNIT_TARGET_TEAM_ENEMY; DOTA_UNIT_TARGET_TEAM_BOTH";
                Return += "\n	local units	= FindUnitsInRadius(team, point, nil, AoERadius, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_NONE, FIND_ANY_ORDER, false)";
            }
            else if (AoERadius != "" && AoERadius != "-")
            {
                Return += "\n	-- DOTA_UNIT_TARGET_TEAM_FRIENDLY; DOTA_UNIT_TARGET_TEAM_ENEMY; DOTA_UNIT_TARGET_TEAM_BOTH";
                Return += "\n	local units	= FindUnitsInRadius(team, caster_loc, nil, AoERadius, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_NONE, FIND_ANY_ORDER, false)";
            }

            return(Return);
        }
Example #14
0
    // 指向性技能输入:妲己二技能
    private AbilityInput CreateAbilityTargetInput(AbilityBehavior abilityBehavior)
    {
        var abilityInput = new AbilityInputPoint(m_casterTransform, ability);
        var trans        = GetIndicatorAsset(AbilityIndicatorType.RANGE_AREA);
        AbilityIndicatorRange abilityIndicatorRange = new AbilityIndicatorRange(trans, m_casterTransform, ability.GetCastRange());

        trans = GetIndicatorAsset(AbilityIndicatorType.SEGMENT);
        AbilityIndicatorSegment abilityIndicatorSegment = new AbilityIndicatorSegment(trans, m_casterTransform);
        var radius = ability.GetAbilityAOERadius();

        trans = GetIndicatorAsset(AbilityIndicatorType.SEGMENT_AREA);
        AbilityIndicatorPoint abilityIndicatorPoint = new AbilityIndicatorPoint(trans, m_casterTransform, radius);

        abilityInput.AddAbilityIndicator(abilityIndicatorRange);
        abilityInput.AddAbilityIndicator(abilityIndicatorSegment);
        abilityInput.AddAbilityIndicator(abilityIndicatorPoint);
        return(abilityInput);
    }
Example #15
0
    /// <summary>
    /// 解析技能行为数组
    /// </summary>
    private static AbilityBehavior ParseAbilityBehaviorArray(JsonData json, string key)
    {
        var behaviorConfigs = GetJsonValue(json, key);

        if (behaviorConfigs == null)
        {
            return(0);
        }
        AbilityBehavior behavior = 0;

        if (behaviorConfigs.IsArray)
        {
            for (int i = 0; i < behaviorConfigs.Count; i++)
            {
                string item            = behaviorConfigs[i].ToString();
                var    abilityBehavior = GetEnumValue <AbilityBehavior>(item);
                behavior |= abilityBehavior;
            }
        }
        return(behavior);
    }
Example #16
0
        private string CheckDistanceToTarget()
        {
            string Return = "";

            if (AbilityBehavior.Contains("TargetSystem") && AbilityCastRange != "" && AbilityCastRange != "-")
            {
                Return += "\n	local AbilityCastRange = self:GetSpecialValueFor(\"AbilityCastRange\")";
                Return += "\n";
                Return += "\n	-- Check Range --";
                Return += "\n	local timer1 = Timers:CreateTimer(0, function()";
                Return += "\n		local result = CheckDistanceToTarget(playerID, player, caster, AbilityCastRange,  \""+ CodeName + "\")";
                Return += "\n		if result then return 0.02";
                Return += "\n		else caster:Stop() return false end";
                Return += "\n	end)";
                Return += "\n	Timers:CreateTimer(self:GetCastPoint()-0.05, function()";
                Return += "\n		Timers:RemoveTimer(timer1)";
                Return += "\n	end)";
            }

            return(Return);
        }
Example #17
0
        private string Target()
        {
            string Return = "";

            if (AbilityBehavior.Contains("NoTarget"))
            {
                Return += "\n	local victim		= caster";
                Return += "\n	local victim_loc	= victim:GetAbsOrigin()";
            }
            else if (AbilityBehavior.Contains("Targeted"))
            {
                Return += "\n	local victim		= self:GetCursorTarget()";
                Return += "\n	local victim_loc	= victim:GetAbsOrigin()";
            }
            else if (AbilityBehavior.Contains("TargetSystem"))
            {
                Return += "\n	local victim		= GameRules.PLAYER_HEROES_TARGET[playerID+1]";
                Return += "\n	local victim_loc	= victim:GetAbsOrigin()";
            }

            return(Return);
        }
Example #18
0
    // 点施法类型,王昭君大招
    private AbilityInput CreateAbilityPointInput(AbilityBehavior abilityBehavior)
    {
        var abilityInput = new AbilityInputPoint(m_casterTransform, ability);

        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_RADIUS_AOE) != 0)
        {
            var radius = ability.GetAbilityAOERadius();
            var trans  = GetIndicatorAsset(AbilityIndicatorType.RANGE_AREA);
            AbilityIndicatorRange abilityIndicatorRange = new AbilityIndicatorRange(trans, m_casterTransform, ability.GetCastRange());
            trans = GetIndicatorAsset(AbilityIndicatorType.CIRCLE_AREA);
            AbilityIndicatorPoint abilityIndicatorPoint = new AbilityIndicatorPoint(trans, m_casterTransform, radius);

            abilityInput.AddAbilityIndicator(abilityIndicatorRange);
            abilityInput.AddAbilityIndicator(abilityIndicatorPoint);
        }
        else
        {
            BattleLog.LogError("技能[{0}]中有未定义的Point类型技能区域", ability.GetConfigName());
        }

        return(abilityInput);
    }
Example #19
0
        public void SetSpecialAbility()
        {
            switch (number)
            {
            case 1:
                abilityBehavior = new OneAttackAbility();
                break;

            case 2:
                abilityBehavior = new TwoAttackAbility();
                break;

            case 7:
                abilityBehavior = new ChangePatternAbility();
                break;

            case 11:
                abilityBehavior = new OneMoreTimeAbility();
                break;

            case 12:
                abilityBehavior = new ReverseAbility();
                break;

            case 13:
                abilityBehavior = new JumpAbility();
                break;

            default:
                abilityBehavior = new NoAbility();
                break;
            }

            if (pattern == Pattern.Joker)
            {
                abilityBehavior = new JokerAttackAbility();
            }
        }
Example #20
0
    // 非指向性技能输入,妲己一技能
    private AbilityInput CreateAbilityNoTargetInput(AbilityBehavior abilityBehavior)
    {
        AbilityInput          abilityInput;
        AbilityIndicatorRange abilityIndicatorRange;
        var rangeTrans = GetIndicatorAsset(AbilityIndicatorType.RANGE_AREA);

        // 直线型
        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_DIRECTIONAL) != 0)
        {
            abilityInput = new AbilityInputDirection(m_casterTransform, ability);
            var castRange = ability.GetCastRange();
            abilityIndicatorRange = new AbilityIndicatorRange(rangeTrans, m_casterTransform, castRange);
            var   trans = GetIndicatorAsset(AbilityIndicatorType.LINE_AREA);
            float lineLength, lineThickness;
            ability.GetLineAoe(out lineLength, out lineThickness);
            AbilityIndicatorLine abilityIndicatorLine = new AbilityIndicatorLine(trans, m_casterTransform, lineLength, lineThickness);
            abilityInput.AddAbilityIndicator(abilityIndicatorRange);
            abilityInput.AddAbilityIndicator(abilityIndicatorLine);
            return(abilityInput);
        }

        // 扇形型
        if ((abilityBehavior & AbilityBehavior.ABILITY_BEHAVIOR_SECTOR_AOE) != 0)
        {
            abilityInput = new AbilityInputDirection(m_casterTransform, ability);
            AbilityIndicatorType abilityIndicatorType;
            float sectorRadius, sectorAngle;
            ability.GetSectorAoe(out sectorRadius, out sectorAngle);
            if (sectorAngle == 60)
            {
                abilityIndicatorType = AbilityIndicatorType.SECTOR60_AREA;
            }
            else if (sectorAngle == 90)
            {
                abilityIndicatorType = AbilityIndicatorType.SECTOR90_AREA;
            }
            else if (sectorAngle == 120)
            {
                abilityIndicatorType = AbilityIndicatorType.SECTOR120_AREA;
            }
            else
            {
                BattleLog.LogError("技能[{0}]中有未定义的扇形AOE范围角度[{1}]", ability.GetConfigName(), sectorAngle);
                return(null);
            }

            var castRange = ability.GetCastRange();
            abilityIndicatorRange = new AbilityIndicatorRange(rangeTrans, m_casterTransform, castRange);

            var trans = GetIndicatorAsset(abilityIndicatorType);
            var abilityIndicatorSector = new AbilityIndicatorLine(trans, m_casterTransform, sectorRadius, sectorRadius);

            abilityInput.AddAbilityIndicator(abilityIndicatorRange);
            abilityInput.AddAbilityIndicator(abilityIndicatorSector);
            return(abilityInput);
        }

        // 范围型AOE 和 普通攻击,可以原地平A
        abilityInput          = new AbilityInputDirection(m_casterTransform, ability);
        abilityIndicatorRange = new AbilityIndicatorRange(rangeTrans, m_casterTransform, ability.GetCastRange());
        abilityInput.AddAbilityIndicator(abilityIndicatorRange);

        return(abilityInput);
    }
Example #21
0
        Vector2 DrawAbilityConfigurator(float startX, float startY, Ability ability)
        {
            float originX = startX;
            float originY = startY;
            //float cachedX=startX;
            float cachedY = startY;

            cont = new GUIContent("Prefab:", "The prefab object of the tower\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX + 65, startY, width, height), cont);
            abilityList[selectID].prefab = (GameObject)EditorGUI.ObjectField(new Rect(startX + 120, startY, 130, height), abilityList[selectID].prefab, typeof(GameObject), false);

            cont = new GUIContent("ID :" + ability.ID, "The prefab object of the tower\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX + 260, startY, width, height), cont);

            //EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), ability.icon);
            startX += 65;

            cont = new GUIContent("Name:", "The ability name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.name);

            cont = new GUIContent("Selfcast:", "When checked, Selfcast ability");
            EditorGUI.LabelField(new Rect(startX + 235, startY, width + 10, height), cont);
            ability.selfCast = EditorGUI.Toggle(new Rect(startX + 290, startY, 40, height), ability.selfCast);

            if (!ability.selfCast)
            {
                cont = new GUIContent("At Caster:", "Cast at position of Caster");
                EditorGUI.LabelField(new Rect(startX + 310, startY, width + 10, height), cont);
                ability.castAtCaster = EditorGUI.Toggle(new Rect(startX + 365, startY, 40, height), ability.castAtCaster);
            }

            cont = new GUIContent("Layer:", "Layer of targetable object");
            EditorGUI.LabelField(new Rect(startX + 235, startY += spaceY, width + 10, height), cont);
            ability.customMask = EditorUtilities.LayerMaskField(new Rect(startX + 290, startY, 100, height), "", ability.customMask);

            //ability.customMask = EditorGUI.IntField(new Rect(startX + 390, startY+40, 185, height), ability.customMask);

            cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.icon = (Sprite)EditorGUI.ObjectField(new Rect(originX, originY, 60, 60), ability.icon, typeof(Sprite), false);

            cont = new GUIContent("Disable in AbilityManager:", "When checked, the ability won't appear on AbilityManager list and thus can't be access from the get go\nThis is to mark ability that can only be unlocked from perk");
            EditorGUI.LabelField(new Rect(startX + 235, startY, width + 10, height), cont);
            ability.disableInAbilityManager = EditorGUI.Toggle(new Rect(startX + 400, startY, 185, height), ability.disableInAbilityManager);

            cont = new GUIContent("Belong to Hero:", "When checked, the ability won't appear on AbilityManager list and thus can't be access from the get go\nThis is to mark ability that can only be unlocked from perk");
            EditorGUI.LabelField(new Rect(startX + 235, startY += spaceY, width + 10, height), cont);
            ability.belongToHero = EditorGUI.Toggle(new Rect(startX + 400, startY, 185, height), ability.belongToHero);


            startX -= 65;
            startY += 10 + spaceY / 2;

            cachedY = startY + spaceY;

            cont = new GUIContent("Cost:", "The energy cost to use the ability");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), ability.cost);

            cont = new GUIContent("Cooldown:", "The cooldown duration of the ability. Once used, the ability cannot be used again until the cooldown duration has passed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.cooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), ability.cooldown);


            cont = new GUIContent("Ability type:", "Check if ability need a specific position or unit as target. When checked, the user will need to select a position/unit before the ability can be cast. Otherwise the ability be cast without a target position/unit. If ability uses default effects and this is unchecked, the effect will be apply to all unit in the game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[abilityTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(abilityTypeLabel[i], abilityTypeTooltip[i]);
            }
            ability.abilityType = (Ability.AbilityType)EditorGUI.Popup(new Rect(startX + spaceX, startY, width - 20, height), new GUIContent(""), (int)ability.abilityType, contL);

            // ability.requireTargetSelection = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), ability.requireTargetSelection);

            if (ability.requireTargetSelection)
            {
                cont = new GUIContent(" - Single Unit Only:", "Check if the ability require a specific unit as a target. Otherwise the ability can be cast anywhere without a specific target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.singleUnitTargeting = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), ability.singleUnitTargeting);

                if (ability.singleUnitTargeting)
                {
                    //~ cont=new GUIContent(" - Target Friendly:", "Check if the ability is meant to target firendly unit. Otherwise it will target");
                    //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                    //~ ability.targetType=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), ability.targetType);

                    cont = new GUIContent(" - Target :", "Determine which type of unit the tower can target. Hostile for hostile unit. Friendly for friendly unit. Hybrid for both.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    contL = new GUIContent[targetTypeLabel.Length];
                }

                cont = new GUIContent(" - Indicator:", "(Optional) The cursor indicator that used to indicate the ability target position during target selection phase for the ability. If left unassigned, the default indicator specified in the AbilityManager will be used instead");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.indicator = (Transform)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ability.indicator, typeof(Transform), false);

                if (ability.indicator == null)
                {
                    cont = new GUIContent(" - Scale Indicator:", "Automatically scale the indicator size to match the aoeRadius of the ability, or a unit width in case of a single unit targeting. Only applicable if ability is using default effects");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ability.autoScaleIndicator = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), ability.autoScaleIndicator);
                }
                else
                {
                    cont = new GUIContent(" - Scale Indicator:", "Automatically scale the indicator size to match the aoeRadius of the ability. Only applicable if ability is using default effects");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");
                }
            }
            else
            {
                cont = new GUIContent(" - Targets Unit:", "Check if the unit is immuned to critical hit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");

                cont = new GUIContent(" - Indicator:", "(Optional) The cursor indicator that used to indicate the ability target position during target selection phase for the ability. If left unassigned, the default indicator specified in the AbilityManager will be used instead");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");

                cont = new GUIContent(" - Scale Indicator:", "Automatically scale the indicator size to match the aoeRadius of the ability. Only applicable if ability is using default effects");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");
            }


            cont = new GUIContent("Max Use Count:", "The maximum amount which the ability can be used in a level. Indicate unlimited usage when set to <0");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.maxUseCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), ability.maxUseCount);


            //cont = new GUIContent("Effect Object:", "The effect object spawned at the selected position when the ability is used. This object can contain custom script to do custom effect for the ability");
            //EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //ability.effectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ability.effectObj, typeof(GameObject), false);

            //if(!ability.effectObj && ability.prefab)
            //{
            //    ability.effectObj = ability.prefab;
            //}

            cont = new GUIContent("Use Default Effect:", "Check to use default built in ability effects. Alternative you can script your custom effect and have it spawn as the ability's EffectObject");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.useDefaultEffect = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), ability.useDefaultEffect);

            if (ability.useDefaultEffect)
            {
                if (ability.requireTargetSelection)
                {
                    cont = new GUIContent(" - AOE Radius:", "The Area of Effective radius of the effect. Only target within the radius of the target position will be affected by the ability");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ability.aoeRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), ability.aoeRadius);
                }
                else
                {
                    cont = new GUIContent(" - AOE Radius:", "The Area of Effective radius of the effect. Only target within the radius of the target position will be affected by the ability");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");
                }

                cont = new GUIContent(" - Effect Delay:", "The delay in second before the effect actually hit after the ability is cast. This is mostly used to sync-up the visual effect with the effects.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ability.effectDelay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), ability.effectDelay);
            }
            else
            {
                cont = new GUIContent(" - AOE Radius:", "The Area of Effective radius of the effect. Only target within the radius of the target position will be affected by the ability");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");

                cont = new GUIContent(" - Effect Delay:", "The delay in second before the effect actually hit after the ability is cast. This is mostly used to sync-up the visual effect with the effects.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "not applicable");
            }

            startY += 10;


            cont = new GUIContent("Custom Description:", "Check to use use custom description. If not, the default one (generated based on the effect) will be used");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.useCustomDesp = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), ability.useCustomDesp);
            if (ability.useCustomDesp)
            {
                GUIStyle style = new GUIStyle("TextArea");
                style.wordWrap = true;
                cont           = new GUIContent("Perk description (to be used in runtime): ", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
                ability.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), ability.desp, style);
            }


            if (ability.useDefaultEffect)
            {
                startY  = cachedY;
                startX += 300;
                Vector2 v2 = DrawAbilityEffect(ability.effect, startX, startY);
                startX -= 300;
                startY  = v2.y;
            }

            if (abilityList[selectID].prefab)
            {
                AbilityBehavior ab = abilityList[selectID].prefab.GetComponent <AbilityBehavior>();
                ab.ability = ability;

                EditorUtility.SetDirty(ab);
                EditorUtility.SetDirty(abilityList[selectID].prefab);
            }
            //UnitEditorWindow.DrawStat(ability.effect.stat, startX, startY, 700);


            float contWidth = spaceX + width;

            return(new Vector2(contWidth, startY + 700));
        }
Example #22
0
 public static void AddAbilityBehavior(FlatBufferBuilder builder, AbilityBehavior abilityBehavior)
 {
     builder.AddUshort(8, (ushort)abilityBehavior, 0);
 }
Example #23
0
    override protected void InitAbility()
    {
        string currentAbilityString = "normal";

        abilityBehavior = AbilityBehavior.CreateAbilityBehavior(currentAbilityString);
    }
        /// <summary>
        ///     Checks if given ability has given ability behavior flag
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="flag">
        ///     The flag.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public static bool IsAbilityBehavior(this Ability ability, AbilityBehavior flag, string abilityName = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            AbilityBehavior data;
            if (abilityBehaviorDictionary.TryGetValue(name, out data))
            {
                return data.HasFlag(flag);
            }

            data = ability.AbilityBehavior;
            abilityBehaviorDictionary.Add(name, data);
            return data.HasFlag(flag);
        }
Example #25
0
    virtual protected void InitAbility()
    {
        string currentAbilityString = AbilityManager.Instance.currentlyUsingBall;

        abilityBehavior = AbilityBehavior.CreateAbilityBehavior(currentAbilityString);
    }