예제 #1
0
 public void DestroyCrucio()
 {
     System.Console.WriteLine("Trying to destroy CrucioObject");
     CrucioObject?.SetActive(false);
     CrucioObject?.GetComponent <SpriteRenderer>().Destroy();
     CrucioObject?.Destroy();
 }
예제 #2
0
        public System.Collections.IEnumerator CoCastCrucio(Vector3 mousePosition, ModdedPlayerClass Owner)
        {
            DateTime now         = DateTime.UtcNow;
            int      crucioIndex = 0;

            CrucioObject?.Destroy();
            CrucioObject = new GameObject();
            SpriteRenderer crucioRender = CrucioObject.AddComponent <SpriteRenderer>();
            Rigidbody2D    crucioRigid  = CrucioObject.AddComponent <Rigidbody2D>();

            CrucioObject.SetActive(true);
            BoxCollider2D crucioCollider = CrucioObject.AddComponent <BoxCollider2D>();

            crucioRender.enabled              = true;
            crucioRigid.transform.position    = Owner._Object.myRend.bounds.center;
            crucioRender.transform.localScale = new Vector2(1f, 1f);

            Vector3 v        = mousePosition - Owner._Object.myRend.bounds.center;
            float   dist     = Vector2.Distance(mousePosition, Owner._Object.myRend.bounds.center);
            Vector3 d        = v * 3f * (2f / dist);
            float   AngleRad = Mathf.Atan2(mousePosition.y - Owner._Object.myRend.bounds.center.y, mousePosition.x - Owner._Object.myRend.bounds.center.x);
            float   AngleDeg = (180 / (float)Math.PI) * AngleRad;

            crucioCollider.autoTiling = false;
            crucioCollider.edgeRadius = 0;
            crucioCollider.size       = Owner._Object.Collider.bounds.size * 2;
            crucioRigid.velocity      = new Vector2(d.x, d.y);
            CrucioObject.layer        = 8;

            while (true)
            {
                if (CrucioObject == null)
                {
                    yield break;
                }

                if (crucioIndex <= 5)
                {
                    crucioRender.sprite = Assets.CrucioSprite[0];
                }
                else
                {
                    crucioRender.sprite = Assets.CrucioSprite[1];
                }

                if (crucioIndex >= 10)
                {
                    crucioIndex = 0;
                }

                crucioIndex++;

                crucioRigid.rotation     = AngleDeg;
                crucioRigid.drag         = 0;
                crucioRigid.angularDrag  = 0;
                crucioRigid.inertia      = 0;
                crucioRigid.gravityScale = 0;

                Vector2 oldVelocity = crucioRigid.velocity;

                yield return(null);

                if (CrucioObject == null)
                {
                    yield break;
                }

                if (crucioRigid.velocity != oldVelocity && Owner._Object.AmOwner)
                {
                    RpcDestroyCrucio();
                    yield break;
                }

                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.Data.IsDead || player.Data.Disconnected || Owner._Object == player || player.Data.IsImpostor)
                    {
                        continue;
                    }

                    if (!player.myRend.bounds.Intersects(crucioRender.bounds))
                    {
                        continue;
                    }

                    if (!Owner._Object.AmOwner)
                    {
                        yield break;
                    }

                    RpcDestroyCrucio();

                    if (ModdedPlayerById(player.PlayerId).Immortal)
                    {
                        yield break;
                    }

                    RpcCrucioBlind(player);
                    yield break;
                }

                if (now.AddSeconds(5) >= DateTime.UtcNow && !MeetingHud.Instance && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started)
                {
                    continue;
                }

                RpcDestroyCrucio();
                yield break;
            }
        }