Exemple #1
0
 private void CheckBoxmen()
 {
     HitPart[] array = ExplosionUtil.CheckBoxmen(base.transform.position, radius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(array[i].transform.position));
             if (num > 0)
             {
                 num = GlobalVars.Instance.applyDurabilityDamage(durability, durabilityMax, num);
                 allComponents[0].Desc.accumDamaged += num;
             }
         }
     }
     GameObject[] array2 = BrickManManager.Instance.ToGameObjectArray();
     for (int j = 0; j < array2.Length; j++)
     {
         int          num2      = (int)weaponBy;
         TPController component = array2[j].GetComponent <TPController>();
         if (component != null && !MyInfoManager.Instance.IsBelow12() && component.IsChild)
         {
             num2 = (int)weaponByForChild;
         }
         PlayerProperty component2 = array2[j].GetComponent <PlayerProperty>();
         if (null != component2 && component2.Desc.accumDamaged > 0)
         {
             P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, component2.Desc.Seq, component2.Desc.accumDamaged, rigidity, num2);
             component2.Desc.accumDamaged = 0;
         }
     }
 }
Exemple #2
0
 private void CheckBoxmen()
 {
     HitPart[] array = ExplosionUtil.CheckBoxmen(base.transform.position, Radius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(array[i].transform.position));
             if (num > 0)
             {
                 WeaponFunction component = GetComponent <WeaponFunction>();
                 if (null == component)
                 {
                     Debug.LogError("wpnFunc == null");
                 }
                 TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem;
                 if (tWeapon == null)
                 {
                     Debug.LogError("wpn == null");
                 }
                 Item item = MyInfoManager.Instance.GetItemBySequence(component.ItemSeq);
                 if (item == null)
                 {
                     item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code);
                 }
                 num = GlobalVars.Instance.applyDurabilityDamage(item?.Durability ?? (-1), tWeapon.durabilityMax, num);
                 P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, allComponents[0].Desc.Seq, num, Rigidity, (int)weaponBy);
             }
         }
     }
 }
 private void CreateMuzzleFire()
 {
     if (!(null == muzzleFire) && !(null == muzzle))
     {
         if (muzzleFxInstance == null)
         {
             GameObject gameObject = Object.Instantiate((Object)muzzleFire) as GameObject;
             Recursively.SetLayer(gameObject.GetComponent <Transform>(), LayerMask.NameToLayer("FPWeapon"));
             gameObject.transform.position      = muzzle.position;
             gameObject.transform.parent        = muzzle;
             gameObject.transform.localRotation = Quaternion.Euler(90f, 90f, 0f);
             muzzleFxInstance = gameObject;
         }
         ParticleEmitter particleEmitter = null;
         int             childCount      = muzzleFxInstance.transform.childCount;
         for (int i = 0; i < childCount; i++)
         {
             Transform child = muzzleFxInstance.transform.GetChild(i);
             particleEmitter = child.GetComponent <ParticleEmitter>();
             if ((bool)particleEmitter)
             {
                 particleEmitter.Emit();
             }
         }
     }
 }
    public DroppedItem(int _itemSeq, string _itemCode, int _bulletCount, int _bulletCount2, float x, float y, float z)
    {
        itemSeq      = _itemSeq;
        itemCode     = _itemCode;
        bulletCount  = _bulletCount;
        bulletCount2 = _bulletCount2;
        TWeapon tWeapon = TItemManager.Instance.Get <TWeapon>(itemCode);

        eff = (UnityEngine.Object.Instantiate((UnityEngine.Object)GlobalVars.Instance.droppedEff, new Vector3(x, y, z), Quaternion.Euler(0f, 0f, 0f)) as GameObject);
        obj = (UnityEngine.Object.Instantiate((UnityEngine.Object)tWeapon.CurPrefab()) as GameObject);
        obj.transform.position = new Vector3(x, y, z);
        obj.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        obj.GetComponent <WeaponGadget>().enabled   = true;
        obj.GetComponent <WeaponFunction>().enabled = false;
        obj.GetComponent <WeaponFunction>().ItemSeq = itemSeq;
        Aim component = obj.GetComponent <Aim>();

        if (null != component)
        {
            component.enabled = false;
        }
        Scope component2 = obj.GetComponent <Scope>();

        if (null != component2)
        {
            component2.enabled = false;
        }
        Recursively.SetLayer(obj.GetComponent <Transform>(), LayerMask.NameToLayer("Default"));
    }
Exemple #5
0
 private void VerifyBrickManDesc()
 {
     if (desc == null)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(base.transform, includeInactive: true);
         if (allComponents.Length > 0)
         {
             desc = allComponents[0].Desc;
         }
     }
 }
Exemple #6
0
 private void _LateUpdate4SpectatorMode()
 {
     SpectatorController[] allComponents  = Recursively.GetAllComponents <SpectatorController>(base.transform, includeInactive: false);
     SpectatorSwitch[]     allComponents2 = Recursively.GetAllComponents <SpectatorSwitch>(base.transform, includeInactive: false);
     if (allComponents2.Length > 0 && allComponents2[0].Target != null && allComponents.Length > 0)
     {
         Vector3 position      = allComponents2[0].Target.transform.position;
         Vector3 worldPosition = new Vector3(position.x, position.y + allComponents[0].targetHeight, position.z);
         base.transform.LookAt(worldPosition);
     }
 }
