Esempio n. 1
0
        public void createManualCrosshairForController(PlayerController playerOwner)
        {
            if (BraveInput.GetInstanceForPlayer(playerOwner.PlayerIDX).IsKeyboardAndMouse(false))
            {
                Debug.LogError("Clicker: Attempted to create a crosshair for a user playing on keyboard and mouse.");
                return;
            }
            GameObject newSprite = new GameObject("Controller_Crosshair", new Type[] { typeof(tk2dSprite) })
            {
                layer = 0
            };

            newSprite.transform.position = (playerOwner.transform.position + new Vector3(0.5f, 2));
            tk2dSprite m_ItemSprite = newSprite.AddComponent <tk2dSprite>();

            m_ItemSprite.SetSprite(clickerCollection, crosshairSpriteID);
            m_ItemSprite.PlaceAtPositionByAnchor(newSprite.transform.position, tk2dBaseSprite.Anchor.MiddleCenter);
            m_ItemSprite.transform.localPosition = m_ItemSprite.transform.localPosition.Quantize(0.0625f);

            if (m_ItemSprite)
            {
                playerOwner.sprite.AttachRenderer(m_ItemSprite);
                m_ItemSprite.depthUsesTrimmedBounds = true;
                m_ItemSprite.UpdateZDepth();
            }
            m_extantReticleQuad = m_ItemSprite;
        }
        private void Update()
        {
            BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(player.PlayerIDX);

            if (instanceForPlayer.GetButtonDown(GungeonActions.GungeonActionType.DodgeRoll))
            {
                instanceForPlayer.ConsumeButtonDown(GungeonActions.GungeonActionType.DodgeRoll);
                Vector2 vector = Vector2.zero;
                if (player.CurrentInputState != PlayerInputState.NoMovement)
                {
                    vector = this.AdjustInputVector(instanceForPlayer.ActiveActions.Move.Vector, BraveInput.MagnetAngles.movementCardinal, BraveInput.MagnetAngles.movementOrdinal);
                }
                if (vector.magnitude > 1f)
                {
                    vector.Normalize();
                }
                if (!m_isJumping)
                {
                    player.StartCoroutine(this.Jump(vector));
                }
            }
            if (player.IsOnFire)
            {
                if (this.IsJumping)
                {
                    player.IncreaseFire(-(BraveTime.DeltaTime * 0.466666f));
                }
            }
        }
        private void UpdateReticlePosition()
        {
            PlayerController user = this.gun.GunPlayerOwner();

            if (user)
            {
                if (BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false))
                {
                    Vector2 vector  = user.unadjustedAimPoint.XY();
                    Vector2 vector2 = vector - this.m_extantReticleQuad.GetBounds().extents.XY();
                    this.m_extantReticleQuad.transform.position = vector2;
                }
                else
                {
                    BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(user.PlayerIDX);
                    Vector2    vector3           = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    vector3               += instanceForPlayer.ActiveActions.Aim.Vector * 12f * BraveTime.DeltaTime;
                    this.m_currentAngle    = BraveMathCollege.Atan2Degrees(vector3 - user.CenterPosition);
                    this.m_currentDistance = Vector2.Distance(vector3, user.CenterPosition);
                    this.m_currentDistance = Mathf.Min(this.m_currentDistance, 100);
                    vector3                = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    Vector2 vector4 = vector3 - this.m_extantReticleQuad.GetBounds().extents.XY();
                    this.m_extantReticleQuad.transform.position = vector4;
                }
            }
        }
Esempio n. 4
0
 private void HandleForceToPosition()
 {
     if (owner)
     {
         if (BraveInput.GetInstanceForPlayer(owner.PlayerIDX).IsKeyboardAndMouse(false))
         {
             Vector2 vec = owner.GetCursorPosition(1);
             vec += new Vector2(0, 0.56f);
             m_projectile.specRigidbody.Position = new Position(vec);
             m_projectile.specRigidbody.UpdateColliderPositions();
         }
         else
         {
             if (m_projectile.PossibleSourceGun != null && m_projectile.PossibleSourceGun.GetComponent <Clicker>() != null)
             {
                 Clicker sourceclicker = m_projectile.PossibleSourceGun.GetComponent <Clicker>();
                 if (sourceclicker.m_extantReticleQuad != null)
                 {
                     Vector2 pos = sourceclicker.m_extantReticleQuad.WorldCenter;
                     m_projectile.specRigidbody.Position = new Position(pos);
                     m_projectile.specRigidbody.UpdateColliderPositions();
                 }
             }
             else
             {
                 m_projectile.specRigidbody.Position = new Position(owner.GetCursorPosition(UnityEngine.Random.Range(5f, 10f)));
                 m_projectile.specRigidbody.UpdateColliderPositions();
             }
         }
     }
 }
 private static void Update()
 {
     //Doesnt quite work yet. so its your challenge to get it to work =)
     if (ModMenu.teleportHax && Input.GetMouseButtonDown(1))
     {
         Vector2 mousePosition = BraveInput.GetInstanceForPlayer(0).MousePosition;
         Vector3 position      = Camera.main.ScreenToWorldPoint(mousePosition);
         if (GameManager.Instance.PrimaryPlayer)
         {
             GameManager.Instance.PrimaryPlayer.transform.position = position;
         }
     }
     if (ModMenu.addAmmoAutomatically)
     {
         int num = GameManager.Instance.PrimaryPlayer.CurrentGun.AdjustedMaxAmmo / 2;
         if (GameManager.Instance.PrimaryPlayer.CurrentGun.CurrentAmmo <= num)
         {
             GameManager.Instance.PrimaryPlayer.CurrentGun.GainAmmo(10000);
         }
     }
     if (ModMenu.autoHeal)
     {
         for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
         {
             float num2 = GameManager.Instance.AllPlayers[i].healthHaver.GetMaxHealth() / 2f;
             if (GameManager.Instance.AllPlayers[i].healthHaver.IsAlive && GameManager.Instance.AllPlayers[i].healthHaver.GetCurrentHealth() <= num2)
             {
                 GameManager.Instance.AllPlayers[i].healthHaver.FullHeal();
             }
         }
     }
 }
