Пример #1
0
    void OnTriggerEnter(Collider other)
    {
        if (triggleEnable)
        {
            try
            {
                if (other.gameObject.layer == 9)
                {
                    triggleEnable = false;
                    HitGround();
                    base.SetGearEventStateOne(ID);

                    List <List <uint> > entities = MogoUtils.GetEntitiesInRange(transform, radius);

                    if (entities.Count != 4)
                    {
                        return;
                    }

                    List <uint> dummyList  = entities[0];
                    List <uint> playerList = entities[2];

                    if (canAttackDummy)
                    {
                        foreach (uint id in dummyList)
                        {
                            EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.GetEntity(id) as EntityParent));
                        }
                    }

                    foreach (uint id in playerList)
                    {
                        if (id == MogoWorld.thePlayer.ID)
                        {
                            EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.thePlayer as EntityParent));
                            break;
                        }
                    }
                }
            }
            catch
            {
                Debug.LogError("Undefined tag gameobject name: " + other.gameObject.name);
            }
        }
    }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        if (triggleEnable)
        {
            if (other.gameObject.layer == 9)//Terrain
            {
                MogoMainCamera.Instance.Shake(5, 0.1f);
                sfxHandler.HandleFx(500102);
                sfxHandler.RemoveFXs(6011);
                List <List <uint> > entities = MogoUtils.GetEntitiesInRange(transform, radius);
                if (entities.Count != 4)
                {
                    return;
                }

                List <uint> dummyList  = entities[0];
                List <uint> playerList = entities[2];

                if (canAttackDummy)
                {
                    foreach (uint id in dummyList)
                    {
                        EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.GetEntity(id) as EntityParent));
                    }
                }

                foreach (uint id in playerList)
                {
                    if (id == MogoWorld.thePlayer.ID)
                    {
                        EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.thePlayer as EntityParent));
                        break;
                    }
                }

                if (timerID == uint.MaxValue)
                {
                    timerID = TimerHeap.AddTimer(5000, 0, BombDestroy);
                }
                vx            = 0;
                vy            = 0;
                triggleEnable = false;
            }
        }
    }
Пример #3
0
    void OnTriggerEnter(Collider other)
    {
        if (triggleEnable)
        {
            if (other.gameObject.layer == 9)//Terrain
            {
                MogoMainCamera.Instance.Shake(5, 0.1f);
                sfxHandler.HandleFx(500102);

                SetDamage(MogoUtils.GetEntitiesInRange(transform, radius));

                triggleEnable = false;

                if (timerID == uint.MaxValue)
                {
                    timerID = TimerHeap.AddTimer(5000, 0, RockDestroy);
                }
            }
        }
    }
Пример #4
0
    protected void MoveEnd(MonoBehaviour script)
    {
        if (triggleEnable && script is MogoSimpleMotor)
        {
            if ((script as MogoSimpleMotor) == motor)
            {
                triggleEnable = false;
                HitGround();
                base.SetGearEventStateOne(ID);

                List <List <uint> > entities = MogoUtils.GetEntitiesInRange(transform, radius);

                if (entities.Count != 4)
                {
                    return;
                }

                List <uint> dummyList  = entities[0];
                List <uint> playerList = entities[0];

                if (canAttackDummy)
                {
                    foreach (uint id in dummyList)
                    {
                        EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.GetEntity(id) as EntityParent));
                    }
                }

                foreach (uint id in playerList)
                {
                    if (id == MogoWorld.thePlayer.ID)
                    {
                        EventDispatcher.TriggerEvent(Events.GearEvent.Damage, id, 9003, (int)2, CalcDamage(MogoWorld.thePlayer as EntityParent));
                        break;
                    }
                }
            }
        }
    }
