Ejemplo n.º 1
0
    protected override void CheckCollisionWithEnemy()
    {
        List <EnemyBase> enemyList = EnemyManager.GetInstance().GetEnemyList();
        int                  count = enemyList.Count;
        EnemyBase            enemy;
        CollisionDetectParas para;
        float                dx, dy;
        eEliminateDef        specialEliminateDef = eEliminateDef.CodeEliminate | eEliminateDef.CodeRawEliminate | eEliminateDef.SpellCardFinish;

        for (int i = 0; i < count; i++)
        {
            enemy = enemyList[i];
            if (enemy != null && enemy.DetectCollision())
            {
                para = enemy.GetCollisionDetectParas(0);
                // 敌机全部使用矩形判定
                dx = Mathf.Abs(_curPos.x - para.centerPos.x);
                dy = Mathf.Abs(_curPos.y - para.centerPos.y);
                if (dx <= _radius + para.halfWidth && dy <= _radius + para.halfHeight)
                {
                    if ((_eliminateType & specialEliminateDef) != 0)
                    {
                        enemy.Eliminate(_eliminateType);
                    }
                    else
                    {
                        enemy.TakeDamage(_hitEnemyDamage, _eliminateType);
                    }
                    _collidedByEnemy?.Invoke(this, enemy);
                }
            }
        }
    }
    protected override void CheckCollisionWithEnemy()
    {
        List <EnemyBase> enemyList = EnemyManager.GetInstance().GetEnemyList();
        int                  count = enemyList.Count;
        EnemyBase            enemy;
        CollisionDetectParas para;
        eEliminateDef        specialEliminateDef = eEliminateDef.CodeEliminate | eEliminateDef.CodeRawEliminate | eEliminateDef.SpellCardFinish;

        //bool checkWithEnemy = (_colliderGroups & (int)eColliderGroup.Enemy) != 0;
        //bool checkWithBoss = (_colliderGroups & (int)eColliderGroup.Boss) != 0;
        for (int i = 0; i < count; i++)
        {
            enemy = enemyList[i];
            if (enemy != null && enemy.DetectCollision())
            {
                para = enemy.GetCollisionDetectParas(0);
                if (MathUtil.DetectCollisionBetweenOBBAndOBB(_curPos, _halfWidth, _halfHeight, _curRotation, para.centerPos, para.halfWidth, para.halfHeight, 0))
                {
                    if ((_eliminateType & specialEliminateDef) != 0)
                    {
                        enemy.Eliminate(_eliminateType);
                    }
                    else
                    {
                        enemy.TakeDamage(_hitEnemyDamage, _eliminateType);
                    }
                    _collidedByEnemy?.Invoke(this, enemy);
                }
            }
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 被消除的时候调用
 /// </summary>
 protected void OnEliminate(eEliminateDef eliminateType)
 {
     if (eliminateType != eEliminateDef.ForcedDelete && (eliminateType & RawEliminateTypes) != 0)
     {
         if (_onEliminateFuncRef != 0)
         {
             InterpreterManager.GetInstance().AddPara(this, LuaParaType.LightUserData);
             InterpreterManager.GetInstance().CallLuaFunction(_onEliminateFuncRef, 1);
         }
     }
     if (_attachableMaster != null)
     {
         IAttachable master = _attachableMaster;
         _attachableMaster = null;
         master.OnAttachmentEliminated(this);
     }
     if (_attachmentsCount != 0)
     {
         int count = _attachmentsCount;
         _attachmentsCount = 0;
         IAttachment attachment;
         for (int i = 0; i < count; i++)
         {
             attachment = _attachmentsList[i];
             if (attachment != null)
             {
                 attachment.OnMasterEliminated(eliminateType);
             }
         }
         _attachmentsList.Clear();
     }
 }
Ejemplo n.º 4
0
 public override bool Eliminate(eEliminateDef eliminateType = eEliminateDef.ForcedDelete)
 {
     _curHp = 0;
     if (base.Eliminate(eliminateType))
     {
         if (eliminateType != eEliminateDef.ForcedDelete)
         {
             SoundManager.GetInstance().Play("killenemy", 0.1f, false, true);
             if (_cfg.eliminatedEffectStyle != 0)
             {
                 STGEnemyEliminatedEffect effect = EffectsManager.GetInstance().CreateEffectByType(EffectType.EnemyEliminated) as STGEnemyEliminatedEffect;
                 effect.SetEliminateEffectStyle(_cfg.eliminatedEffectStyle);
                 effect.SetPosition(_curPos.x, _curPos.y);
             }
         }
         if (eliminateType != eEliminateDef.ForcedDelete && eliminateType != eEliminateDef.CodeRawEliminate)
         {
             if (_dropItemDatas != null)
             {
                 DropItems();
             }
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 消除子弹
 /// </summary>
 /// <param name="eliminateType">消除方式</param>
 /// <returns></returns>
 public virtual bool Eliminate(eEliminateDef eliminateType = 0)
 {
     if (_clearFlag == 1)
     {
         return(false);
     }
     if (((int)eliminateType & _resistEliminateFlag) != 0)
     {
         return(false);
     }
     if (_attachableMaster != null)
     {
         IAttachable master = _attachableMaster;
         _attachableMaster = null;
         master.OnAttachmentEliminated(this);
     }
     if (_attachmentsCount != 0)
     {
         int attachmentsCount = _attachmentsCount;
         _attachmentsCount = 0;
         for (int i = 0; i < attachmentsCount; i++)
         {
             if (_attachmentsList[i] != null)
             {
                 _attachmentsList[i].OnMasterEliminated(eliminateType);
             }
         }
         _attachmentsList.Clear();
     }
     _clearFlag = 1;
     return(true);
 }
    /// <summary>
    /// 设置ObjectCollider的清除类型
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int SetObjectColliderEliminateType(ILuaState luaState)
    {
        ObjectColliderBase collider      = luaState.ToUserData(-2) as ObjectColliderBase;
        eEliminateDef      eliminateType = (eEliminateDef)luaState.ToInteger(-1);

        collider.SetEliminateType(eliminateType);
        return(0);
    }
Ejemplo n.º 7
0
 public void OnMasterEliminated(eEliminateDef eliminateType)
 {
     _attachableMaster = null;
     _isFollowingMasterContinuously = false;
     if (_isEliminatedWithMaster)
     {
         Eliminate(eliminateType);
     }
 }
Ejemplo n.º 8
0
 public override void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     if (n == 0)
     {
         _isSourceEliminated = true;
     }
     else
     {
         _eliminateRangeList.Add(_collisionSegmentsList[n - 1]);
         _eliminateRangeListCount++;
     }
 }
Ejemplo n.º 9
0
 public override void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     if (n == 0)
     {
         _isSourceEliminated = true;
         SetSourceEnable(false);
     }
     else if (_collidedSegmentIndexList.IndexOf(n - 1) == -1)
     {
         _collidedSegmentIndexList.Add(n - 1);
         _collidedSegmentCount++;
     }
 }
Ejemplo n.º 10
0
 public override void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     Logger.Log("Before Hit Circle len = " + _curLaserLen);
     if (_collisionSegmentsCount > n)
     {
         _curLaserLen = (_collisionSegments[n] - _curPos).magnitude;
         Logger.Log("Hit Circle len = " + _curLaserLen);
         // 截取掉之后的碰撞组
         _collisionSegmentsCount = n;
         _hitPos    = _curPos + _dirVec * _curLaserLen;
         _hitObject = true;
     }
 }
Ejemplo n.º 11
0
 public ObjectColliderBase()
 {
     _clearFlag        = 0;
     _existDuration    = 0;
     _hitEnemyDamage   = 0;
     _eliminateType    = eEliminateDef.HitObjectCollider;
     _isScaling        = false;
     _movableObject    = ObjectsPool.GetInstance().GetPoolClassAtPool <MovableObject>();
     _tag              = "";
     _taskList         = new List <Task>();
     _taskCount        = 0;
     _attachmentsList  = new List <IAttachment>();
     _attachmentsCount = 0;
 }
Ejemplo n.º 12
0
 public virtual bool Eliminate(eEliminateDef eliminateType = 0)
 {
     if (!_isAvailable)
     {
         return(false);
     }
     if ((_resistEliminateFlag & (int)eliminateType) != 0)
     {
         return(false);
     }
     OnEliminate(eliminateType);
     _isAvailable = false;
     return(true);
 }
Ejemplo n.º 13
0
 public override void TakeDamage(float damage, eEliminateDef eliminateType = eEliminateDef.PlayerBullet)
 {
     if ((_resistEliminateFlag & (int)eliminateType) != 0)
     {
         return;
     }
     if (!_isInvincible)
     {
         _curHp -= damage;
         if (_curHp <= 0)
         {
             _curHp = 0;
         }
     }
 }
Ejemplo n.º 14
0
 public override bool Eliminate(eEliminateDef eliminateType = eEliminateDef.ForcedDelete)
 {
     if (base.Eliminate(eliminateType))
     {
         if (eliminateType != eEliminateDef.ForcedDelete)
         {
             Color eliminateColor = _cfg.eliminateColor;
             //STGBulletEliminateEffect effect = EffectsManager.GetInstance().CreateEffectByType(EffectType.BulletEliminate) as STGBulletEliminateEffect;
             //effect.SetColor(eliminateColor);
             //effect.SetPosition(_curPos.x, _curPos.y);
             STGEliminateEffectManager.GetInstance().CreateBulletEliminateEffect(_curPos, eliminateColor);
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 15
0
 public override void TakeDamage(float damage, eEliminateDef eliminateType = eEliminateDef.PlayerBullet)
 {
     if ((_resistEliminateFlag & (int)eliminateType) != 0)
     {
         return;
     }
     if (!_isInteractive)
     {
         return;
     }
     _curHp -= damage;
     if (_curHp <= 0)
     {
         _isInteractive = false;
         _curHp         = 0;
         Eliminate(eliminateType);
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 物体第n个碰撞盒被物体碰撞了
 /// </summary>
 /// <param name="index"></param>
 public virtual void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 受到伤害
 /// </summary>
 /// <param name="damage"></param>
 /// <param name="eliminateType"></param>
 public virtual void TakeDamage(float damage, eEliminateDef eliminateType = eEliminateDef.PlayerBullet)
 {
 }
Ejemplo n.º 18
0
 public virtual void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 19
0
 public void OnMasterEliminated(eEliminateDef eliminateType)
 {
     _master   = null;
     _isFinish = true;
 }
Ejemplo n.º 20
0
 public bool Eliminate(eEliminateDef eliminateType = 0)
 {
     FinishEffect();
     return(true);
 }
 public override void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     _hitPos = _curPos;
     BeginEliminating();
 }
Ejemplo n.º 22
0
 public bool Eliminate(eEliminateDef eliminateType = 0)
 {
     ClearSelf();
     return(true);
 }
Ejemplo n.º 23
0
 public void OnMasterEliminated(eEliminateDef eliminateType)
 {
     _master    = null;
     _clearFlag = 1;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 设置ObjectCollider的消除类型
 /// 自机符卡/碰撞物体
 /// </summary>
 /// <param name="eliminateType"></param>
 public void SetEliminateType(eEliminateDef eliminateType)
 {
     _eliminateType = eliminateType;
 }
Ejemplo n.º 25
0
 public override void CollidedByObject(int n = 0, eEliminateDef eliminateDef = eEliminateDef.HitObjectCollider)
 {
     Eliminate(eliminateDef);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// 判断是否能被该种类型消除
 /// </summary>
 /// <param name="eliminateType"></param>
 /// <returns></returns>
 public virtual bool CanBeEliminated(eEliminateDef eliminateType)
 {
     return(((int)eliminateType & _resistEliminateFlag) == 0);
 }