Exemple #7
0
 public void collideTest()
 {
     activeBeam();
     if (isBeamTest)
     {
         int layerMask = (1 << LayerMask.NameToLayer("BoxMan")) | (1 << LayerMask.NameToLayer("Mon"));
         realExplosion = false;
         if (Physics.Raycast(BeamRay, out RaycastHit hitInfo, rayRange, layerMask))
         {
             GameObject gameObject = hitInfo.transform.gameObject;
             if (gameObject.layer == LayerMask.NameToLayer("BoxMan"))
             {
                 PlayerProperty[] allComponents  = Recursively.GetAllComponents <PlayerProperty>(gameObject.transform, includeInactive: false);
                 PlayerProperty   playerProperty = null;
                 if (allComponents.Length != 1)
                 {
                     Debug.LogError("PlayerProperty should be unique for a box man, but it has multiple PlayerProperty components or non ");
                 }
                 if (allComponents.Length > 0)
                 {
                     playerProperty = allComponents[0];
                 }
                 if (playerProperty != null && !playerProperty.IsHostile())
                 {
                     return;
                 }
             }
             CheckBoxmen(vBomb);
             CheckMonster(vBomb);
             if (realExplosion)
             {
                 CheckDestructibles(vBomb);
                 if (!BuildOption.Instance.Props.useUskMuzzleEff || !applyUsk)
                 {
                     if (explosion != null)
                     {
                         Object.Instantiate((Object)explosion, vBomb, Quaternion.Euler(0f, 0f, 0f));
                     }
                 }
                 else if (GlobalVars.Instance.explosionUsk != null)
                 {
                     Object.Instantiate((Object)GlobalVars.Instance.explosionUsk, vBomb, Quaternion.Euler(0f, 0f, 0f));
                 }
                 detonating = false;
                 isBeamTest = false;
                 throwing   = false;
                 Object.DestroyImmediate(beamObj);
                 Object.DestroyImmediate(bombObj);
                 CSNetManager.Instance.Sock.SendCS_GADGET_ACTION_REQ(MyInfoManager.Instance.SenseBombSeq, -1);
             }
         }
     }
 }
 private void CheckMonster(Vector3 boomPos, float DamageRadius)
 {
     HitPart[] array = ExplosionUtil.CheckMon(boomPos, DamageRadius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         MonProperty[] allComponents = Recursively.GetAllComponents <MonProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1 && (MyInfoManager.Instance.Slot >= 4 || !allComponents[i].Desc.bRedTeam) && (MyInfoManager.Instance.Slot < 4 || allComponents[i].Desc.bRedTeam))
         {
             MonManager.Instance.Hit(allComponents[0].Desc.Seq, poisonDamage, 1f, -4, Vector3.zero, Vector3.zero, -1);
         }
     }
 }
 private void CheckBoxmen(Vector3 boomPos, float DamageRadius)
 {
     HitPart[] array = ExplosionUtil.CheckBoxmen(boomPos, DamageRadius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, allComponents[0].Desc.Seq, poisonDamage, 1f, -4);
         }
     }
 }
 protected bool VerifyLocalController()
 {
     if (null == localCtrl)
     {
         LocalController[] allComponents = Recursively.GetAllComponents <LocalController>(base.transform, includeInactive: false);
         if (allComponents.Length != 1)
         {
             Debug.LogError("Local controller should be unique for fps object, but it has multiple local controllers or no local controllers");
         }
         if (allComponents.Length > 0)
         {
             localCtrl = allComponents[0];
         }
     }
     return(localCtrl != null);
 }
Exemple #11
0
 private void CheckMonster()
 {
     HitPart[] array = ExplosionUtil.CheckMon(base.transform.position, radius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         MonProperty[] allComponents = Recursively.GetAllComponents <MonProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1 && (MyInfoManager.Instance.Slot >= 4 || !allComponents[i].Desc.bRedTeam) && (MyInfoManager.Instance.Slot < 4 || allComponents[i].Desc.bRedTeam))
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(array[i].transform.position));
             if (num > 0)
             {
                 MonManager.Instance.Hit(allComponents[0].Desc.Seq, num, 1f, (int)weaponBy, Vector3.zero, Vector3.zero, -1);
             }
         }
     }
 }