Пример #5
0
    public bool IsInSkillRange(int skillId, uint targetId)
    {
        var spellData = SkillAction.dataMap[SkillData.dataMap[skillId].skillAction[0]];

        // 目标类型 0 敌人, 1 自己  2 队友  3  友方
        //int targetType = spellData.targetType;
        // 攻击范围类型。  0  扇形范围 1  圆形范围, 2, 单体。 3  直线范围 4 前方范围
        int targetRangeType = spellData.targetRangeType;
        // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表
        List <float> targetRangeParam = spellData.targetRangeParam;
        // 最大攻击人数
        //int maxTargetCount = spellData.maxTargetCount;
        // 触发伤害特效帧数
        //int damageTriggerFrame = spellData.damageTriggerFrame;

        List <List <uint> > entities  = new List <List <uint> >();
        TargetRangeType     rangeType = (TargetRangeType)targetRangeType;

        switch (rangeType)
        {
        case TargetRangeType.CircleRange:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                entities = MogoUtils.GetEntitiesInRange(theOwner.Transform, radius);
            }
            break;

        case TargetRangeType.SectorRange:
            if (targetRangeParam.Count >= 2)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = targetRangeParam[1];
                entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.SingeTarget:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = 150;
                entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.WorldRange:
            if (targetRangeParam.Count >= 4)
            {
                float x1      = targetRangeParam[0] * 0.01f;
                float y1      = targetRangeParam[1] * 0.01f;
                float x2      = targetRangeParam[2] * 0.01f;
                float y2      = targetRangeParam[3] * 0.01f;
                float minX    = Math.Min(x1, x2);
                float maxX    = Math.Max(x1, x2);
                float minY    = Math.Min(y1, y2);
                float maxY    = Math.Max(y1, y2);
                float radiusX = minX + (maxX - minX) * 0.5f;
                float radiusY = minY + (maxY - minY) * 0.5f;
                float radius  = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f;
                entities = MogoUtils.GetEntitiesInRange(new Vector3(radiusX, 0, radiusY), radius);
            }
            break;

        case TargetRangeType.LineRange:
        default:
            if (targetRangeParam.Count >= 2)
            {
                float length = targetRangeParam[0] * 0.01f;
                float width  = targetRangeParam[1] * 0.01f;
                entities = MogoUtils.GetEntitiesFrontLine(theOwner.Transform, length, theOwner.Transform.forward, width);
            }
            break;
        }
        if (entities.Count < 3)
        {
            return(false);
        }
        if (entities[0].Count > 0 && entities[0].Contains(targetId))
        {
            return(true);
        }
        if (entities[1].Count > 0 && entities[1].Contains(targetId))
        {
            return(true);
        }
        if (entities[2].Count > 0 && entities[2].Contains(targetId))
        {
            return(true);
        }
        return(false);
    }