Esempio n. 6
0
            public Vector2 GetAimPoint(PlayerController player)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(player.PlayerIDX);
                bool       flag2             = instanceForPlayer == null;
                Vector2    a = Vector2.zero;

                if (!flag2)
                {
                    bool flag3 = instanceForPlayer.IsKeyboardAndMouse(false);
                    if (flag3)
                    {
                        a = player.unadjustedAimPoint.XY() - (base.transform.position.XY() + base.sprite.GetRelativePositionFromAnchor(tk2dBaseSprite.Anchor.MiddleLeft).Rotate(base.transform.eulerAngles.z));
                    }
                    else
                    {
                        bool flag4 = instanceForPlayer.ActiveActions == null;
                        if (flag4)
                        {
                            return(a);
                        }
                        a = instanceForPlayer.ActiveActions.Aim.Vector;
                    }
                }
                return(a);
            }
Esempio n. 7
0
        protected override void DoActiveEffect(PlayerController user)
        {
            base.DoActiveEffect(user);
            if (user.healthHaver != null)
            {
                user.healthHaver.TriggerInvulnerabilityPeriod(0.5f);
            }
            this.m_currentlyHeldEnemy.Dismount();
            AIActor       aiActor       = this.m_currentlyHeldEnemy;
            KnockbackDoer knockbackDoer = aiActor.knockbackDoer;

            if (aiActor)
            {
                if (aiActor.specRigidbody != null)
                {
                    aiActor.specRigidbody.AddCollisionLayerOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox));
                    aiActor.specRigidbody.OnPreRigidbodyCollision += new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.HandleHitEnemyHitEnemy);
                    aiActor.specRigidbody.OnPreTileCollision      += new SpeculativeRigidbody.OnPreTileCollisionDelegate(this.HandleHitTile);
                }
            }
            if (knockbackDoer)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(GameManager.Instance.PrimaryPlayer.PlayerIDX);
                bool       flag2             = instanceForPlayer == null;
                if (!flag2)
                {
                    Vector2 vector    = GameManager.Instance.PrimaryPlayer.unadjustedAimPoint.XY() - user.CenterPosition;
                    Vector2 direction = BraveMathCollege.DegreesToVector(BraveMathCollege.Atan2Degrees(vector), 1);
                    knockbackDoer.ApplyKnockback(direction, 800f, true);
                }
            }
            this.m_currentlyHeldEnemy = null;
        }
Esempio n. 8
0
        protected override void DoEffect(PlayerController user)
        {
            Projectile proj = ((Gun)ETGMod.Databases.Items["burning_hand"]).DefaultModule.projectiles[0];
            BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(this.LastOwner.PlayerIDX);
            bool       flag2             = instanceForPlayer == null;
            float      z = 0;

            if (!flag2)
            {
                bool    flag3 = instanceForPlayer.IsKeyboardAndMouse(false);
                Vector2 a;
                if (flag3)
                {
                    a = this.LastOwner.unadjustedAimPoint.XY() - base.sprite.WorldCenter;
                }
                else
                {
                    bool flag4 = instanceForPlayer.ActiveActions == null;
                    if (flag4)
                    {
                        return;
                    }
                    a = instanceForPlayer.ActiveActions.Aim.Vector;
                }
                a.Normalize();
                z = BraveMathCollege.Atan2Degrees(a);
            }
            GameObject obj       = SpawnManager.SpawnProjectile(proj.gameObject, user.sprite.WorldCenter, Quaternion.Euler(0, 0, z));
            Projectile component = obj.GetComponent <Projectile>();

            if (component != null)
            {
                component.Owner           = user;
                component.Shooter         = user.specRigidbody;
                component.AppliesFire     = false;
                component.FireApplyChance = 0f;
                component.baseData.damage = 20f;
                if (UnityEngine.Random.value < 0.26f)
                {
                    component.damageTypes = CoreDamageTypes.Void;
                    component.AdditionalScaleMultiplier *= 2f;
                    component.baseData.speed            *= 2f;
                    component.DefaultTintColor           = Color.black;
                    component.HasDefaultTint             = true;
                }
                else
                {
                    component.damageTypes      = CoreDamageTypes.None;
                    component.DefaultTintColor = Color.white;
                    component.HasDefaultTint   = true;
                }
                PierceProjModifier component2 = component.GetComponent <PierceProjModifier>();
                if (component2 != null)
                {
                    component2.penetratesBreakables = true;
                }
            }
            this.usesLeft -= 1;
        }
        private IEnumerator HandleConversation(PlayerController interactor)
        {
            SpriteOutlineManager.AddOutlineToSprite(base.sprite, Color.black);
            base.spriteAnimator.PlayForDuration("talk_start", 1, "talk");
            interactor.SetInputOverride("npcConversation");
            Pixelator.Instance.LerpToLetterbox(0.35f, 0.25f);
            yield return(null);

            int conversationIndex = m_allowMeToIntroduceMyself ? 0 : conversation.Count - 1;

            while (conversationIndex < conversation.Count - 1)
            {
                Tools.Print($"Index: {conversationIndex}");
                TextBoxManager.ClearTextBox(this.talkPoint);
                TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, -1f, conversation[conversationIndex], interactor.characterAudioSpeechTag, instant: false, showContinueText: true);
                float timer = 0;
                while (!BraveInput.GetInstanceForPlayer(interactor.PlayerIDX).ActiveActions.GetActionFromType(GungeonActions.GungeonActionType.Interact).WasPressed || timer < 0.4f)
                {
                    timer += BraveTime.DeltaTime;
                    yield return(null);
                }
                conversationIndex++;
            }
            m_allowMeToIntroduceMyself = false;
            TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, -1f, conversation[conversation.Count - 1], interactor.characterAudioSpeechTag, instant: false, showContinueText: true);

            GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, null, acceptText, declineText);
            int selectedResponse = -1;

            while (!GameUIRoot.Instance.GetPlayerConversationResponse(out selectedResponse))
            {
                yield return(null);
            }

            if (selectedResponse == 0)
            {
                TextBoxManager.ClearTextBox(this.talkPoint);
                base.spriteAnimator.PlayForDuration("do_effect", -1, "talk");

                while (base.spriteAnimator.CurrentFrame < 20) //play do effect anim
                {
                    yield return(null);
                }
                OnAccept?.Invoke(interactor, this.gameObject);
                base.spriteAnimator.Play("talk");
                TextBoxManager.ShowTextBox(this.talkPoint.position, this.talkPoint, 1f, "Bam!", interactor.characterAudioSpeechTag, instant: false);
                yield return(new WaitForSeconds(1f));
            }
            else
            {
                OnDecline?.Invoke(interactor, this.gameObject);
                TextBoxManager.ClearTextBox(this.talkPoint);
            }

            // Free player and run OnAccept/OnDecline actions
            interactor.ClearInputOverride("npcConversation");
            Pixelator.Instance.LerpToLetterbox(1, 0.25f);
            base.spriteAnimator.Play("idle");
        }