Exemple #12
0
 public static void CheckMonster(Vector3 boomPos, int boomDamage, float boomRadius, bool teamConsider = true)
 {
     HitPart[] array = CheckMon(boomPos, boomRadius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         MonProperty[] allComponents = Recursively.GetAllComponents <MonProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1 && (!teamConsider || ((MyInfoManager.Instance.Slot >= 4 || !allComponents[i].Desc.bRedTeam) && (MyInfoManager.Instance.Slot < 4 || allComponents[i].Desc.bRedTeam))))
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(boomPos, array[i].transform.position, boomDamage, boomRadius));
             if (num > 0)
             {
                 MonManager.Instance.Hit(allComponents[0].Desc.Seq, num, 1f, -3, Vector3.zero, Vector3.zero, -1);
             }
         }
     }
 }
 private void CheckBoxmen(Vector3 boomPos, float DamageRadius)
 {
     HitPart[] array = ExplosionUtil.CheckBoxmen(boomPos, DamageRadius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(boomPos, array[i].transform.position));
             if (num > 0)
             {
                 P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, allComponents[0].Desc.Seq, num, Rigidity, -3);
             }
         }
     }
 }
 private void Update()
 {
     enemy = null;
     if (!(null == cam))
     {
         int layerMask = (1 << LayerMask.NameToLayer("BoxMan")) | (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Bomb")) | (1 << LayerMask.NameToLayer("InstalledBomb"));
         Ray ray       = cam.ScreenPointToRay(new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), 0f));
         if (Physics.Raycast(ray, out RaycastHit hitInfo, float.PositiveInfinity, layerMask) && hitInfo.transform.gameObject.layer == LayerMask.NameToLayer("BoxMan"))
         {
             PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(hitInfo.transform, includeInactive: false);
             if (allComponents.Length == 1 && allComponents[0].Desc.IsHostile())
             {
                 enemy = allComponents[0].Desc;
             }
         }
     }
 }
Exemple #15
0
    private GameObject AttachWeapon(GameObject weaponPrefab,TWeapon tItem)
    {
        if (null == weaponPrefab || null == rightHand)
        {
            return(null);
        }
        GameObject gameObject = Object.Instantiate((Object)weaponPrefab) as GameObject;

        gameObject.GetComponent <Weapon>().tItem           = tItem;
        gameObject.GetComponent <WeaponFunction>().enabled = true;
        gameObject.GetComponent <WeaponFunction>().SetDrawn(draw: false);
        if (tItem != null && tItem.IsTwoHands)
        {
            WeaponLeft = (Object.Instantiate((Object)weaponPrefab) as GameObject);
            WeaponLeft.GetComponent <Weapon>().tItem           = tItem;
            WeaponLeft.GetComponent <WeaponFunction>().enabled = true;
            WeaponLeft.GetComponent <WeaponFunction>().SetDrawn(draw: false);
            WeaponLeft.GetComponent <Gun>().LeftHand = true;
            WeaponLeft.GetComponent <Gun>().TwoHands = true;
        }
        if (RoomManager.Instance.CurrentRoomType != 0 && tItem != null)
        {
            gameObject.GetComponent <WeaponFunction>().category = tItem.cat;
            if (WeaponLeft != null)
            {
                WeaponLeft.GetComponent <WeaponFunction>().category = tItem.cat;
            }
        }
        Recursively.SetLayer(gameObject.GetComponent <Transform>(),LayerMask.NameToLayer("FPWeapon"));
        if (WeaponLeft != null)
        {
            Recursively.SetLayer(WeaponLeft.GetComponent <Transform>(),LayerMask.NameToLayer("FPWeapon"));
        }
        Attach(gameObject.transform,rightHand,Quaternion.Euler(0f,90f,90f));
        if (WeaponLeft != null)
        {
            Attach(WeaponLeft.transform,leftHand,Quaternion.Euler(0f,90f,90f));
        }
        gameObject.SetActive(value: false);
        if (WeaponLeft != null)
        {
            WeaponLeft.SetActive(value: false);
        }
        return(gameObject);
    }
 public virtual void setFever(bool isOn)
 {
     if (isOn)
     {
         if (objFever != null)
         {
             Object.Destroy(objFever);
             objFever = null;
         }
         Transform[] componentsInChildren = GetComponentsInChildren <Transform>();
         int         num = 0;
         while (transformFever == null && num < componentsInChildren.Length)
         {
             if (componentsInChildren[num].name.Contains("Dummy_fire_effect"))
             {
                 transformFever = componentsInChildren[num];
                 break;
             }
             num++;
         }
         if (transformFever != null && objFever == null)
         {
             objFever = (Object.Instantiate((Object)GlobalVars.Instance.fxFeverGun, transformFever.position, Quaternion.Euler(0f, 0f, 0f)) as GameObject);
             Recursively.SetLayer(objFever.GetComponent <Transform>(), LayerMask.NameToLayer("FPWeapon"));
             objFever.transform.position      = transformFever.position;
             objFever.transform.parent        = transformFever;
             objFever.transform.localRotation = Quaternion.Euler(90f, 90f, 0f);
         }
         else
         {
             Debug.LogError("Not found. Dummy_fire_effect.");
         }
     }
     else if (objFever != null)
     {
         Object.Destroy(objFever);
         objFever            = null;
         transformFever      = null;
         feverAutoFire1Click = false;
         feverAutoFire2Click = false;
     }
 }