Пример #6
0
    // 根据技能id, 获取到受攻击者列表。
    // 返回值 是一个三元组。 分别是 dummy list, monster list, player list
    private List <List <uint> > GetHitEntities(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position)
    {
        var spellData = SkillAction.dataMap[hitActionID];

        // 目标类型 0 敌人, 1 自己  2 队友  3  友方
        int targetType = spellData.targetType;
        // 攻击范围类型。  0  扇形范围 1  圆形范围, 2, 单体。 3  直线范围 4 前方范围
        int targetRangeType = spellData.targetRangeType;
        // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表
        List <float> targetRangeParam = spellData.targetRangeParam;
        float        offsetX          = spellData.hitXoffset;
        float        offsetY          = spellData.hitYoffset;
        float        angleOffset      = 180;
        // 最大攻击人数
        //int maxTargetCount = spellData.maxTargetCount;
        // 触发伤害特效帧数
        //int damageTriggerFrame = spellData.damageTriggerFrame;

        List <List <uint> > entities = new List <List <uint> >();

        if (targetType == (int)TargetType.Myself)
        {
            List <uint> listDummy     = new List <uint>();
            List <uint> listMonster   = new List <uint>();
            List <uint> listPlayer    = new List <uint>();
            List <uint> listMercenary = new List <uint>();
            listPlayer.Add(theOwner.ID);
            entities.Add(listDummy);
            entities.Add(listMonster);
            entities.Add(listPlayer);
            entities.Add(listMercenary);
            return(entities);
        }
        if (theOwner.Transform == null)
        {
            return(entities);
        }
        Matrix4x4  entityltwm     = theOwner.Transform.localToWorldMatrix;
        Quaternion entityrotation = theOwner.Transform.rotation;
        Vector3    entityforward  = theOwner.Transform.forward;
        Vector3    entityposition = theOwner.Transform.position;

        if (spellData.castPosType == 0)
        {
            entityltwm     = ltwm;
            entityrotation = rotation;
            entityforward  = forward;
            entityposition = position;
        }
        TargetRangeType rangeType = (TargetRangeType)targetRangeType;

        switch (rangeType)
        {
        case TargetRangeType.CircleRange:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                if (spellData.castPosType == 2 && theOwner is EntityDummy)
                {
                    EntityParent e = theOwner.GetTargetEntity();
                    if (e != null)
                    {
                        entities = MogoUtils.GetEntitiesInRange(e.Transform.position, radius, offsetX, offsetY, angleOffset);
                    }
                }
                else
                {
                    //entities = MogoUtils.GetEntitiesInRange(theOwner.Transform, radius, offsetX, offsetY, angleOffset);
                    entities = MogoUtils.GetEntitiesInRange(entityltwm, entityrotation, entityforward, entityposition, radius, offsetX, offsetY, angleOffset);
                }
                //entities = Utils.GetEntities(theOwner.Transform, radius, 150f);
            }
            break;

        case TargetRangeType.SectorRange:
            if (targetRangeParam.Count >= 2)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = targetRangeParam[1];
                //entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle, offsetX, offsetY, angleOffset);
                entities = MogoUtils.GetEntitiesInSector(entityltwm, entityrotation, entityforward, entityposition, radius, angle, offsetX, offsetY, angleOffset);
                //entities = Utils.GetEntities(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.SingeTarget:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = 150;
                //entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle, offsetX, offsetY, angleOffset);
                entities = MogoUtils.GetEntitiesInSector(entityltwm, entityrotation, entityforward, entityposition, radius, angle, offsetX, offsetY, angleOffset);
                //entities = Utils.GetEntities(theOwner.Transform, radius, angle);
                MogoUtils.SortByDistance(theOwner.Transform, entities[0]);
                MogoUtils.SortByDistance(theOwner.Transform, entities[1]);
                MogoUtils.SortByDistance(theOwner.Transform, entities[2]);
                if (entities.Count > 1)
                {
                    for (int i = 1; i < entities.Count; i++)
                    {
                        entities.RemoveAt(i);
                    }
                }
            }
            break;

        case TargetRangeType.WorldRange:
            if (targetRangeParam.Count >= 4)
            {
                float x1      = targetRangeParam[0] * 0.01f;
                float y1      = targetRangeParam[1] * 0.01f;
                float x2      = targetRangeParam[2] * 0.01f;
                float y2      = targetRangeParam[3] * 0.01f;
                float minX    = Math.Min(x1, x2);
                float maxX    = Math.Max(x1, x2);
                float minY    = Math.Min(y1, y2);
                float maxY    = Math.Max(y1, y2);
                float radiusX = minX + (maxX - minX) * 0.5f;
                float radiusY = minY + (maxY - minY) * 0.5f;
                float radius  = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f;
                entities = MogoUtils.GetEntitiesInRange(new Vector3(radiusX, 0, radiusY), radius);
            }
            break;

        case TargetRangeType.LineRange:
        default:
            if (targetRangeParam.Count >= 2)
            {
                float length = targetRangeParam[0] * 0.01f;
                float width  = targetRangeParam[1] * 0.01f;
                //entities = MogoUtils.GetEntitiesFrontLineNew(theOwner.Transform, length, theOwner.Transform.forward, width, offsetX, offsetY, angleOffset);
                entities = MogoUtils.GetEntitiesFrontLineNew(entityltwm, entityrotation, entityforward, entityposition, length, entityforward, width, offsetX, offsetY, angleOffset);
                //entities = Utils.GetEntities(theOwner.Transform, length, width);
            }
            break;
        }
        return(entities);
    }