示例#1
0
    protected override void CollisionEnter(Collision other)
    {
        M_Rigidbody.Sleep();

        BulletMark bulletMark = other.gameObject.GetComponent <BulletMark>();
        AIBase     ai         = other.gameObject.GetComponentInParent <AIBase>();

        // 攻击环境物体.
        if (bulletMark != null)
        {
            bulletMark.CreateBulletMark(hit);
            bulletMark.Hp -= Damage;
        }

        // 攻击AI角色.
        else if (ai != null)
        {
            // 头部伤害加倍.
            if (other.gameObject.name == "Head")
            {
                ai.Life -= 2 * Damage;
                ai.HitHeadState();
            }
            else
            {
                ai.Life -= Damage;
                ai.HitNormalState();
            }

            ai.PlayEffect(hit);
        }

        gameObject.SetActive(false);
    }
示例#2
0
    private IEnumerator ChangeHitState()
    {
        yield return(new WaitForSeconds(0.8f));

        ray = envCamera.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit, 2.0f))
        {
            BulletMark bm = hit.collider.gameObject.GetComponent <BulletMark>();
            if (bm != null)
            {
                Durable--;
                bm.HP -= Damage;
                bm.PlayEffectsWithAxe(hit);
            }
        }
        yield return(new WaitForSeconds(1.0f));

        canHit = true;
    }
示例#3
0
    /// <summary>
    ///  碰撞时执行的方法
    /// </summary>
    /// <param name="coll"></param>
    protected override void Collision(Collision coll)
    {
        M_Rigidbody.Sleep();
        /// 和环境交互
        if (coll.gameObject.layer == LayerMask.NameToLayer("Envionment"))
        {
            BulletMark bulletMark = coll.gameObject.GetComponent <BulletMark>();
            if (bulletMark != null)
            {
                bulletMark.CreateBulletMark(uiHit);
                bulletMark.HP -= Damage;
            }
            GameObject.Destroy(gameObject);
        }
        /// 和 AI 交互
        else if (coll.gameObject.layer == LayerMask.NameToLayer("AI"))
        {
            AI tempAI = coll.collider.GetComponentInParent <AI>();
            if (tempAI != null)
            {
                // 头部伤害加倍
                if (coll.collider.gameObject.name == "Head")
                {
                    tempAI.HeadGetHit(Damage);
                }
                else
                {
                    tempAI.NormalHit(Damage);
                }



                tempAI.PlayBloodEffect(aiHit);
            }
            GameObject.Destroy(gameObject);
        }
        else
        {
            GameObject.Destroy(gameObject, 2.0f);
        }
    }
示例#4
0
    /// <summary>
    /// 射击.
    /// </summary>
    protected override void Shoot()
    {
        if (hit.point != Vector3.zero)
        {
            BulletMark bulletMark = hit.collider.GetComponent <BulletMark>();
            AIBase     ai         = hit.collider.GetComponentInParent <AIBase>();

            // 射击到环境物体.
            if (bulletMark != null)
            {
                bulletMark.CreateBulletMark(hit);
                bulletMark.Hp -= Damage;
            }

            // 攻击AI角色.
            else if (ai != null)
            {
                // 头部伤害加倍.
                if (hit.collider.gameObject.name == "Head")
                {
                    ai.Life -= 2 * Damage;
                    ai.HitHeadState();
                }
                else
                {
                    ai.Life -= Damage;
                    ai.HitNormalState();
                }

                ai.PlayEffect(hit);
            }
        }
        else
        {
            GameObject.Instantiate <GameObject>(m_AssaultRifleView.Prefab_Bullet,
                                                hit.point, Quaternion.identity);
        }

        Durable--;
    }
示例#5
0
    protected override void Collision(Collision coll)
    {
        M_Rigidbody.Sleep();
        if (coll.gameObject.layer == LayerMask.NameToLayer("Envionment"))
        {
            GameObject.Destroy(m_BoxCollider);
            GameObject.Destroy(M_Rigidbody);
            BulletMark tempBulletMark = coll.collider.GetComponent <BulletMark>();
            if (tempBulletMark != null)
            {
                tempBulletMark.HP -= Damage;
            }
            StartCoroutine("AnimationPlay", m_Pivot);
            M_Transform.SetParent(coll.gameObject.transform);
        }
        else if (coll.gameObject.layer == LayerMask.NameToLayer("AI"))
        {
            GameObject.Destroy(m_BoxCollider);
            GameObject.Destroy(M_Rigidbody);
            AI tempAI = coll.collider.GetComponentInParent <AI>();
            if (tempAI != null)
            {
                // 头部伤害加倍
                if (coll.collider.gameObject.name == "Head")
                {
                    tempAI.HeadGetHit(Damage);
                }
                else
                {
                    tempAI.NormalHit(Damage);
                }

                // 播放血液特效
                tempAI.PlayBloodEffect(aiEffectHit);
            }
            StartCoroutine("AnimationPlay", m_Pivot);
            M_Transform.SetParent(coll.gameObject.transform);
        }
    }
