Beispiel #1
0
        public System.Collections.IEnumerator CoCastCurse(Vector3 mousePosition, ModdedPlayerClass Owner)
        {
            DateTime now        = DateTime.UtcNow;
            int      curseindex = 0;

            CurseObject?.Destroy();
            CurseObject = new GameObject();
            SpriteRenderer curseRender = CurseObject.AddComponent <SpriteRenderer>();
            Rigidbody2D    curseRigid  = CurseObject.AddComponent <Rigidbody2D>();

            CurseObject.SetActive(true);
            BoxCollider2D curseCollider = CurseObject.AddComponent <BoxCollider2D>();

            curseRender.enabled              = true;
            curseRigid.transform.position    = Owner._Object.myRend.bounds.center;
            curseRender.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;

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

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

                if (curseindex <= 5)
                {
                    curseRender.sprite = Assets.CurseSprite[0];
                }
                else
                {
                    curseRender.sprite = Assets.CurseSprite[1];
                }

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

                curseindex++;

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

                Vector2 oldVelocity = curseRigid.velocity;

                yield return(null);

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

                if (curseRigid.velocity != oldVelocity && Owner._Object.AmOwner)
                {
                    RpcDestroyCurse();
                    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(curseRender.bounds))
                    {
                        continue;
                    }

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

                    RpcDestroyCurse();

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

                    if (GetPlayerRoleName(ModdedPlayerById(player.PlayerId)) == "Harry")
                    {
                        RpcKillPlayer(Owner._Object, Owner._Object);
                    }
                    else
                    {
                        RpcKillPlayer(Owner._Object, player);
                    }

                    yield break;
                }

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

                RpcDestroyCurse();
                yield break;
            }
        }
Beispiel #2
0
 public void DestroyCurse()
 {
     CurseObject?.SetActive(false);
     CurseObject?.GetComponent <SpriteRenderer>().Destroy();
     CurseObject?.Destroy();
 }