コード例 #1
0
ファイル: AK47SpecialBullet.cs プロジェクト: 05Robot/05_Robot
    private Transform MainEnemy;//射中的敌人
    /// <summary>
    /// 大范围爆炸
    /// </summary>
    //修改Physics2D.Raycast
    void ExplosionHitEffect()
    {
        Collider2D[] colliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), ExplosionRadius, layer);//Physics.OverlapSphere():球形范围内的碰撞器
        for (int i = 0; i < colliders.Length; i++)
        {
            EnemyContral hitEnemyContral = null;
            switch (colliders[i].transform.gameObject.layer)
            {
            //敌人护盾
            case 18:
                hitEnemyContral = hitPoint[i].transform.GetComponent <ShieldProtect>().GetEnemyControl();
                break;

            //敌人内部
            case 11:
                hitEnemyContral = hitPoint[i].transform.GetComponent <EnemyContral>();
                break;

            //紫水晶与零件箱
            case 19:
            case 20:
                hitPoint[i].transform.GetComponent <HitCheckBase>().Broken();
                break;
            }

            if (hitEnemyContral != null)
            {
                hitEnemyContral.GetDamage(Convert.ToInt32(ExplosionDemage), Convert.ToInt32(ExplosionDemage));
                //硬直
                hitEnemyContral.SetDelay(2, 4);
                //击退
                hitEnemyContral.SetKnockback(transform.position, 0.5f, 4);
            }
        }
    }
コード例 #2
0
ファイル: RocketBullet.cs プロジェクト: 05Robot/05_Robot
    private Transform MainEnemy;//射中的敌人
    /// <summary>
    /// 大范围爆炸
    /// </summary>
    //修改Physics2D.Raycast
    void ExplosionHitEffect()
    {
        EnemyIDList.Clear();
        Collider2D[] colliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), ExplosionRadius, layer);//Physics.OverlapSphere():球形范围内的碰撞器
        for (int i = 0; i < colliders.Length; i++)
        {
            EnemyContral hitEnemyContral = null;
            switch (colliders[i].transform.gameObject.layer)
            {
            //敌人护盾
            case 18:
                if (EnemyIDList.Contains(colliders[i].transform.GetComponent <ShieldProtect>().ProtectAimGameObject.GetInstanceID()))
                {
                    continue;
                }
                hitEnemyContral = colliders[i].transform.GetComponent <ShieldProtect>().GetEnemyControl();
                EnemyIDList.Add(colliders[i].transform.GetComponent <ShieldProtect>().ProtectAimGameObject.GetInstanceID());
                break;

            //敌人内部
            case 11:
                if (EnemyIDList.Contains(colliders[i].transform.GetInstanceID()))
                {
                    continue;
                }
                hitEnemyContral = colliders[i].transform.GetComponent <EnemyContral>();
                EnemyIDList.Add(colliders[i].transform.GetInstanceID());
                break;

            //紫水晶与零件箱
            case 19:
            case 20:
                colliders[i].transform.GetComponent <HitCheckBase>().Broken();
                break;
            }
            if (hitEnemyContral != null)
            {
                hitEnemyContral.GetDamage(Convert.ToInt32(ExplosionDemage), Convert.ToInt32(ExplosionDemage));
                //硬直
                hitEnemyContral.SetDelay(2, (int)HardStraight);
                //击退
                hitEnemyContral.SetKnockback(transform.position, 0.5f, (int)BeatBack);
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// 敌人伤害
    /// </summary>
    private void EnemyDamage(Collider2D[] AllCollider2D, int DamageNums)
    {
        for (int i = 0; i < AllCollider2D.Length; i++)
        {
            EnemyContral hitEnemyContral = null;
            switch (AllCollider2D[i].transform.gameObject.layer)
            {
            //敌人护盾
            case 18:
                hitEnemyContral = AllCollider2D[i].transform.GetComponent <ShieldProtect>().GetEnemyControl();
                break;

            //敌人内部
            case 11:
                hitEnemyContral = AllCollider2D[i].transform.GetComponent <EnemyContral>();
                break;

            //紫水晶与零件箱
            case 19:
            case 20:
                AllCollider2D[i].transform.GetComponent <HitCheckBase>().Broken();
                break;
            }

            if (hitEnemyContral != null)
            {
                hitEnemyContral.GetDamage(DamageNums, DamageNums);
                //硬直
                hitEnemyContral.SetDelay(2, 4);
                //击退
                hitEnemyContral.SetKnockback(transform.position, 0.5f, 4);
            }
        }

        var shakePreset = ProCamera2DShake.Instance.ShakePresets[2];

        ProCamera2DShake.Instance.Shake(shakePreset);
    }
コード例 #4
0
    /// <summary>
    /// 普通攻击  碰撞后产生伤害
    /// 打在护盾上或者是人物身上
    /// </summary>
    protected virtual void GenerateDemage()
    {
        //伤害取整
        int Damage = Convert.ToInt32(DemageNums);

        for (int i = 0; i < hitPoint.Length; i++)
        {
            EnemyContral hitEnemyContral = null;
            switch (hitPoint[i].transform.gameObject.layer)
            {
            //击中玩家护盾
            case 17:
                //对玩家进行伤害(应该是扣mp)
                hitPoint[i].transform.GetComponent <ShieldProtect>().GetPlayerControl().GetDamage(Damage, Damage);
                break;

            //击中玩家内部
            case 10:
                //对玩家进行伤害(应该是扣hp)
                print(hitPoint[i].transform.name);
                hitPoint[i].transform.GetComponent <PlayerRobotContral>().GetRealDamage(Damage);
                break;

            //击中敌人护盾
            case 18:
                //对敌人进行伤害(应该是扣mp)
                hitEnemyContral = hitPoint[i].transform.GetComponent <ShieldProtect>().GetEnemyControl();
                hitEnemyContral.GetDamage(Damage, Damage);
                break;

            //击中敌人内部
            case 11:
                //对敌人进行伤害(应该是扣hp)
                hitEnemyContral = hitPoint[i].transform.GetComponent <EnemyContral>();
                hitEnemyContral.GetRealDamage(Damage);
                break;

            //紫水晶与零件箱
            case 19:
            case 20:
                hitPoint[i].transform.GetComponent <HitCheckBase>().Broken();
                break;
            }

            //设置硬直击退
            if (hitEnemyContral != null)
            {
                hitEnemyContral.SetDelay(0.5f, (int)HardStraight);
                hitEnemyContral.SetKnockback(transform.position, 0.5f, (int)BeatBack);
            }
            //-----------------------------------------------------------------------------------------------------------------
            //核心攻击 AOE + 特殊效果
            //当前是否核心攻击 && 是否打中敌人护盾/敌人内部
            if (isCoreAttack && hitEnemyContral != null)
            {
                //不同的核心产生不同的效果
                switch (m_CurrentCoreAttribute)
                {
                case CoreAttribute.Initial:
                    break;

                case CoreAttribute.Fire:
                    //燃烧效果,敌人持续减血
                    hitEnemyContral.ER.AddAbnormalState(new AbnormalState_Burn(hitEnemyContral.ER, 3));
                    break;

                case CoreAttribute.Amethyst:
                    //todo 无视MP,修改紫水晶子弹检测layer,不添加敌人护盾检测,直接打在敌人身上
                    break;

                case CoreAttribute.Frozen:
                    //冰冻效果,敌人持续减速
                    hitEnemyContral.ER.AddAbnormalState(new AbnormalState_Frozen(hitEnemyContral.ER, 3));
                    break;
                }
            }
        }
    }