Exemple #17
0
    private static bool IsFaceToMeSameBrick(Vector3 myEye, Vector3 thirdEye, float d, int seq)
    {
        GameObject    gameObject    = null;
        BrickProperty brickProperty = null;
        int           layerMask     = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick"));
        Ray           ray           = default(Ray);

        ray.origin    = thirdEye;
        ray.direction = Vector3.Normalize(myEye - ray.origin);
        if (Physics.Raycast(ray, out RaycastHit hitInfo, 1000f, layerMask))
        {
            float num = Vector3.Distance(hitInfo.point, thirdEye);
            if (d > num)
            {
                GameObject gameObject2 = hitInfo.transform.gameObject;
                if (gameObject2.layer == LayerMask.NameToLayer("Brick"))
                {
                    BrickProperty[] allComponents = Recursively.GetAllComponents <BrickProperty>(gameObject2.transform, includeInactive: false);
                    if (allComponents.Length > 0)
                    {
                        brickProperty = allComponents[0];
                    }
                }
                else
                {
                    gameObject = BrickManager.Instance.GetBrickObjectByPos(Brick.ToBrickCoord(hitInfo.normal, hitInfo.point));
                    if (null != gameObject)
                    {
                        brickProperty = gameObject.GetComponent <BrickProperty>();
                    }
                }
                if (null != brickProperty && brickProperty.Seq == seq)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Exemple #18
0
 private void CheckBoxmen(Vector3 boomPos)
 {
     HitPart[] array = ExplosionUtil.CheckBoxmen(boomPos, Radius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             int num = Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(boomPos, array[i].transform.position));
             if (num > 0)
             {
                 WeaponFunction component = GetComponent <WeaponFunction>();
                 if (null == component)
                 {
                     Debug.LogError("wpnFunc == null");
                 }
                 TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem;
                 if (tWeapon == null)
                 {
                     Debug.LogError("wpn == null");
                 }
                 Item usingEquipByCode = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code);
                 num = GlobalVars.Instance.applyDurabilityDamage(usingEquipByCode?.Durability ?? (-1), tWeapon.durabilityMax, num);
                 allComponents[0].Desc.accumDamaged += num;
             }
         }
     }
     GameObject[] array2 = BrickManManager.Instance.ToGameObjectArray();
     for (int j = 0; j < array2.Length; j++)
     {
         PlayerProperty component2 = array2[j].GetComponent <PlayerProperty>();
         if (null != component2 && component2.Desc.accumDamaged > 0)
         {
             P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, component2.Desc.Seq, component2.Desc.accumDamaged, Rigidity, (int)weaponBy);
             component2.Desc.accumDamaged = 0;
             realExplosion = true;
         }
     }
 }
    private bool IsVisible(Vector3 pos, int seq)
    {
        float num = Vector3.Distance(cam.transform.position, pos);

        if (num > 15f)
        {
            return(false);
        }
        int     layerMask  = (1 << LayerMask.NameToLayer("BoxMan")) | (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Bomb")) | (1 << LayerMask.NameToLayer("InstalledBomb")) | (1 << LayerMask.NameToLayer("BndWall"));
        Vector3 normalized = (pos - cam.transform.position).normalized;
        Ray     ray        = new Ray(cam.transform.position, normalized);

        if (Physics.Raycast(ray, out RaycastHit hitInfo, float.PositiveInfinity, layerMask) && hitInfo.transform.gameObject.layer == LayerMask.NameToLayer("BoxMan"))
        {
            PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(hitInfo.transform, includeInactive: false);
            if (allComponents.Length == 1 && allComponents[0].Desc.Seq == seq)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #20
0
 public static void CheckBoxmen(Vector3 boomPos, int boomDamage, float boomRadius, int weaponBy, float rigidity)
 {
     HitPart[] array = CheckBoxmen(boomPos, boomRadius, includeFriendly: false);
     for (int i = 0; i < array.Length; i++)
     {
         PlayerProperty[] allComponents = Recursively.GetAllComponents <PlayerProperty>(array[i].transform, includeInactive: false);
         if (allComponents.Length == 1)
         {
             allComponents[0].Desc.accumDamaged += Mathf.FloorToInt(array[i].damageFactor * CalcPowFrom(boomPos, array[i].transform.position, boomDamage, boomRadius));
         }
     }
     GameObject[] array2 = BrickManManager.Instance.ToGameObjectArray();
     for (int j = 0; j < array2.Length; j++)
     {
         PlayerProperty component = array2[j].GetComponent <PlayerProperty>();
         if (null != component && component.Desc.accumDamaged > 0)
         {
             P2PManager.Instance.SendPEER_BOMBED(MyInfoManager.Instance.Seq, component.Desc.Seq, component.Desc.accumDamaged, rigidity, weaponBy);
             component.Desc.accumDamaged = 0;
         }
     }
 }
Exemple #21
0
    public GameObject Instantiate(ushort code, Vector3 position, Quaternion rotation)
    {
        GameObject gameObject = UnityEngine.Object.Instantiate((UnityEngine.Object)brick, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject;

        if (meshOptimize)
        {
            for (DIR dIR = DIR.TOP; dIR <= DIR.RIGHT; dIR++)
            {
                if ((code & meshCodeSet[(int)dIR]) > 0)
                {
                    GameObject gameObject2 = bright[(int)dIR];
                    if ((code & shadowCodeSet[(int)dIR]) > 0)
                    {
                        gameObject2 = dark[(int)dIR];
                    }
                    GameObject gameObject3 = UnityEngine.Object.Instantiate((UnityEngine.Object)gameObject2, position, gameObject2.transform.rotation) as GameObject;
                    gameObject3.transform.parent  = gameObject.transform;
                    gameObject.transform.rotation = rotation;
                }
            }
        }
        else
        {
            GameObject gameObject4 = UnityEngine.Object.Instantiate((UnityEngine.Object)bright[0], position, bright[0].transform.rotation) as GameObject;
            if (NeedChunkOptimize())
            {
                Collider[] componentsInChildren = gameObject4.GetComponentsInChildren <Collider>();
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    UnityEngine.Object.Destroy(componentsInChildren[i]);
                }
                Recursively.SetLayer(gameObject4.transform, LayerMask.NameToLayer("Default"));
            }
            gameObject4.transform.parent  = gameObject.transform;
            gameObject.transform.rotation = rotation;
        }
        return(gameObject);
    }
Exemple #22
0
    public static SEND_PACKET_LEVEL check3rdPersonSendOrNoSend(GameObject player, Vector3 shootpos, Vector3 hitpoint, Vector3 shootdir, Vector3 hitnormal, int brickSeq, float range, bool possibleCan)
    {
        if (null == player)
        {
            return(SEND_PACKET_LEVEL.NONE);
        }
        int           layerMask     = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick"));
        GameObject    gameObject    = null;
        BrickProperty brickProperty = null;
        Ray           ray           = default(Ray);
        bool          flag          = true;
        bool          flag2         = true;
        float         num           = 0f;
        Plane         plane         = default(Plane);

        shootpos.y += 1.2f;
        TPController component = player.GetComponent <TPController>();

        if ((bool)component)
        {
            float num2  = Vector3.Distance(shootpos, component.transform.position);
            bool  flag3 = false;
            if (num2 < inputMinDistance)
            {
                flag3 = true;
            }
            bool flag4 = false;
            if (num2 > inputMaxDistance)
            {
                flag4 = true;
            }
            Vector3 position  = component.transform.position;
            Vector3 position2 = component.transform.position;
            position2.y += 10f;
            Vector3 c = component.transform.position + component.lookAt() * 30f;
            plane.Set3Points(position, position2, c);
            flag = true;
            Vector3 rhs = shootpos - component.transform.position;
            rhs.Normalize();
            num = Vector3.Dot(component.lookAt(), rhs);
            if (num < 0.2f)
            {
                flag = false;
            }
            flag2 = true;
            rhs   = hitpoint - component.transform.position;
            rhs.Normalize();
            num = Vector3.Dot(component.lookAt(), rhs);
            if (num <= 0.2f)
            {
                flag2 = false;
            }
            if (flag3)
            {
                return(SEND_PACKET_LEVEL.ALL);
            }
            if (flag4)
            {
                return(SEND_PACKET_LEVEL.NONE);
            }
            Vector3 position3 = component.transform.position;
            position3.y  += 1.2f;
            ray.origin    = position3;
            ray.direction = Vector3.Normalize(hitpoint - ray.origin);
            bool flag5 = false;
            if (Physics.Raycast(ray, out RaycastHit hitInfo, range, layerMask))
            {
                GameObject gameObject2 = hitInfo.transform.gameObject;
                if (gameObject2.layer == LayerMask.NameToLayer("Brick"))
                {
                    BrickProperty[] allComponents = Recursively.GetAllComponents <BrickProperty>(gameObject2.transform, includeInactive: false);
                    if (allComponents.Length > 0)
                    {
                        brickProperty = allComponents[0];
                    }
                }
                else
                {
                    gameObject = BrickManager.Instance.GetBrickObjectByPos(Brick.ToBrickCoord(hitInfo.normal, hitInfo.point));
                    if (null != gameObject)
                    {
                        brickProperty = gameObject.GetComponent <BrickProperty>();
                    }
                }
                if (null != brickProperty && brickSeq != brickProperty.Seq)
                {
                    flag5 = true;
                }
            }
            ray.direction = Vector3.Normalize(shootpos - ray.origin);
            bool flag6 = false;
            if (Physics.Raycast(ray, out hitInfo, num2 + 1f, layerMask))
            {
                float num3 = Vector3.Distance(hitInfo.point, component.transform.position);
                if (num2 > num3)
                {
                    flag6 = true;
                }
            }
            if (!flag && !flag2)
            {
                return(SEND_PACKET_LEVEL.NONE);
            }
            if (!flag5 && !flag6)
            {
                return(SEND_PACKET_LEVEL.ALL);
            }
            if (flag5 || !flag2)
            {
                if (!flag6)
                {
                    return(SEND_PACKET_LEVEL.EXCEPT_EFFECT);
                }
                if (num2 < 20f)
                {
                    return(SEND_PACKET_LEVEL.ONLY_SOUND);
                }
                return(SEND_PACKET_LEVEL.NONE);
            }
            if (!possibleCan && flag5 && flag6)
            {
                float distanceToPoint  = plane.GetDistanceToPoint(shootpos);
                float distanceToPoint2 = plane.GetDistanceToPoint(hitpoint);
                if (distanceToPoint < distanceToPoint2)
                {
                    return(SEND_PACKET_LEVEL.NONE);
                }
                if (distanceToPoint * distanceToPoint2 < 0f)
                {
                    Vector3 intersection = Vector3.zero;
                    if (LinePlaneIntersection(out intersection, shootpos, shootdir, plane.normal, position3))
                    {
                        ray.direction = component.lookAt();
                        if (Physics.Raycast(ray, out hitInfo, 30f, layerMask))
                        {
                            return(SEND_PACKET_LEVEL.EXCEPT_EFFECT);
                        }
                    }
                }
            }
            return(SEND_PACKET_LEVEL.ALL);
        }
        return(SEND_PACKET_LEVEL.ALL);
    }
Exemple #23
0
    public static SEND_PACKET_LEVEL checkSendDir(GameObject player, Vector3 myPos, Bounds bounds)
    {
        if (null == player)
        {
            return(SEND_PACKET_LEVEL.NONE);
        }
        GameObject    gameObject    = null;
        BrickProperty brickProperty = null;
        TPController  component     = player.GetComponent <TPController>();

        if ((bool)component)
        {
            Vector3  vector               = new Vector3(myPos.x, myPos.y + 1.2f, myPos.z);
            Vector3  position             = component.transform.position;
            float    x                    = position.x;
            Vector3  position2            = component.transform.position;
            float    y                    = position2.y + 1.2f;
            Vector3  position3            = component.transform.position;
            Vector3  vector2              = new Vector3(x, y, position3.z);
            float    num                  = Vector3.Distance(myPos, component.transform.position);
            Camera[] componentsInChildren = player.GetComponentsInChildren <Camera>();
            if (componentsInChildren.Length > 0)
            {
                camera               = componentsInChildren[0];
                camera.fieldOfView   = 75f;
                camera.nearClipPlane = 0.3f;
                camera.farClipPlane  = 1000f;
            }
            camera.transform.position = vector2;
            camera.transform.rotation = component.transform.rotation;
            Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
            if (GeometryUtility.TestPlanesAABB(planes, bounds))
            {
                int layerMask = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick"));
                Ray ray       = default(Ray);
                ray.origin    = vector2;
                ray.direction = Vector3.Normalize(vector - ray.origin);
                if (Physics.Raycast(ray, out RaycastHit hitInfo, 1000f, layerMask))
                {
                    float num2 = Vector3.Distance(hitInfo.point, vector2);
                    if (num > num2)
                    {
                        GameObject gameObject2 = hitInfo.transform.gameObject;
                        if (gameObject2.layer == LayerMask.NameToLayer("Brick"))
                        {
                            BrickProperty[] allComponents = Recursively.GetAllComponents <BrickProperty>(gameObject2.transform, includeInactive: false);
                            if (allComponents.Length > 0)
                            {
                                brickProperty = allComponents[0];
                            }
                        }
                        else
                        {
                            gameObject = BrickManager.Instance.GetBrickObjectByPos(Brick.ToBrickCoord(hitInfo.normal, hitInfo.point));
                            if (null != gameObject)
                            {
                                brickProperty = gameObject.GetComponent <BrickProperty>();
                            }
                        }
                        if (null != brickProperty && IsTransparent(brickProperty.Index) && IsFaceToMeSameBrick(vector, vector2, num, brickProperty.Seq))
                        {
                            camera.enabled = false;
                            return(SEND_PACKET_LEVEL.ALL);
                        }
                        camera.enabled = false;
                        return(SEND_PACKET_LEVEL.NONE);
                    }
                }
                camera.enabled = false;
                return(SEND_PACKET_LEVEL.ALL);
            }
            camera.enabled = false;
            return(SEND_PACKET_LEVEL.NONE);
        }
        return(SEND_PACKET_LEVEL.ALL);
    }
 private void CheckSlash()
 {
     if (isValidRange)
     {
         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((float)(Screen.width / 2), (float)(Screen.height / 2), 0f));
         if (Physics.Raycast(ray, out RaycastHit hitInfo, GetComponent <Weapon>().range, layerMask))
         {
             GameObject gameObject  = null;
             GameObject gameObject2 = hitInfo.transform.gameObject;
             if (gameObject2.layer == LayerMask.NameToLayer("Chunk") || gameObject2.layer == LayerMask.NameToLayer("Brick"))
             {
                 BrickProperty brickProperty = null;
                 GameObject    gameObject3   = null;
                 if (gameObject2.layer == LayerMask.NameToLayer("Brick"))
                 {
                     BrickProperty[] allComponents = Recursively.GetAllComponents <BrickProperty>(gameObject2.transform, includeInactive: false);
                     if (allComponents.Length > 0)
                     {
                         brickProperty = allComponents[0];
                     }
                 }
                 else
                 {
                     gameObject = BrickManager.Instance.GetBrickObjectByPos(Brick.ToBrickCoord(hitInfo.normal, hitInfo.point));
                     if (null != gameObject)
                     {
                         brickProperty = gameObject.GetComponent <BrickProperty>();
                     }
                 }
                 if (null != brickProperty)
                 {
                     P2PManager.Instance.SendPEER_HIT_BRICK(brickProperty.Seq, brickProperty.Index, hitInfo.point, hitInfo.normal, isBullet: false);
                     gameObject3 = BrickManager.Instance.GetBulletImpact(brickProperty.Index);
                     Brick brick = BrickManager.Instance.GetBrick(brickProperty.Index);
                     if (brick != null && brick.destructible)
                     {
                         brickProperty.Hit((int)CalcAtkPow());
                         if (brickProperty.HitPoint <= 0)
                         {
                             if (!Application.loadedLevelName.Contains("Tutor"))
                             {
                                 CSNetManager.Instance.Sock.SendCS_DESTROY_BRICK_REQ(brickProperty.Seq);
                             }
                             gameObject3 = null;
                             if (brickProperty.Index == 115 || brickProperty.Index == 193)
                             {
                                 CheckMyself(gameObject.transform.position, GlobalVars.Instance.BoomRadius);
                                 CheckBoxmen(gameObject.transform.position, GlobalVars.Instance.BoomRadius);
                                 CheckMonster(gameObject.transform.position, GlobalVars.Instance.BoomRadius);
                                 CheckDestructibles(gameObject.transform.position, GlobalVars.Instance.BoomRadius);
                             }
                         }
                         else
                         {
                             P2PManager.Instance.SendPEER_BRICK_HITPOINT(brickProperty.Seq, brickProperty.HitPoint);
                         }
                     }
                 }
                 if (null != gameObject3)
                 {
                     Object.Instantiate((Object)gameObject3, hitInfo.point, Quaternion.FromToRotation(Vector3.up, hitInfo.normal));
                 }
             }
             else if (gameObject2.layer == LayerMask.NameToLayer("BoxMan"))
             {
                 PlayerProperty[] allComponents2 = Recursively.GetAllComponents <PlayerProperty>(gameObject2.transform, includeInactive: false);
                 TPController[]   allComponents3 = Recursively.GetAllComponents <TPController>(gameObject2.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 component = gameObject2.GetComponent <HitPart>();
                     if (component != null)
                     {
                         if (component.GetHitImpact() != null)
                         {
                             Object.Instantiate((Object)component.GetHitImpact(), hitInfo.point, Quaternion.Euler(0f, 0f, 0f));
                         }
                         num = (int)(CalcAtkPow() * component.damageFactor);
                         if (!playerProperty.IsHostile())
                         {
                             num = 0;
                         }
                         WeaponFunction component2 = GetComponent <WeaponFunction>();
                         if (null == component2)
                         {
                             Debug.LogError("wpnFunc == nulll");
                         }
                         TWeapon tWeapon = (TWeapon)GetComponent <Weapon>().tItem;
                         if (tWeapon == null)
                         {
                             Debug.LogError("wpn == null");
                         }
                         Item item = MyInfoManager.Instance.GetItemBySequence(component2.ItemSeq);
                         if (item == null)
                         {
                             item = MyInfoManager.Instance.GetUsingEquipByCode(tWeapon.code);
                         }
                         num = GlobalVars.Instance.applyDurabilityDamage(item?.Durability ?? (-1), tWeapon.durabilityMax, num);
                         P2PManager.Instance.SendPEER_HIT_BRICKMAN(MyInfoManager.Instance.Seq, playerProperty.Desc.Seq, (int)component.part, hitInfo.point, hitInfo.normal, lucky: false, 0, ray.direction);
                         P2PManager.Instance.SendPEER_PIERCE(MyInfoManager.Instance.Seq, playerProperty.Desc.Seq, num, Rigidity, (int)weaponBy);
                     }
                     tPController.GetHit(num, playerProperty.Desc.Seq);
                 }
             }
             else if (gameObject2.layer == LayerMask.NameToLayer("Mon"))
             {
                 MonProperty[] allComponents4 = Recursively.GetAllComponents <MonProperty>(gameObject2.transform, includeInactive: false);
                 MonProperty   monProperty    = null;
                 if (allComponents4.Length > 0)
                 {
                     monProperty = allComponents4[0];
                 }
                 if (monProperty != null)
                 {
                     HitPart component3 = gameObject2.GetComponent <HitPart>();
                     if (component3 != null)
                     {
                         if ((MyInfoManager.Instance.Slot < 4 && monProperty.Desc.bRedTeam) || (MyInfoManager.Instance.Slot >= 4 && !monProperty.Desc.bRedTeam))
                         {
                             return;
                         }
                         if (component3.GetHitImpact() != null)
                         {
                             Object.Instantiate((Object)component3.GetHitImpact(), hitInfo.point, Quaternion.Euler(0f, 0f, 0f));
                         }
                         if (monProperty.Desc.Xp <= 0)
                         {
                             return;
                         }
                         int num2 = (int)(CalcAtkPow() * component3.damageFactor);
                         if (monProperty.Desc.bHalfDamage)
                         {
                             num2 /= 2;
                         }
                         MonManager.Instance.Hit(monProperty.Desc.Seq, num2, 0f, (int)weaponBy, Vector3.zero, Vector3.zero, -1);
                     }
                 }
             }
             else if (gameObject2.layer == LayerMask.NameToLayer("InvincibleArmor") || gameObject2.layer == LayerMask.NameToLayer("Bomb") || gameObject2.layer == LayerMask.NameToLayer("InstalledBomb"))
             {
                 GameObject impact = VfxOptimizer.Instance.GetImpact(gameObject2.layer);
                 if (null != impact)
                 {
                     Object.Instantiate((Object)impact, hitInfo.point, Quaternion.FromToRotation(Vector3.up, hitInfo.normal));
                     P2PManager.Instance.SendPEER_HIT_IMPACT(gameObject2.layer, hitInfo.point, hitInfo.normal);
                 }
             }
             isValidRange = false;
         }
     }
 }
    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);
                }
            }
        }
    }
 public void SetShooter(int player)
 {
     if (shooter == MyInfoManager.Instance.Seq)
     {
         shooter         = -1;
         localController = null;
         Recursively.ChangeLayer(base.transform, LayerMask.NameToLayer("FpsBrick"), LayerMask.NameToLayer("Brick"));
     }
     else if (shooter >= 0)
     {
         GameObject gameObject = BrickManManager.Instance.Get(shooter);
         if (null != gameObject)
         {
             gameObject.BroadcastMessage("OnLeaveCannon");
             gameObject.transform.parent = null;
         }
         SaveAxleAngle();
     }
     shooter = player;
     if (shooter == MyInfoManager.Instance.Seq)
     {
         GameObject gameObject2 = GameObject.Find("Me");
         if (null != gameObject2)
         {
             localController = gameObject2.GetComponent <LocalController>();
         }
         if (null == gameObject2 || null == localController || localController.IsDead)
         {
             localController = null;
             shooter         = -1;
         }
         else
         {
             Recursively.ChangeLayer(base.transform, LayerMask.NameToLayer("Brick"), LayerMask.NameToLayer("FpsBrick"));
             gameObject2.BroadcastMessage("OnGetCannon", this);
             cyclic       = false;
             heat         = 0f;
             overHeatTime = 0f;
             overHeated   = false;
             SaveAxleAngle();
             lastNotified = 0f;
         }
     }
     else if (shooter >= 0)
     {
         TPController tPController = null;
         GameObject   gameObject3  = BrickManManager.Instance.Get(shooter);
         if (null != gameObject3)
         {
             tPController = gameObject3.GetComponent <TPController>();
         }
         if (null == gameObject3 || null == tPController || tPController.IsDead)
         {
             shooter = -1;
         }
         else
         {
             gameObject3.BroadcastMessage("OnGetCannon", this);
             gameObject3.transform.parent   = tpsLink.transform;
             gameObject3.transform.position = tpsLink.transform.position;
             gameObject3.transform.rotation = tpsLink.transform.rotation;
         }
     }
 }