示例#6
0
    /// <summary>
    /// 碰撞事件.
    /// </summary>
    protected override void CollisionEnter(Collision other)
    {
        GameObject.Destroy(M_Rigidbody);
        GameObject.Destroy(m_BoxCollider);

        BulletMark bulletMark = other.gameObject.GetComponent <BulletMark>();
        AIBase     ai         = other.gameObject.GetComponentInParent <AIBase>();

        // 攻击环境物体.
        if (bulletMark != null)
        {
            bulletMark.Hp -= Damage;
            bulletMark.PlayHitAudio(hit);
        }

        // 攻击AI角色.
        else if (ai != null)
        {
            // 头部伤害加倍.
            if (other.gameObject.name == "Head")
            {
                ai.Life -= 2 * Damage;
                ai.HitHeadState();
            }
            else
            {
                ai.Life -= Damage;
                ai.HitNormalState();
            }

            ai.PlayEffect(hit);
        }

        // 通用效果展现.
        M_Transform.SetParent(other.gameObject.GetComponent <Transform>());
        StartCoroutine("TailAnimation", m_PivotTransform);
    }
    private void Shoot()
    {
        Vector2 vector    = accuracy.CalcDeflection();
        int     layerMask = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick")) | (1 << LayerMask.NameToLayer("BoxMan")) | (1 << LayerMask.NameToLayer("Mon")) | (1 << LayerMask.NameToLayer("InvincibleArmor")) | (1 << LayerMask.NameToLayer("Bomb")) | (1 << LayerMask.NameToLayer("InstalledBomb"));
        Ray     ray       = cam.ScreenPointToRay(new Vector3(vector.x, vector.y, 0f));

        if (!Application.loadedLevelName.Contains("Tutor"))
        {
            P2PManager.Instance.SendPEER_CANNON_FIRE(BrickSeq, shooter, ray.origin, ray.direction);
        }
        if (Physics.Raycast(ray, out RaycastHit hitInfo, Range, layerMask))
        {
            GameObject gameObject = hitInfo.transform.gameObject;
            if (gameObject.layer == LayerMask.NameToLayer("Brick") || gameObject.layer == LayerMask.NameToLayer("Chunk"))
            {
                GameObject    gameObject2   = null;
                BrickProperty brickProperty = null;
                GameObject    original      = null;
                Texture2D     mark          = null;
                if (gameObject.layer == LayerMask.NameToLayer("Brick"))
                {
                    BrickProperty[] allComponents = Recursively.GetAllComponents <BrickProperty>(gameObject.transform, includeInactive: false);
                    if (allComponents.Length > 0)
                    {
                        brickProperty = allComponents[0];
                    }
                }
                else
                {
                    gameObject2 = BrickManager.Instance.GetBrickObjectByPos(Brick.ToBrickCoord(hitInfo.normal, hitInfo.point));
                    if (null != gameObject2)
                    {
                        brickProperty = gameObject2.GetComponent <BrickProperty>();
                    }
                }
                if (null != brickProperty)
                {
                    P2PManager.Instance.SendPEER_HIT_BRICK(brickProperty.Seq, brickProperty.Index, hitInfo.point, hitInfo.normal, isBullet: true);
                    mark     = BrickManager.Instance.GetBulletMark(brickProperty.Index);
                    original = BrickManager.Instance.GetBulletImpact(brickProperty.Index);
                    Brick brick = BrickManager.Instance.GetBrick(brickProperty.Index);
                    if (brick != null && brick.destructible)
                    {
                        brickProperty.Hit((int)AtkPow);
                        if (brickProperty.HitPoint <= 0)
                        {
                            CSNetManager.Instance.Sock.SendCS_DESTROY_BRICK_REQ(brickProperty.Seq);
                            mark     = null;
                            original = null;
                            if (brickProperty.Index == 115 || brickProperty.Index == 193)
                            {
                                ExplosionUtil.CheckMyself(gameObject2.transform.position, GlobalVars.Instance.BoomDamage, GlobalVars.Instance.BoomRadius, -3);
                                ExplosionUtil.CheckBoxmen(gameObject2.transform.position, GlobalVars.Instance.BoomDamage, GlobalVars.Instance.BoomRadius, -3, Rigidity);
                                ExplosionUtil.CheckMonster(gameObject2.transform.position, GlobalVars.Instance.BoomDamage, GlobalVars.Instance.BoomRadius);
                                ExplosionUtil.CheckDestructibles(gameObject2.transform.position, GlobalVars.Instance.BoomDamage, GlobalVars.Instance.BoomRadius);
                            }
                        }
                        else
                        {
                            P2PManager.Instance.SendPEER_BRICK_HITPOINT(brickProperty.Seq, brickProperty.HitPoint);
                        }
                    }
                }
                if (null != gameObject2 && null != mark)
                {
                    GameObject gameObject3 = Object.Instantiate((Object)BrickManager.Instance.bulletMark, hitInfo.point, Quaternion.FromToRotation(Vector3.forward, -hitInfo.normal)) as GameObject;
                    BulletMark component   = gameObject3.GetComponent <BulletMark>();
                    component.GenerateDecal(mark, gameObject, gameObject2);
                }
                if (null != original)
                {
                    Object.Instantiate((Object)original, hitInfo.point, Quaternion.FromToRotation(Vector3.up, hitInfo.normal));
                }
            }
            else if (gameObject.layer == LayerMask.NameToLayer("BoxMan"))
            {
                PlayerProperty[] allComponents2 = Recursively.GetAllComponents <PlayerProperty>(gameObject.transform, includeInactive: false);
                TPController[]   allComponents3 = Recursively.GetAllComponents <TPController>(gameObject.transform, includeInactive: false);
                if (allComponents2.Length != 1)
                {
                    Debug.LogError("PlayerProperty should be unique for a box man, but it has multiple PlayerProperty components or non ");
                }
                if (allComponents3.Length != 1)
                {
                    Debug.LogError("TPController should be unique for a box man, but it has multiple TPController components or non ");
                }
                PlayerProperty playerProperty = null;
                TPController   tPController   = null;
                if (allComponents2.Length > 0)
                {
                    playerProperty = allComponents2[0];
                }
                if (allComponents3.Length > 0)
                {
                    tPController = allComponents3[0];
                }
                if (playerProperty != null && tPController != null)
                {
                    int     num        = 0;
                    HitPart component2 = gameObject.GetComponent <HitPart>();
                    if (component2 != null)
                    {
                        bool flag = false;
                        if (component2.part == HitPart.TYPE.HEAD)
                        {
                            int layerMask2 = 1 << LayerMask.NameToLayer("Brain");
                            if (Physics.Raycast(ray, out RaycastHit hitInfo2, Range, layerMask2))
                            {
                                if (playerProperty.Desc.IsLucky())
                                {
                                    flag = true;
                                }
                                else
                                {
                                    component2 = hitInfo2.transform.gameObject.GetComponent <HitPart>();
                                }
                            }
                        }
                        if (component2.GetHitImpact() != null)
                        {
                            GameObject original2 = component2.GetHitImpact();
                            if (flag && null != component2.luckyImpact)
                            {
                                original2 = component2.luckyImpact;
                            }
                            Object.Instantiate((Object)original2, hitInfo.point, Quaternion.Euler(0f, 0f, 0f));
                        }
                        num = (int)(AtkPow * component2.damageFactor);
                        if (!playerProperty.IsHostile())
                        {
                            num = 0;
                        }
                        P2PManager.Instance.SendPEER_HIT_BRICKMAN(MyInfoManager.Instance.Seq, playerProperty.Desc.Seq, (int)component2.part, hitInfo.point, hitInfo.normal, flag, 0, ray.direction);
                        P2PManager.Instance.SendPEER_SHOOT(MyInfoManager.Instance.Seq, playerProperty.Desc.Seq, num, Rigidity, (int)weaponBy, (int)component2.part, flag, rateOfFire);
                    }
                    tPController.GetHit(num, playerProperty.Desc.Seq);
                }
            }
            else if (gameObject.layer == LayerMask.NameToLayer("Mon"))
            {
                MonProperty[] allComponents4 = Recursively.GetAllComponents <MonProperty>(gameObject.transform, includeInactive: false);
                MonProperty   monProperty    = null;
                if (allComponents4.Length > 0)
                {
                    monProperty = allComponents4[0];
                }
                if (monProperty != null)
                {
                    HitPart component3 = gameObject.GetComponent <HitPart>();
                    if (component3 != null && (MyInfoManager.Instance.Slot >= 4 || !monProperty.Desc.bRedTeam) && (MyInfoManager.Instance.Slot < 4 || monProperty.Desc.bRedTeam))
                    {
                        if (component3.GetHitImpact() != null)
                        {
                            Object.Instantiate((Object)component3.GetHitImpact(), hitInfo.point, Quaternion.Euler(0f, 0f, 0f));
                        }
                        if (monProperty.Desc.Xp > 0)
                        {
                            int num2 = (int)(AtkPow * component3.damageFactor);
                            num2 += DefenseManager.Instance.AddAtkPower;
                            if (monProperty.Desc.bHalfDamage)
                            {
                                num2 /= 2;
                            }
                            MonManager.Instance.Hit(monProperty.Desc.Seq, num2, 0f, (int)weaponBy, hitInfo.point, hitInfo.normal, -1);
                        }
                    }
                }
            }
            else if (gameObject.layer == LayerMask.NameToLayer("InvincibleArmor") || gameObject.layer == LayerMask.NameToLayer("Bomb") || gameObject.layer == LayerMask.NameToLayer("InstalledBomb"))
            {
                GameObject impact = VfxOptimizer.Instance.GetImpact(gameObject.layer);
                if (null != impact)
                {
                    Object.Instantiate((Object)impact, hitInfo.point, Quaternion.FromToRotation(Vector3.up, hitInfo.normal));
                    P2PManager.Instance.SendPEER_HIT_IMPACT(gameObject.layer, hitInfo.point, hitInfo.normal);
                }
            }
        }
    }