コード例 #1
0
    private void OnTriggerStay(Collider other)
    {
        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Multiplayer && !Extensions.GetPhotonView(transform.root.gameObject).isMine || !active_me)
        {
            return;
        }


        if (other.gameObject.CompareTag("playerHitbox"))
        {
            if (ModuleManager.Enabled(nameof(ModulePVPEverywhere)) || LevelInfoManager.Get(GameManager.Level).IsPvP)
            {
                float b = 1f - Vector3.Distance(other.gameObject.transform.position, transform.position) * 0.05f;
                b = Mathf.Min(1f, b);
                HitBox component = other.gameObject.GetComponent <HitBox>();
                if (component != null &&
                    component.transform.root != null)
                {
                    var hero = component.transform.root.GetComponent <HERO>();
                    if (!Extensions.GetPhotonView(component.transform.root.gameObject).isMine&& (hero.myTeam != this.myTeam || ModuleManager.Enabled(nameof(ModulePVPEverywhere))) &&
                        !hero.isInvincible() && !hero.HasDied() && !hero.IsGrabbed)
                    {
                        hero.markDie();
                        Vector3 distance = component.transform.root.position - transform.position;
                        component.transform.root.GetComponent <HERO>().photonView.RPC(Rpc.Die, PhotonTargets.All,
                                                                                      distance.normalized * b * 1000f + Vector3.up * 50f, // force : Vector3
                                                                                      false,                                              // isBite : bool
                                                                                      this.viewID,                                        // viewID : int
                                                                                      this.ownerName,                                     // titanName : string
                                                                                      false);                                             // killByTitan : bool
                    }
                }
            }
        }
        else if (other.gameObject.CompareTag("erenHitbox"))
        {
            if (dmg > 0 && !other.gameObject.transform.root.gameObject.GetComponent <TITAN_EREN>().isHit)
            {
                other.gameObject.transform.root.gameObject.GetComponent <TITAN_EREN>().hitByTitan();
            }
        }
        else if (other.gameObject.CompareTag("titanneck"))
        {
            HitBox item = other.gameObject.GetComponent <HitBox>();
            if (item != null && CheckIfBehind(item.transform.root.gameObject) && !this.currentHits.Contains(item))
            {
                item.hitPosition = (transform.position + item.transform.position) * 0.5f;
                this.currentHits.Add(item);

                TITAN          titan         = item.transform.root.GetComponent <TITAN>();
                FEMALE_TITAN   femaleTitan   = item.transform.root.GetComponent <FEMALE_TITAN>();
                COLOSSAL_TITAN colossalTitan = item.transform.root.GetComponent <COLOSSAL_TITAN>();

                Vector3 velocity = IN_GAME_MAIN_CAMERA.instance.main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                int     damage   = Mathf.Max(10, (int)(velocity.magnitude * 10f * this.scoreMulti));
                switch (IN_GAME_MAIN_CAMERA.GameType)
                {
                // TITAN
                // Single
                case GameType.Singleplayer when titan != null && !titan.hasDie:

                    GameManager.instance.NetShowDamage(damage, null);
                    if (damage > titan.myLevel * 100f)
                    {
                        titan.die();
                        IN_GAME_MAIN_CAMERA.instance.TakeScreenshot(item.transform.position, damage, item.transform.root.gameObject, 0.02f);
                        GameManager.instance.PlayerKillInfoSingleplayerUpdate(damage);
                    }
                    break;

                // Multi as MC
                case GameType.Multiplayer when PhotonNetwork.isMasterClient && titan != null && !titan.hasDie:
                    if (damage > titan.myLevel * 100f)
                    {
                        IN_GAME_MAIN_CAMERA.instance.TakeScreenshot(item.transform.position, damage, item.transform.root.gameObject, 0.02f);

                        titan.TitanGetHit(Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                    }
                    break;

                // Multi as user
                case GameType.Multiplayer when titan != null && !titan.hasDie:
                    if (damage > titan.myLevel * 100f)
                    {
                        if (ModuleManager.Enabled(nameof(ModuleSnapshot)))
                        {
                            IN_GAME_MAIN_CAMERA.instance.TakeScreenshot(item.transform.position, damage, item.transform.root.gameObject, 0.02f);
                            titan.asClientLookTarget = false;
                        }
                        object[] objArray2 = new object[] { Extensions.GetPhotonView(transform.root.gameObject).viewID, damage };
                        titan.photonView.RPC(Rpc.TitanGetHit, titan.photonView.owner, objArray2);
                    }
                    break;

                // FEMALE TITAN
                // Multi as MC
                case GameType.Multiplayer when PhotonNetwork.isMasterClient && femaleTitan != null && !femaleTitan.hasDie:
                    IN_GAME_MAIN_CAMERA.instance.TakeScreenshot(item.transform.position, damage, null, 0.02f);

                    femaleTitan.TitanGetHit(Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                    break;

                // Multi as user
                case GameType.Multiplayer when femaleTitan != null && !femaleTitan.hasDie:
                    femaleTitan.photonView.RPC(Rpc.TitanGetHit, femaleTitan.photonView.owner,
                                               Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                    break;

                // COLOSSAL TITAN
                // Multi as MC
                case GameType.Multiplayer when PhotonNetwork.isMasterClient && colossalTitan != null && !colossalTitan.hasDie:
                    IN_GAME_MAIN_CAMERA.instance.TakeScreenshot(item.transform.position, damage, null, 0.02f);

                    colossalTitan.TitanGetHit(Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                    break;

                // Multi as user
                case GameType.Multiplayer when colossalTitan != null && !colossalTitan.hasDie:
                    colossalTitan.photonView.RPC(Rpc.TitanGetHit, colossalTitan.photonView.owner,
                                                 Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                    break;
                }

                this.ShowCriticalHitFX(other.gameObject.transform.position);
            }
        }
        else if (other.gameObject.CompareTag("titaneye"))
        {
            if (!this.currentHits.Contains(other.gameObject))
            {
                this.currentHits.Add(other.gameObject);

                GameObject eye = other.gameObject.transform.root.gameObject;

                var femaleTitan = eye.GetComponent <FEMALE_TITAN>();
                if (femaleTitan != null && !femaleTitan.hasDie)
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Singleplayer)
                    {
                        femaleTitan.hitEye();
                    }
                    else if (!PhotonNetwork.isMasterClient)
                    {
                        femaleTitan.photonView.RPC(Rpc.HitEye, PhotonTargets.MasterClient, Extensions.GetPhotonView(transform.root.gameObject).viewID);
                    }
                    else
                    {
                        femaleTitan.HitEyeRPC(Extensions.GetPhotonView(transform.root.gameObject).viewID);
                    }
                    return;
                }

                var titan = eye.GetComponent <TITAN>();
                if (titan != null && titan.abnormalType != AbnormalType.Crawler && !titan.hasDie)
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Singleplayer)
                    {
                        titan.HitEye();
                    }
                    else if (!PhotonNetwork.isMasterClient)
                    {
                        titan.photonView.RPC(Rpc.HitEye, PhotonTargets.MasterClient, Extensions.GetPhotonView(transform.root.gameObject).viewID);
                    }
                    else if (!titan.hasDie)
                    {
                        titan.HitEyeRPC(Extensions.GetPhotonView(transform.root.gameObject).viewID);
                    }

                    this.ShowCriticalHitFX(other.gameObject.transform.position);
                }
            }
        }
        else if (other.gameObject.CompareTag("titanankle") && !this.currentHits.Contains(other.gameObject))
        {
            currentHits.Add(other.gameObject);
            GameObject obj      = other.gameObject.transform.root.gameObject;
            Vector3    velocity = IN_GAME_MAIN_CAMERA.instance.main_object.rigidbody.velocity - obj.rigidbody.velocity;
            int        damage   = Mathf.Max(10, (int)(velocity.magnitude * 10f * this.scoreMulti));

            var titan       = obj.GetComponent <TITAN>();
            var femaleTitan = obj.GetComponent <FEMALE_TITAN>();

            if (titan != null && titan.abnormalType != AbnormalType.Crawler && !titan.hasDie)
            {
                if (IN_GAME_MAIN_CAMERA.GameType == GameType.Singleplayer)
                {
                    titan.hitAnkle();
                }
                else if (!PhotonNetwork.isMasterClient)
                {
                    titan.photonView.RPC(Rpc.HitEye, PhotonTargets.MasterClient, Extensions.GetPhotonView(transform.root.gameObject).viewID);
                }
                else
                {
                    titan.hitAnkle();
                }

                ShowCriticalHitFX(other.gameObject.transform.position);
            }
            else if (femaleTitan != null && !femaleTitan.hasDie)
            {
                switch (IN_GAME_MAIN_CAMERA.GameType)
                {
                case GameType.Singleplayer:
                    if (other.gameObject.name == "ankleR")
                    {
                        femaleTitan.hitAnkleR(damage);
                    }
                    else
                    {
                        femaleTitan.hitAnkleL(damage);
                    }
                    break;

                case GameType.Multiplayer:
                    if (PhotonNetwork.isMasterClient)
                    {
                        if (other.gameObject.name == "ankleR")
                        {
                            femaleTitan.HitAnkleRRPC(Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                        }
                        else
                        {
                            femaleTitan.HitAnkleLRPC(Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                        }
                    }
                    else
                    {
                        if (other.gameObject.name == "ankleR")
                        {
                            femaleTitan.photonView.RPC(Rpc.HitRightAnkle, PhotonTargets.MasterClient, Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                        }
                        else
                        {
                            femaleTitan.photonView.RPC(Rpc.HitLeftAnkle, PhotonTargets.MasterClient, Extensions.GetPhotonView(transform.root.gameObject).viewID, damage);
                        }
                    }

                    break;
                }

                this.ShowCriticalHitFX(other.gameObject.transform.position);
            }
        }
    }