Exemple #27
0
    public static BrickProperty[] CheckDestructibles(Vector3 position, float radius)
    {
        List <BrickProperty> list = new List <BrickProperty>();
        int layerMask             = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick")) | (1 << LayerMask.NameToLayer("Me")) | (1 << LayerMask.NameToLayer("BoxMan")) | (1 << LayerMask.NameToLayer("InvincibleArmor"));
        int layerMask2            = (1 << LayerMask.NameToLayer("Chunk")) | (1 << LayerMask.NameToLayer("Brick"));

        Collider[] array = Physics.OverlapSphere(position, radius, layerMask2);
        for (int i = 0; i < array.Length; i++)
        {
            BrickProperty[] array2 = null;
            array2 = ((array[i].gameObject.layer != LayerMask.NameToLayer("Brick")) ? array[i].GetComponentsInChildren <BrickProperty>(includeInactive: true) : Recursively.GetAllComponents <BrickProperty>(array[i].gameObject.transform, includeInactive: false));
            if (array2.Length > 0)
            {
                Brick brick = BrickManager.Instance.GetBrick(array2[0].Index);
                if (brick != null && brick.destructible)
                {
                    for (int j = 0; j < array2.Length; j++)
                    {
                        RaycastHit hitInfo;
                        if (!(Vector3.Distance(position, array2[j].transform.position) > radius) && Physics.Linecast(position, array2[j].transform.position, out hitInfo, layerMask) && Vector3.Distance(hitInfo.point, array2[j].transform.position) < 1f)
                        {
                            list.Add(array2[j]);
                        }
                    }
                }
            }
        }
        return(list.ToArray());
    }