Esempio n. 10
0
            static void Postfix(PlayerController __instance)
            {
                if (__instance.AcceptingNonMotionInput)
                {
                    BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(__instance.PlayerIDX);
                    bool       isKeyboard        = instanceForPlayer.IsKeyboardAndMouse(false);
                    if (isKeyboard)
                    {
                        if (Input.GetKeyDown(KeyCode.H))
                        {
                            util.ToggleHealthBars();
                            logger.LogInfo($"Toggled health bars to {util.healthBars}");
                        }
                        if (Input.GetKeyDown(KeyCode.Z))
                        {
                            util.ToggleAutoBlank();
                            logger.LogInfo($"Toggled auto blank to {util.autoBlank}");
                        }

                        if (Input.GetKeyDown(KeyCode.G))
                        {
                            SilencerInstance.DestroyBulletsInRange(GameManager.Instance.PrimaryPlayer.CenterPosition, 10000, true, true);
                        }
                        if (Input.GetKeyDown(KeyCode.I))
                        {
                            ReadFiles();
                        }
                        if (Input.GetKeyDown(KeyCode.U))
                        {
                            SpawnItems();
                        }

                        if (Input.GetKeyDown(KeyCode.O))
                        {
                            BraveTime.RegisterTimeScaleMultiplier(0.5f, __instance.gameObject);
                            logger.LogInfo($"Applied time multiplier");
                        }

                        if (Input.GetKeyDown(KeyCode.P))
                        {
                            BraveTime.ClearMultiplier(__instance.gameObject);
                            logger.LogInfo($"Cleared time multiplier");
                        }

                        if (Input.GetKeyDown(KeyCode.K))
                        {
                            configGodModeEnabled.Value = !configGodModeEnabled.Value;
                            logger.LogInfo($"Toggled godmode to {configGodModeEnabled.Value}");
                        }

                        if (Input.GetKeyDown(KeyCode.J))
                        {
                            configInfiniteAmmoEnabled.Value = !configInfiniteAmmoEnabled.Value;
                            logger.LogInfo($"Toggled infinite ammo to {configInfiniteAmmoEnabled.Value}");
                        }
                    }
                }
            }
Esempio n. 11
0
        protected override void Update()
        {
            base.Update();
            if (this.charges > this.chargesMax)
            {
                this.charges = this.chargesMax;
            }
            this.gun.idleAnimation = this.gun.UpdateAnimation("idle" + ((this.charges > 0) ? this.charges.ToString() : ""), null, false);
            this.gun.PlayIdleAnimation();
            bool isFocusing = false;

            if (this.Player != null)
            {
                BraveInput input = BraveInput.GetInstanceForPlayer(this.Player.PlayerIDX);
                if (input != null && input.ActiveActions != null)
                {
                    InControl.PlayerAction action = input.ActiveActions.ReloadAction;
                    if (action.IsPressed)
                    {
                        if (this.charges >= 3)
                        {
                            reloadHoldTime += BraveTime.DeltaTime;
                            if (reloadHoldTime >= 1.5f)
                            {
                                reloadHoldTime = 0f;
                                this.Owner.healthHaver.ApplyHealing(0.5f);
                                this.Owner.PlayEffectOnActor(ResourceCache.Acquire("Global VFX/VFX_Healing_Sparkles_001") as GameObject, Vector3.zero, true, false, false);
                                AkSoundEngine.PostEvent("Play_OBJ_heart_heal_01", base.gameObject);
                                this.charges -= 3;
                                Toolbox.GetGunById(417).DefaultModule.projectiles[0].hitEffects.HandleEnemyImpact(this.gun.sprite.WorldCenter, 0f, this.gun.transform, Vector3.zero, Vector2.zero, false, false);
                            }
                            else if (reloadHoldTime >= 0.5f)
                            {
                                this.Owner.PlayEffectOnActor(SoulFocusVFX, new Vector3(0f, -0.5f, 0f), true, false, false);
                            }
                            if (reloadHoldTime >= 0.1f)
                            {
                                isFocusing = true;
                            }
                        }
                    }
                    if (!action.IsPressed && actionWasPressed)
                    {
                        if (reloadHoldTime <= 0.1f)
                        {
                            //Do stuff.
                        }
                        reloadHoldTime = 0f;
                    }
                    this.actionWasPressed = action.IsPressed;
                }
            }
            if (this.cooldownTimer > 0f)
            {
                this.cooldownTimer -= BraveTime.DeltaTime;
            }
            this.gun.RuntimeModuleData[this.gun.DefaultModule].onCooldown = this.cooldownTimer > 0 || isFocusing || charges < 3;
        }
        private IEnumerator TalkRaw(string plaintext, Vector3 DialogBoxOffset)
        {
            TextBoxManager.ShowTextBox(transform.position + DialogBoxOffset, transform, 5f, plaintext, "playermimicboss", false, TextBoxManager.BoxSlideOrientation.NO_ADJUSTMENT, false, false);
            bool advancedPressed = false;

            while (!advancedPressed)
            {
                advancedPressed = (BraveInput.GetInstanceForPlayer(0).WasAdvanceDialoguePressed() || BraveInput.GetInstanceForPlayer(1).WasAdvanceDialoguePressed());
                yield return(null);
            }
            TextBoxManager.ClearTextBox(transform);
            yield break;
        }
