コード例 #1
0
    //-----------------------------------------Utility Functions

    public void DestroySelectedEfect()
    {
        if (_selectedEffect != null)
        {
            _selectedEffect.DestroyEffect();
        }
        _selectedEffect = null;
        selectEffectID  = 0;
    }
コード例 #2
0
    public void enableEffect(int effectType, int drawType, float selectDistance, float attackRange, float chooseRange, int nTargetFilter, int selectType)
    {
        if (m_currentEfffect != null)
        {
            disableEffect();
        }

        if (0 != (drawType & (int)SPELL_DRAW_TYPE.DRAW_TYPE_CHOOSE_RANGE))
        {
            attackRange = chooseRange;
        }
        bool isAnotherPlane = false;

        //水平光圈提示
        if (drawType != 0 && 0 != (drawType & (int)SPELL_DRAW_TYPE.DRAW_TYPE_HORIZONTAL_APERTURE))
        {
            isAnotherPlane = true;
        }
        bool isMaskBuilding = false;

        //取点时检测建筑层
        if (selectType != 0 && (selectType & (int)SPELL_SELECT_TYPE.SpellSelectType_HeroProjectToFloor) != 0)
        {
            isMaskBuilding = true;
        }

        if (m_selectEffectMap == null)
        {
            return;
        }

        m_drawType       = drawType;
        m_selectDistance = selectDistance;
        m_attackRange    = attackRange;
        m_nTargetFilter  = nTargetFilter;
        if (m_selectEffectMap.ContainsKey(effectType))
        {
            m_currentEfffect = m_selectEffectMap[effectType];
            m_currentEfffect.isAnotherPlane = isAnotherPlane;
            m_currentEfffect.isMaskBuilding = isMaskBuilding;
            m_currentEfffect.active         = true;
            m_currentEfffect.nDrawType      = drawType;
            m_currentEfffect.buildArea(selectDistance, attackRange);
        }

        if ((m_selectEffectMap.ContainsKey((int)SPELL_DRAW_TYPE.DRAW_TYPE_DRAW_DISTANCE)) && (0 != (m_drawType & (int)SPELL_DRAW_TYPE.DRAW_TYPE_DRAW_DISTANCE)))
        {
            m_currentDistanceEfffect                = m_selectEffectMap[(int)SPELL_DRAW_TYPE.DRAW_TYPE_DRAW_DISTANCE];
            m_currentDistanceEfffect.active         = true;
            m_currentDistanceEfffect.isAnotherPlane = isAnotherPlane;
            m_currentDistanceEfffect.isMaskBuilding = isMaskBuilding;
            m_currentDistanceEfffect.nDrawType      = drawType;
            m_currentDistanceEfffect.buildArea(selectDistance, selectDistance);
        }
    }
コード例 #3
0
    private void updateOutline(SelectEffect effect)
    {
        if (effect == null)
        {
            return;
        }

        ICollection <U3D_Render.EntityView> all_entities = EntityFactory.GetEntityList();

        foreach (U3D_Render.EntityView ev in all_entities)
        {
            if (ev == null)
            {
                continue;
            }

            int entity_id = ev.ID;


            if (!ev.gameObject)
            {
                continue;
            }
            int layer = ev.gameObject.layer;
            if (0 == ((1 << layer) & m_selectLayerFilter))
            {
                continue;
            }


            bool select = (ScreenRaycast.checkTargetFilter(ev, m_nTargetFilter));
            select = select && (effect.isInArea(ev.gameObject.transform.position));
            if (select)
            {
                if (!m_outlineList.Contains(entity_id))
                {
                    ev.StateMachine.outLineCount++;
                    m_outlineList.Add(entity_id);
                }
            }
            else
            {
                if (m_outlineList.Contains(entity_id))
                {
                    ev.StateMachine.outLineCount--;
                    m_outlineList.Remove(entity_id);
                }
            }
        }
    }
コード例 #4
0
 public void disableEffect()
 {
     if (m_currentEfffect != null)
     {
         m_currentEfffect.active = false;
         m_currentEfffect        = null;
     }
     if (m_currentDistanceEfffect != null)
     {
         m_currentDistanceEfffect.active = false;
         m_currentDistanceEfffect        = null;
     }
     clearOutline();
 }
コード例 #5
0
    public void clearEffects()
    {
        foreach (KeyValuePair <int, SelectEffect> keypair in m_selectEffectMap)
        {
            SelectEffect effect = keypair.Value;
            effect.destroy();
        }
        if (m_selectEffectRoot)
        {
            var temp = m_selectEffectRoot.gameObject;
            ResNode.DestroyRes(ref temp);
        }

        m_selectEffectMap.Clear();
    }
コード例 #6
0
ファイル: ScriptedAI.cs プロジェクト: spadd/CypherCore
        //Returns spells that meet the specified criteria from the creatures spell list
        public SpellInfo SelectSpell(Unit target, SpellSchoolMask school, Mechanics mechanic, SelectTargetType targets, float rangeMin, float rangeMax, SelectEffect effect)
        {
            //No target so we can't cast
            if (target == null)
            {
                return(null);
            }

            //Silenced so we can't cast
            if (me.HasUnitFlag(UnitFlags.Silenced))
            {
                return(null);
            }

            //Using the extended script system we first create a list of viable spells
            SpellInfo[] apSpell = new SpellInfo[SharedConst.MaxCreatureSpells];

            uint spellCount = 0;

            //Check if each spell is viable(set it to null if not)
            for (uint i = 0; i < SharedConst.MaxCreatureSpells; i++)
            {
                SpellInfo       tempSpell = Global.SpellMgr.GetSpellInfo(me.m_spells[i], me.GetMap().GetDifficultyID());
                AISpellInfoType aiSpell   = GetAISpellInfo(me.m_spells[i], me.GetMap().GetDifficultyID());

                //This spell doesn't exist
                if (tempSpell == null)
                {
                    continue;
                }

                // Targets and Effects checked first as most used restrictions
                //Check the spell targets if specified
                if (targets != 0 && !Convert.ToBoolean(aiSpell.Targets & (1 << ((int)targets - 1))))
                {
                    continue;
                }

                //Check the type of spell if we are looking for a specific spell type
                if (effect != 0 && !Convert.ToBoolean(aiSpell.Effects & (1 << ((int)effect - 1))))
                {
                    continue;
                }

                //Check for school if specified
                if (school != 0 && (tempSpell.SchoolMask & school) == 0)
                {
                    continue;
                }

                //Check for spell mechanic if specified
                if (mechanic != 0 && tempSpell.Mechanic != mechanic)
                {
                    continue;
                }

                //Check if the spell meets our range requirements
                if (rangeMin != 0 && me.GetSpellMinRangeForTarget(target, tempSpell) < rangeMin)
                {
                    continue;
                }
                if (rangeMax != 0 && me.GetSpellMaxRangeForTarget(target, tempSpell) > rangeMax)
                {
                    continue;
                }

                //Check if our target is in range
                if (me.IsWithinDistInMap(target, me.GetSpellMinRangeForTarget(target, tempSpell)) || !me.IsWithinDistInMap(target, me.GetSpellMaxRangeForTarget(target, tempSpell)))
                {
                    continue;
                }

                //All good so lets add it to the spell list
                apSpell[spellCount] = tempSpell;
                ++spellCount;
            }

            //We got our usable spells so now lets randomly pick one
            if (spellCount == 0)
            {
                return(null);
            }

            return(apSpell[RandomHelper.IRand(0, (int)(spellCount - 1))]);
        }