Esempio n. 13
0
        private static void PreMoveProjectileModifier(Projectile p)
        {
            PlayerController player = this_gun.CurrentOwner as PlayerController;

            if (player && p && p.Owner is PlayerController)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(player.PlayerIDX);
                if (instanceForPlayer == null)
                {
                    return;
                }
                Vector2 vector = Vector2.zero;
                if (instanceForPlayer.IsKeyboardAndMouse(false))
                {
                    vector = (p.Owner as PlayerController).unadjustedAimPoint.XY() - p.specRigidbody.UnitCenter;
                }
                else
                {
                    if (instanceForPlayer.ActiveActions == null)
                    {
                        return;
                    }
                    vector = instanceForPlayer.ActiveActions.Aim.Vector;
                }
                float target  = vector.ToAngle();
                float current = BraveMathCollege.Atan2Degrees(p.Direction);
                float num     = 0f;
                if (p.ElapsedTime < trackingTime)
                {
                    num = trackingCurve.Evaluate(p.ElapsedTime / trackingTime) * trackingSpeed;
                }
                float   target2 = Mathf.MoveTowardsAngle(current, target, num * BraveTime.DeltaTime);
                Vector2 vector2 = Quaternion.Euler(0f, 0f, Mathf.DeltaAngle(current, target2)) * p.Direction;
                if (p is HelixProjectile)
                {
                    HelixProjectile helixProjectile = p as HelixProjectile;
                    helixProjectile.AdjustRightVector(Mathf.DeltaAngle(current, target2));
                }
                if (p.OverrideMotionModule != null)
                {
                    p.OverrideMotionModule.AdjustRightVector(Mathf.DeltaAngle(current, target2));
                }
                p.Direction = vector2.normalized;
                if (p.shouldRotate)
                {
                    p.transform.eulerAngles = new Vector3(0f, 0f, p.Direction.ToAngle());
                }
            }
        }
        void Update()
        {
            if (!this.gun.PreventNormalFireAudio) // Make it so the gun doesn't make any regular sound
            {
                this.gun.PreventNormalFireAudio = true;
            }

            // This happens if the player has the gun held.
            if (gun.CurrentOwner is PlayerController owner)
            {
                // If the player has the Hyperspeed Swing synergy, set their gun's fps to 30. Otherwise set it back to 20
                bool hasSynergy = owner.PlayerHasActiveSynergy("Hyperspeed Swing");
                int  fps        = (int)gun.spriteAnimator.GetClipByName(gun.shootAnimation).fps;
                if (fps == 20 && hasSynergy)
                {
                    GunExt.SetAnimationFPS(gun, 30);
                }
                else if (fps == 30 && !hasSynergy)
                {
                    GunExt.SetAnimationFPS(gun, 20);
                }

                // This section checks to see if the shoot button was pressed, and if it was, sets the clicked variable to true
                var input = BraveInput.GetInstanceForPlayer(owner.PlayerIDX);
                if (input.ActiveActions.ShootAction.State == true && input.ActiveActions.ShootAction.LastState == false)
                {
                    clicked = true;
                }
                if (gun.IsReloading) // If the gun is reloading (aka just combo killed an enemy), set clicked to false so the shooting animation stops
                {
                    clicked = false;
                }

                // This code checks to see if an enemy is targeted, and if it is, give it a bright white outline.
                if (highlightedEnemy != null)
                {
                    Material outlineMaterial = SpriteOutlineManager.GetOutlineMaterial(highlightedEnemy.sprite);
                    if (outlineMaterial != null)
                    {
                        outlineMaterial.SetColor("_OverrideColor", new Color(60f, 60f, 60f));
                    }
                }
            }
            else
            {
                DeselectEnemy(); // If the gun isn't held by the player, deselect an enemy if one is selected.
            }
        }
        protected override void DoEffect(PlayerController user)
        {
            if (this.m_isDashing)
            {
                return;
            }
            Vector2 dashDirection = BraveInput.GetInstanceForPlayer(user.PlayerIDX).ActiveActions.Move.Vector;

            if (dashDirection.x == 0 && dashDirection.y == 0)
            {
                return;
            }
            AkSoundEngine.PostEvent("Play_CHR_ninja_dash_01", base.gameObject);
            this.m_useCount++;
            base.StartCoroutine(this.HandleDash(user, dashDirection));
        }
        public IEnumerator direction(Projectile bullet)
        {
            if (bullet != null)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(this.Owner.PlayerIDX);
                if (instanceForPlayer != null)
                {
                    if (instanceForPlayer.IsKeyboardAndMouse() == false)
                    {
                        Projectile         projectile2 = bullet;
                        GameObject         gameObject  = SpawnManager.SpawnProjectile(projectile2.gameObject, this.Owner.CurrentGun.sprite.WorldCenter, Quaternion.Euler(0f, 0f, (this.Owner.CurrentGun == null) ? 0f : this.Owner.CurrentGun.CurrentAngle), true);
                        Projectile         component   = gameObject.GetComponent <Projectile>();
                        PierceProjModifier peirce      = gameObject.GetOrAddComponent <PierceProjModifier>();
                        peirce.penetration = 90;
                        bool flag = component != null;
                        if (flag)
                        {
                            component.Owner                     = this.Owner;
                            component.Shooter                   = this.Owner.specRigidbody;
                            component.baseData.damage           = 0f;
                            component.baseData.speed           *= 1.8f;
                            component.AdditionalScaleMultiplier = .0001f;
                        }

                        yield return(new WaitForSecondsRealtime(.25f));

                        if (bullet.gameObject != null)
                        {
                            Vector2 vector = bullet.sprite.WorldCenter;
                            Vector2 Aim    = component.sprite.WorldCenter;
                            bullet.SendInDirection(Aim - vector, false, true);
                        }
                    }
                    else
                    {
                        yield return(new WaitForSecondsRealtime(.25f));

                        if (bullet != null)
                        {
                            Vector2 vector = bullet.sprite.WorldCenter;
                            Vector2 Aim    = this.Owner.unadjustedAimPoint;
                            bullet.SendInDirection(Aim - vector, false, true);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
            void FixedUpdate()
            {
                if (owner == null)
                {
                    return;
                }
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(this.owner.PlayerIDX);
                Vector2    vector;

                if (instanceForPlayer == null)
                {
                    return;
                }

                if (instanceForPlayer.IsKeyboardAndMouse(false))
                {
                    vector = owner.unadjustedAimPoint.XY() - this.sprite.WorldCenter;
                }
                else
                {
                    if (instanceForPlayer.ActiveActions == null)
                    {
                        return;
                    }
                    vector = instanceForPlayer.ActiveActions.Aim.Vector;
                }

                vector.Normalize();
                float speed = (owner.HasMTGConsoleID("remote_bullets") || owner.HasMTGConsoleID("3rd_party_controller")) ? droneMoveSpeed * 2f : droneMoveSpeed;

                if (Vector2.Distance(owner.unadjustedAimPoint.XY(), this.sprite.WorldCenter) < .2f)
                {
                    velocity = Vector2.Lerp(velocity, Vector2.zero, .5f);
                }
                else
                {
                    velocity = Vector2.Lerp(velocity, vector * speed, .1f);
                }
                specRigidbody.Velocity = velocity;

                string clip = GetAnimationDirection(velocity);

                if (clip != spriteAnimator.CurrentClip.name)
                {
                    spriteAnimator.Play(clip);
                }
            }
Esempio n. 18
0
 public static void InvokerHook(Action <Invoker, PlayerController> orig, Invoker self, PlayerController user)
 {
     if (user.HasPickupID(203))
     {
         self.damageCooldown = 200;
     }
     else
     {
         self.damageCooldown = 400;
     }
     orig(self, user);
     if (user.HasPickupID(203))
     {
         Projectile proj = (PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0];
         BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(user.PlayerIDX);
         bool       flag2             = instanceForPlayer == null;
         float      z = 0;
         if (!flag2)
         {
             bool    flag3 = instanceForPlayer.IsKeyboardAndMouse(false);
             Vector2 a;
             if (flag3)
             {
                 a = user.unadjustedAimPoint.XY() - self.sprite.WorldCenter;
             }
             else
             {
                 bool flag4 = instanceForPlayer.ActiveActions == null;
                 if (flag4)
                 {
                     return;
                 }
                 a = instanceForPlayer.ActiveActions.Aim.Vector;
             }
             a.Normalize();
             z = BraveMathCollege.Atan2Degrees(a);
         }
         GameObject obj   = SpawnManager.SpawnProjectile(proj.gameObject, user.sprite.WorldCenter, Quaternion.Euler(0, 0, z));
         Projectile proj2 = obj.GetComponent <Projectile>();
         if (proj2 != null)
         {
             proj2.Owner            = user;
             proj2.Shooter          = user.specRigidbody;
             proj2.baseData.damage *= ((user.stats.GetStatValue(PlayerStats.StatType.Coolness) / 2) + 1);
         }
     }
 }
Esempio n. 19
0
        // Token: 0x0600001B RID: 27 RVA: 0x00003110 File Offset: 0x00001310
        private void UpdateAimTargetPosition()
        {
            PlayerController playerController  = this.owner;
            BraveInput       instanceForPlayer = BraveInput.GetInstanceForPlayer(playerController.PlayerIDX);
            GungeonActions   activeActions     = instanceForPlayer.ActiveActions;
            Vector3          position          = this.m_aiActor.CenterPosition + BraveMathCollege.DegreesToVector(this.owner.FacingDirection, 1f) * 5f;
            bool             flag = instanceForPlayer.IsKeyboardAndMouse(false);

            if (flag)
            {
                this.m_fakeTargetRigidbody.transform.position = position;
            }
            else
            {
                this.m_fakeTargetRigidbody.transform.position = position;
            }
            this.m_fakeTargetRigidbody.Reinitialize();
        }
Esempio n. 20
0
        protected override void DoEffect(PlayerController user)
        {
            this.thrown = true;
            BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(this.LastOwner.PlayerIDX);
            bool       flag2             = instanceForPlayer == null;
            float      z = 0;

            if (!flag2)
            {
                bool    flag3 = instanceForPlayer.IsKeyboardAndMouse(false);
                Vector2 a;
                if (flag3)
                {
                    a = this.LastOwner.unadjustedAimPoint.XY() - base.sprite.WorldCenter;
                }
                else
                {
                    bool flag4 = instanceForPlayer.ActiveActions == null;
                    if (flag4)
                    {
                        return;
                    }
                    a = instanceForPlayer.ActiveActions.Aim.Vector;
                }
                a.Normalize();
                z = BraveMathCollege.Atan2Degrees(a);
            }
            GameObject obj  = SpawnManager.SpawnProjectile((PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0].gameObject, user.sprite.WorldCenter, Quaternion.Euler(0, 0, z));
            Projectile proj = obj.GetComponent <Projectile>();

            if (proj != null)
            {
                proj.Owner           = user;
                proj.Shooter         = user.specRigidbody;
                proj.baseData.damage = 0;
                proj.baseData.force  = 0;
                CatchProjectileBehaviour pokemonBehaviour = proj.gameObject.AddComponent <CatchProjectileBehaviour>();
                pokemonBehaviour.thrower             = user;
                pokemonBehaviour.parentItem          = this;
                pokemonBehaviour.hasEvolutionSynergy = user.PlayerHasActiveSynergy("#GEN_2");
            }
        }
Esempio n. 21
0
 private void Update()
 {
     if (this.user != null && Time.frameCount % 10 == 0 && this.proj)
     {
         GungeonActions m_activeActions    = Stuff.ReflectGetField <GungeonActions>(typeof(PlayerController), "m_activeActions", this.user);
         bool           IsKeyboardAndMouse = BraveInput.GetInstanceForPlayer(this.user.PlayerIDX).IsKeyboardAndMouse(false);
         if (IsKeyboardAndMouse)
         {
             this.spawnpos = this.user.unadjustedAimPoint.XY() - (this.user.CenterPosition - this.user.specRigidbody.UnitCenter);
         }
         else
         {
             if (m_activeActions != null)
             {
                 spawnpos = m_activeActions.Aim.Vector;
             }
         }
         this.proj.SendInDirection(spawnpos - this.proj.specRigidbody.UnitCenter, true);
         this.proj.shouldRotate = false;
     }
 }
        public override void OnPostFired(PlayerController player, Gun gun)
        {
            //This determines what sound you want to play when you fire a gun.
            //Sounds names are based on the Gungeon sound dump, which can be found at EnterTheGungeon/Etg_Data/StreamingAssets/Audio/GeneratedSoundBanks/Windows/sfx.txt
            gun.PreventNormalFireAudio = false;

            BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(player.PlayerIDX);

            if (instanceForPlayer.IsKeyboardAndMouse() == false)
            {
                // special controls for controller
                StartCoroutine(nytraPlacerCtrl(player));
            }
            else
            {
                // standard controls for keyboard
                nytraPlacer(player);
            }

            AkSoundEngine.PostEvent("Play_BOSS_FuseBomb_Attack_Toys_01", base.gameObject);
        }
Esempio n. 23
0
        public static Vector2 GetCursorPosition(this PlayerController user, float noCursorControllerRange)
        {
            Vector2 m_cachedBlinkPosition = Vector2.zero;

            GungeonActions m_activeActions = OMITBReflectionHelpers.ReflectGetField <GungeonActions>(typeof(PlayerController), "m_activeActions", user);

            bool IsKeyboardAndMouse = BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false);

            if (IsKeyboardAndMouse)
            {
                m_cachedBlinkPosition = user.unadjustedAimPoint.XY() - (user.CenterPosition - user.specRigidbody.UnitCenter);
            }
            else
            {
                m_cachedBlinkPosition = user.PositionInDistanceFromAimDir(5);
                //if (m_activeActions != null) { m_cachedBlinkPosition += m_activeActions.Aim.Vector.normalized * BraveTime.DeltaTime * 15f; }
            }

            m_cachedBlinkPosition = BraveMathCollege.ClampToBounds(m_cachedBlinkPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint);
            return(m_cachedBlinkPosition);
        }
Esempio n. 24
0
 public override void Update()
 {
     base.Update();
     if (this.m_pickedUp && this.m_isCurrentlyActive && this.LastOwner != null)
     {
         BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(this.LastOwner.PlayerIDX);
         bool       flag2             = instanceForPlayer == null;
         if (!flag2)
         {
             for (int i = 0; i < 3; i++)
             {
                 float z = 0f;
                 if (i == 1f)
                 {
                     z = 5f;
                 }
                 else if (i == 2f)
                 {
                     z = -5f;
                 }
                 GameObject obj = SpawnManager.SpawnVFX((PickupObjectDatabase.GetById(384) as Gun).muzzleFlashEffects.effects[0].effects[0].effect, this.LastOwner.CenterPosition, Quaternion.Euler(0f, 0f,
                                                                                                                                                                                                    BraveMathCollege.Atan2Degrees(this.LastOwner.unadjustedAimPoint.XY() - this.LastOwner.CenterPosition) + z));
                 obj.transform.localScale = new Vector3(2.4f, 0.5f, 0);
                 obj.transform.parent     = this.LastOwner.transform;
                 SpeculativeRigidbody hitRigidbody = this.IterativeRaycast(this.LastOwner.CenterPosition, BraveMathCollege.DegreesToVector(BraveMathCollege.Atan2Degrees(this.LastOwner.unadjustedAimPoint.XY() - this.LastOwner.CenterPosition) + z),
                                                                           11.2f, int.MaxValue, this.LastOwner.specRigidbody);
                 if (hitRigidbody && hitRigidbody.aiActor && hitRigidbody.aiActor.IsNormalEnemy)
                 {
                     hitRigidbody.aiActor.ApplyEffect((PickupObjectDatabase.GetById(295) as BulletStatusEffectItem).FireModifierEffect, 1, null);
                 }
             }
             this.LastOwner.IsGunLocked = true;
         }
         if (this.LastOwner.IsDodgeRolling)
         {
             this.DoActiveEffect(this.LastOwner);
         }
     }
 }
 protected override void Update()
 {
     if (gun.CurrentOwner)
     {
         if (!gun.PreventNormalFireAudio)
         {
             this.gun.PreventNormalFireAudio = true;
         }
         if (!gun.IsReloading && !HasReloaded)
         {
             this.HasReloaded = true;
         }
         PlayerController player            = (PlayerController)this.gun.CurrentOwner;
         BraveInput       instanceForPlayer = BraveInput.GetInstanceForPlayer(player.PlayerIDX);
         if (jammed && gun.ClipShotsRemaining == gun.ClipCapacity && instanceForPlayer.GetButtonDown(GungeonActions.GungeonActionType.Shoot))
         {
             this.gun.ClearCooldowns();
             this.gun.reloadTime = .7f;
             this.gun.DefaultModule.cooldownTime = .17f;
             jammed = false;
         }
     }
 }
Esempio n. 26
0
        private void Start()
        {
            this.m_projectile = base.GetComponent <Projectile>();
            if (m_projectile.Owner is PlayerController)
            {
                this.owner = m_projectile.Owner as PlayerController;
            }
            if (owner)
            {
                if (!BraveInput.GetInstanceForPlayer(owner.PlayerIDX).IsKeyboardAndMouse(false))
                {
                    m_projectile.baseData.damage *= 2;
                    m_projectile.RuntimeUpdateScale(1.5f);
                }
                if (owner.PlayerHasActiveSynergy("One Click Away!"))
                {
                    m_projectile.RuntimeUpdateScale(1.5f);
                }
            }
            HandleForceToPosition();

            StartCoroutine(HandleClickDeath());
        }
Esempio n. 27
0
        private void LateUpdate()
        {
            if (Application.isPlaying)
            {
                BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(GameManager.Instance.PrimaryPlayer.PlayerIDX);
                bool       flag2             = instanceForPlayer == null;
                if (!flag2)
                {
                    Vector2 vector = GameManager.Instance.PrimaryPlayer.unadjustedAimPoint.XY() - base.transform.position.XY();
                    float   d      = Mathf.Lerp(0f, (this.MaxPupilRadius * this.scale), vector.magnitude / 7f);
                    this.poopil.transform.localPosition = d * vector.normalized;
                }
            }
            this.baseSprite.scale = new Vector3(this.scale, this.scale, this.scale);
            float x  = this.baseSprite.GetBounds().extents.x;
            float x2 = this.poopil.GetComponent <tk2dSprite>().GetBounds().extents.x;

            for (int i = 0; i < this.layers.Length; i++)
            {
                if (this.layers[i].sprite == null)
                {
                    this.layers[i].sprite = this.layers[i].xform.GetComponent <tk2dSprite>();
                }
                float x3   = this.layers[i].sprite.GetBounds().extents.x;
                float num  = 1f - x3 / x;
                float num2 = (float)i / ((float)this.layers.Length - 1f);
                num = Mathf.Pow(num, Mathf.Lerp(0.75f, 1f, 1f - num2));
                float d2 = this.poopil.localPosition.magnitude / (x - x2);
                this.layers[i].xform.localPosition    = this.poopil.localPosition * num + this.poopil.localPosition.normalized * x2 * d2 * num;
                this.layers[i].sprite.HeightOffGround = ((float)i * 0.1f + 0.1f);
                this.layers[i].sprite.UpdateZDepth();
                this.layers[i].sprite.scale = new Vector3(this.scale, this.scale, this.scale);
            }
            this.poopil.GetComponent <tk2dSprite>().HeightOffGround = 1f;
            this.poopil.GetComponent <tk2dSprite>().UpdateZDepth();
            this.poopil.GetComponent <tk2dSprite>().scale = new Vector3(this.scale, this.scale, this.scale);
        }
Esempio n. 28
0
        private void UpdateReticlePosition()
        {
            PlayerController user = this.gun.GunPlayerOwner();

            if (user)
            {
                if (BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false))
                {
                    Debug.LogError("Clicker: Attempted to update a crosshair for a user playing on keyboard and mouse???");
                }
                else
                {
                    BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(user.PlayerIDX);
                    Vector2    vector3           = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    vector3               += instanceForPlayer.ActiveActions.Aim.Vector * 12f * BraveTime.DeltaTime;
                    this.m_currentAngle    = BraveMathCollege.Atan2Degrees(vector3 - user.CenterPosition);
                    this.m_currentDistance = Vector2.Distance(vector3, user.CenterPosition);
                    this.m_currentDistance = Mathf.Min(this.m_currentDistance, 100);
                    vector3                = user.CenterPosition + (Quaternion.Euler(0f, 0f, this.m_currentAngle) * Vector2.right).XY() * this.m_currentDistance;
                    Vector2 vector4 = vector3 - this.m_extantReticleQuad.GetBounds().extents.XY();
                    this.m_extantReticleQuad.transform.position = vector4;
                }
            }
        }
Esempio n. 29
0
        // Token: 0x0600001C RID: 28 RVA: 0x000031B0 File Offset: 0x000013B0
        private void Update()
        {
            this.m_fakeActor.specRigidbody = this.m_fakeTargetRigidbody;
            bool flag = this.m_aiActor;

            if (flag)
            {
                this.m_aiActor.CanTargetEnemies = false;
                this.m_aiActor.CanTargetPlayers = true;
                this.m_aiActor.PlayerTarget     = this.m_fakeActor;
                this.m_aiActor.OverrideTarget   = null;
                this.UpdateAimTargetPosition();
                bool flag2 = this.m_aiActor.aiShooter;
                if (flag2)
                {
                    this.m_aiActor.aiShooter.AimAtPoint(this.m_behaviorSpeculator.PlayerTarget.CenterPosition);
                }
            }
            bool flag3 = this.m_behaviorSpeculator;

            if (flag3)
            {
                PlayerController playerController  = this.owner;
                BraveInput       instanceForPlayer = BraveInput.GetInstanceForPlayer(playerController.PlayerIDX);
                GungeonActions   activeActions     = instanceForPlayer.ActiveActions;
                bool             flag4             = this.m_behaviorSpeculator.AttackCooldown <= 0f;
                if (flag4)
                {
                    bool flag5 = !this.m_attackedThisCycle && this.m_behaviorSpeculator.ActiveContinuousAttackBehavior != null;
                    if (flag5)
                    {
                        this.m_attackedThisCycle = true;
                    }
                    bool flag6 = this.m_attackedThisCycle && this.m_behaviorSpeculator.ActiveContinuousAttackBehavior == null;
                    if (flag6)
                    {
                        this.m_behaviorSpeculator.AttackCooldown = float.MaxValue;
                        bool flag7 = this.dashBehav != null;
                        if (flag7)
                        {
                        }
                        bool flag8 = this.TeleBehav != null;
                        if (flag8)
                        {
                            this.TeleBehav.RequiresLineOfSight = true;
                            this.TeleBehav.MinRange            = 1000f;
                            this.TeleBehav.Range = 0.1f;
                        }
                    }
                }
                else
                {
                    bool wasPressed = activeActions.ShootAction.WasPressed;
                    if (wasPressed)
                    {
                        this.m_attackedThisCycle = false;
                        this.m_behaviorSpeculator.AttackCooldown = 0f;
                    }
                    else
                    {
                        bool wasPressed2 = activeActions.DodgeRollAction.WasPressed;
                        if (wasPressed2)
                        {
                            this.m_attackedThisCycle = false;
                            bool flag9 = this.dashBehav != null;
                            if (flag9)
                            {
                                bool flag10 = !this.isDashingOrTPing;
                                if (flag10)
                                {
                                    this.dashBehav.RequiresLineOfSight = false;
                                    this.dashBehav.MinRange            = 3f;
                                    this.dashBehav.Range = 8f;
                                    base.StartCoroutine(this.DoDash(this.dashBehav.dashTime));
                                }
                            }
                            bool flag11 = this.TeleBehav != null;
                            if (flag11)
                            {
                                bool flag12 = !this.isDashingOrTPing;
                                if (flag12)
                                {
                                    this.TeleBehav.RequiresLineOfSight = false;
                                    this.TeleBehav.MinRange            = 3f;
                                    this.TeleBehav.Range = 17f;
                                    base.StartCoroutine(this.DoTP());
                                }
                            }
                        }
                    }
                }
                bool flag13 = this.m_behaviorSpeculator.TargetBehaviors != null && this.m_behaviorSpeculator.TargetBehaviors.Count > 0;
                if (flag13)
                {
                    this.m_behaviorSpeculator.TargetBehaviors.Clear();
                }
                bool flag14 = this.m_behaviorSpeculator.MovementBehaviors != null && this.m_behaviorSpeculator.MovementBehaviors.Count > 0;
                if (flag14)
                {
                    this.m_behaviorSpeculator.MovementBehaviors.Clear();
                }
                this.m_aiActor.ImpartedVelocity += activeActions.Move.Value * this.m_aiActor.MovementSpeed * this.m_aiActor.LocalTimeScale;
                bool flag15 = this.m_behaviorSpeculator.AttackBehaviors != null;
                if (flag15)
                {
                    for (int i = 0; i < this.m_behaviorSpeculator.AttackBehaviors.Count; i++)
                    {
                        AttackBehaviorBase attack = this.m_behaviorSpeculator.AttackBehaviors[i];
                        this.ProcessAttack(attack);
                    }
                }
            }
        }
        public override void PostProcessProjectile(Projectile projectile)
        {
            base.PostProcessProjectile(projectile);
            float      length            = 0;
            BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer((this.gun.CurrentOwner as PlayerController).PlayerIDX);
            bool       flag2             = instanceForPlayer == null;

            if (!flag2)
            {
                bool flag3 = instanceForPlayer.IsKeyboardAndMouse(false);
                if (flag3)
                {
                    Vector2 a;
                    a = (this.gun.CurrentOwner as PlayerController).unadjustedAimPoint.XY();
                    a.Normalize();
                    length = Vector2.Distance(projectile.sprite.WorldCenter, a) * 8f;
                    float magnitude = (projectile.sprite.WorldCenter - a).magnitude;
                }
                else
                {
                    length = 8f;
                }
            }
            bool isMiddleProj = false;

            if (this.lastUp == null)
            {
                projectile.OverrideMotionModule = new HelixProjectileMotionModule
                {
                    helixAmplitude  = 2f,
                    helixWavelength = 8f,
                    ForceInvert     = false
                };
                projectile.gameObject.AddComponent <EyeProjUp>();
                this.lastUp = projectile;
            }
            else if (this.lastDown == null)
            {
                projectile.OverrideMotionModule = new HelixProjectileMotionModule
                {
                    helixAmplitude  = 2f,
                    helixWavelength = 8f,
                    ForceInvert     = true
                };
                projectile.gameObject.AddComponent <EyeProjDown>();
                this.lastDown = projectile;
            }
            else
            {
                projectile.gameObject.AddComponent <EyeProjMain>().boundUp   = this.lastUp;
                projectile.gameObject.GetComponent <EyeProjMain>().boundDown = this.lastDown;
                projectile.gameObject.GetComponent <EyeProjMain>().ownerHasThunderstormSynergy = this.gun.CurrentOwner is PlayerController && (this.gun.CurrentOwner as PlayerController).PlayerHasActiveSynergy("#GUNDERSTORM");
                if (this.gun.CurrentOwner != null && this.gun.CurrentOwner is PlayerController)
                {
                    projectile.gameObject.GetComponent <EyeProjMain>().divider = (this.gun.CurrentOwner as PlayerController).stats.GetStatValue(PlayerStats.StatType.ProjectileSpeed);
                }
                this.lastUp   = null;
                this.lastDown = null;
                isMiddleProj  = true;
            }
            if (this.gun.CurrentOwner is PlayerController && (this.gun.CurrentOwner as PlayerController).PlayerHasActiveSynergy("#GUNDERSTORM"))
            {
                ComplexProjectileModifier shockRounds    = PickupObjectDatabase.GetById(298) as ComplexProjectileModifier;
                ChainLightningModifier    orAddComponent = projectile.gameObject.GetOrAddComponent <ChainLightningModifier>();
                orAddComponent.LinkVFXPrefab       = shockRounds.ChainLightningVFX;
                orAddComponent.damageTypes         = shockRounds.ChainLightningDamageTypes;
                orAddComponent.maximumLinkDistance = shockRounds.ChainLightningMaxLinkDistance;
                orAddComponent.damagePerHit        = shockRounds.ChainLightningDamagePerHit;
                orAddComponent.damageCooldown      = shockRounds.ChainLightningDamageCooldown;
                if (isMiddleProj)
                {
                    orAddComponent.maximumLinkDistance    *= 3f;
                    orAddComponent.CanChainToAnyProjectile = true;
                }
                if (shockRounds.ChainLightningDispersalParticles != null)
                {
                    orAddComponent.UsesDispersalParticles        = true;
                    orAddComponent.DispersalParticleSystemPrefab = shockRounds.ChainLightningDispersalParticles;
                    orAddComponent.DispersalDensity      = shockRounds.ChainLightningDispersalDensity;
                    orAddComponent.DispersalMinCoherency = shockRounds.ChainLightningDispersalMinCoherence;
                    orAddComponent.DispersalMaxCoherency = shockRounds.ChainLightningDispersalMaxCoherence;
                }
                else
                {
                    orAddComponent.UsesDispersalParticles = false;
                }
            }
        }