private void HandlePreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody && otherRigidbody.healthHaver)
     {
         float MaxEnemyHealth     = otherRigidbody.healthHaver.GetMaxHealth();
         float HalfEnemyHealth    = MaxEnemyHealth * 0.5f;
         float CurrentEnemyHealth = otherRigidbody.healthHaver.GetCurrentHealth();
         if (CurrentEnemyHealth < HalfEnemyHealth)
         {
             float originalDamage = myRigidbody.projectile.baseData.damage;
             myRigidbody.projectile.baseData.damage *= 1.5f;
             GameManager.Instance.StartCoroutine(this.ChangeProjectileDamage(myRigidbody.projectile, originalDamage));
         }
     }
 }
        private void HandlePierce(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
        {
            FieldInfo field = typeof(Projectile).GetField("m_hasPierced", BindingFlags.Instance | BindingFlags.NonPublic);

            field.SetValue(myRigidbody.projectile, false);
        }
        private void OnPreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherCollider)
        {
            Projectile component = otherRigidbody.GetComponent <Projectile>();

            if (component != null && !(component.Owner is PlayerController))
            {
                PassiveReflectItem.ReflectBullet(component, true, LastOwner.specRigidbody.gameActor, 10f, 1f, 1f, 0f);
                PhysicsEngine.SkipCollision = true;
            }
        }
 private void Collision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
 }
Ejemplo n.º 5
0
 protected extern void orig_method_16(float float_14, Vector2 vector2_1, string string_6, GEnum1 genum1_0, GEnum165 genum165_0 = GEnum165.const_0, bool bool_18 = false, PixelCollider pixelCollider_0 = null, bool bool_19 = false);
        private void PreventBulletCollisions(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
        {
            if (otherRigidbody.projectile)
            {
                if (otherRigidbody.projectile.IsBlackBullet)
                {
                    m_boostPoints = m_boostPoints + 2;
                }
                m_boostPoints++;
                otherRigidbody.projectile.DieInAir(false, true, true, false);

                PhysicsEngine.SkipCollision = true;
            }
            if (otherRigidbody.aiActor)
            {
                if (otherRigidbody.knockbackDoer)
                {
                    otherRigidbody.knockbackDoer.ApplyKnockback(otherRigidbody.UnitCenter - myRigidbody.UnitCenter, 50f, false);
                }
                PhysicsEngine.SkipCollision = true;
            }
        }
Ejemplo n.º 7
0
        private void OnPreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherCollider)
        {
            PlayerController player = this.Owner;

            PhysicsEngine.SkipCollision = true;
            RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom;
            AIActor     component   = otherRigidbody.GetComponent <AIActor>();
            bool        flag        = component != null;

            if (flag)
            {
                if (component.healthHaver && component.CenterPosition.GetAbsoluteRoom() == currentRoom)
                {
                    if (didDamage == false && !player.IsStealthed)
                    {
                        didDamage = true;
                        GameManager.Instance.StartCoroutine(this.DamageTimer());

                        if (player.HasPickupID(822) || player.HasPickupID(457))
                        {
                            Gun gun = PickupObjectDatabase.GetById(616) as Gun;
                            GameActorHealthEffect bleedEffect = new GameActorHealthEffect
                            {
                                TintColor                = Color.red,
                                DeathTintColor           = Color.red,
                                AppliesTint              = true,
                                AppliesDeathTint         = true,
                                AffectsEnemies           = true,
                                AffectsPlayers           = false,
                                effectIdentifier         = "sharpguonbleed",
                                resistanceType           = EffectResistanceType.None,
                                duration                 = 3f,
                                DamagePerSecondToEnemies = 3f,
                                stackMode                = GameActorEffect.EffectStackingMode.Refresh
                            };
                            component.ApplyEffect(bleedEffect, 1, null);


                            Vector3 vector            = component.sprite.WorldBottomLeft.ToVector3ZisY(0);
                            Vector3 vector2           = component.sprite.WorldTopRight.ToVector3ZisY(0);
                            float   num               = (vector2.y - vector.y) * (vector2.x - vector.x);
                            float   num2              = 50f * num;
                            int     num3              = Mathf.CeilToInt(Mathf.Max(1f, num2 * BraveTime.DeltaTime));
                            int     num4              = num3;
                            Vector3 minPosition       = vector;
                            Vector3 maxPosition       = vector2;
                            Vector3 direction         = Vector3.up / 2f;
                            float   angleVariance     = 120f;
                            float   magnitudeVariance = 3f;
                            float?  startLifetime     = new float?(UnityEngine.Random.Range(12, 20f));
                            GlobalSparksDoer.DoRandomParticleBurst(num4, minPosition, maxPosition, direction, angleVariance, magnitudeVariance, null, startLifetime, null, GlobalSparksDoer.SparksType.BLOODY_BLOOD);
                        }

                        component.healthHaver.ApplyDamage(4f, Vector2.zero, "Sharp Guon", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void OnGuonHit(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody other, PixelCollider otherCollider)
        {
            Projectile component = other.GetComponent <Projectile>();

            if (component != null && !(component.Owner is PlayerController))
            {
                if (UnityEngine.Random.value < 0.1f && cashSpawnedThisRoom < 20)
                {
                    LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, other.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                    cashSpawnedThisRoom += 1;
                }
            }
        }
Ejemplo n.º 9
0
    public static List <GameTask> CreateGameTasks(string actionString)
    {
        List <GameTask> gameTasks     = new List <GameTask>();
        List <string>   actionStrings = BreakUpString(actionString);

        Character taskCharacter;
        TaskType  type = IdentifyTaskType(actionStrings, out taskCharacter);

        if (type == TaskType.NAVIGATE)
        {
            GameTask gameTask = new GameTask();
            gameTask.taskType = TaskType.NAVIGATE;
            Debug.Assert(taskCharacter != null);

            if (actionStrings.Count == 3)
            {
                PixelCollider pc       = taskCharacter.GetComponentInChildren <PixelCollider>();
                string        roomName = pc.GetPixelRoom().name;
                actionStrings.Insert(2, roomName);
            }

            string    locationString = actionStrings[2];
            PixelRoom room           = GetObjectOfType <PixelRoom>(locationString);
            gameTask.arguments.Add(room);

            string        objectString  = actionStrings[3];
            PixelCollider pixelCollider = GetObjectOfType <PixelCollider>(objectString, room.transform);
            gameTask.arguments.Add(pixelCollider);
            gameTask.character = taskCharacter;

            Direction direction = Direction.All;
            if (actionStrings.Count > 4)
            {
                string directionString = actionStrings[4];
                if (directionString == "NE")
                {
                    direction = Direction.NE;
                }
                if (directionString == "SE")
                {
                    direction = Direction.SE;
                }
                if (directionString == "SW")
                {
                    direction = Direction.SW;
                }
                if (directionString == "NW")
                {
                    direction = Direction.NW;
                }
            }

            GameTask faceTask = new GameTask();
            faceTask.taskType = TaskType.FACEDIRECTION;
            faceTask.duration = 0.1f;
            faceTask.arguments.Add(direction);
            faceTask.character = taskCharacter;

            gameTasks.Add(gameTask);
            gameTasks.Add(faceTask);
        }
        else if (type == TaskType.CREATE)
        {
            GameTask createItemTask = new GameTask();
            createItemTask.taskType = TaskType.CREATE;
            createItemTask.duration = 0.0f;

            GameObject itemObj = null;

            int  number    = 1;
            bool hasNumber = int.TryParse(actionStrings[2], out number);
            if (!hasNumber)
            {
                number = 1;
                actionStrings.Insert(2, number.ToString());
            }

            Debug.Assert(number >= 1 && number <= 4);
            itemObj = Resources.Load("Items/" + actionStrings[3]) as GameObject;
            if (itemObj == null)
            {
                Debug.LogWarning(actionStrings[3] + " is not an item");
            }

            Debug.Assert(itemObj != null);
            createItemTask.arguments.Add(number);
            createItemTask.arguments.Add(itemObj);
            createItemTask.character = taskCharacter;

            gameTasks.Add(createItemTask);
        }
        else if (type == TaskType.PUTS || type == TaskType.TAKES)
        {
            // Navigate first
            int  number    = 1;
            bool hasNumber = int.TryParse(actionStrings[2], out number);

            if (!hasNumber)
            {
                number = 1;
                actionStrings.Insert(2, "1");
            }

            if (actionStrings.Count == 5)
            {
                PixelCollider pc       = taskCharacter.GetComponentInChildren <PixelCollider>();
                string        roomName = pc.GetPixelRoom().name;
                actionStrings.Insert(4, roomName);
            }

            PixelInventory inv = taskCharacter.GetComponentInChildren <PixelInventory>();
            Debug.Assert(inv != null);

            string    locationString = actionStrings[4];
            PixelRoom room           = GetObjectOfType <PixelRoom>(locationString);

            string        objectString  = actionStrings[5];
            PixelCollider pixelCollider = GetObjectOfType <PixelCollider>(objectString, room.transform);

            PixelStorage storage = pixelCollider.transform.parent.GetComponent <PixelStorage>();
            if (storage == null)
            {
                Debug.LogWarning("Cannot Place Item in " + actionStrings[5]);
                return(gameTasks);
            }

            // Navigate First
            GameTask navigateTask = new GameTask();
            navigateTask.taskType  = TaskType.NAVIGATE;
            navigateTask.character = taskCharacter;
            navigateTask.arguments.Add(room);
            navigateTask.arguments.Add(pixelCollider);
            gameTasks.Add(navigateTask);

            // Then Put
            GameTask putsItemTask = new GameTask();
            putsItemTask.taskType = type;
            putsItemTask.arguments.Add(number);
            putsItemTask.arguments.Add(actionStrings[3]);
            putsItemTask.arguments.Add(storage);
            putsItemTask.character = taskCharacter;
            gameTasks.Add(putsItemTask);
        }
        else if (type == TaskType.GIVES || type == TaskType.STEALS)         // player gives hamen key
        {
            string    characterName = actionStrings[2];
            Character toCharacter   = GetCharacter(characterName);
            if (toCharacter == null)
            {
                Debug.LogWarning("Character: " + toCharacter.name + " does not exist");
            }

            PixelInventory fromInventory = taskCharacter.GetComponentInChildren <PixelInventory>();
            PixelInventory toInventory   = toCharacter.GetComponentInChildren <PixelInventory>();
            Debug.Assert(fromInventory != null && toInventory != null);

            PixelCollider toCharacterCollider = toCharacter.GetComponentInChildren <PixelCollider>();
            PixelRoom     room = toCharacterCollider.GetPixelRoom();
            Debug.Assert(toCharacterCollider != null && room != null);

            int  count     = 1;
            bool hasNumber = int.TryParse(actionStrings[3], out count);
            if (!hasNumber)
            {
                count = 1;
                actionStrings.Insert(3, "1");
            }

            string itemName = actionStrings[4];

            // Navigate to the player
            GameTask navigateTask = new GameTask();
            navigateTask.taskType  = TaskType.NAVIGATE;
            navigateTask.character = taskCharacter;
            navigateTask.arguments.Add(room);
            navigateTask.arguments.Add(toCharacterCollider);
            gameTasks.Add(navigateTask);

            // Then Gives
            GameTask givesItemTask = new GameTask();
            givesItemTask.taskType = type;
            givesItemTask.arguments.Add(count);
            givesItemTask.arguments.Add(itemName);
            givesItemTask.arguments.Add(toCharacter);
            givesItemTask.character = taskCharacter;
            gameTasks.Add(givesItemTask);
        }
        else if (type == TaskType.MOUNT)         // player gives hamen key
        {
            // TODO 1. create a gametask for mounting an object. Must pass in the correct arguments in the gametask that
            // gets passed into the character task
        }
        return(gameTasks);
    }
Ejemplo n.º 10
0
        public bool NavigateObject(PixelRoom room, PixelCollider pixelCollider, Direction direction = Direction.All)
        {
            PixelRoom     pixelRoom      = pixelCollider.GetPixelRoom();
            PixelCollider playerCollider = GetComponentInChildren <PixelCollider>();

            // Find last location
            // Closest from the door or the players position
            List <PixelDoor> path = FindPathToRoom(room);

            Vector2 startPosition;

            if (path.Count != 0)
            {
                room.gameObject.SetActive(true);
                room.GetNavigationalMesh(playerCollider, path.Last().dropOffWorldLocation);
                room.gameObject.SetActive(false);
                startPosition = path.Last().dropOffWorldLocation;
            }
            else
            {
                startPosition = transform.position;
            }

            // Navigate from the last location to find the pixel pose
            PixelPose pixelPose;

            if (pixelCollider != null)
            {
                pixelRoom.GetNavigationalMesh(playerCollider, startPosition);

                // Object is movable
                if (pixelCollider.transform.parent.GetComponent <MovableObject>())
                {
                    if (direction != Direction.All)
                    {
                        WayPoint wayPoint = pixelCollider.FindWayPointInDirection(direction);
                        pixelPose = new PixelPose(pixelRoom, direction, wayPoint.position);
                    }
                    else
                    {
                        // Player moves to the characters position first
                        KeyValuePair <PixelPose, float> bestPlayerMovementWayPoint = pixelCollider.FindBestWayPoint();
                        pixelPose = bestPlayerMovementWayPoint.Key;

                        Debug.DrawLine(transform.position, pixelPose.position, Color.red, 10.0f);

                        // Character enqueues a movement to the best place for that position
                        Character character = pixelCollider.GetComponentInParent <Character>();
                        if (character != null)
                        {
                            PixelPose translatedPose = pixelPose.TranslatePose(2 * (pixelCollider.navigationMargin + playerCollider.navigationMargin));
                            PixelPose flippedPose    = translatedPose.Flip();

                            GameTask characterNavTask = new GameTask(GameTask.TaskType.NAVIGATE);
                            characterNavTask.character = character;
                            characterNavTask.arguments.Add(flippedPose);
                            character.characterTasks.Enqueue(characterNavTask);
                        }
                    }
                }
                else
                {
                    if (direction != Direction.All)
                    {
                        WayPoint wayPoint = pixelCollider.FindWayPointInDirection(direction);
                        pixelPose = new PixelPose(pixelRoom, direction, wayPoint.position);
                    }
                    else
                    {
                        PixelCollider characterCollider = GetComponentInChildren <PixelCollider>();
                        pixelPose = pixelCollider.FindBestWayPointPosition(startPosition);
                    }
                }
                Navigate(pixelPose);
            }
            return(true);
        }
 public void Start()
 {
     if (!m_configured)
     {
         ConfigureOnPlacement(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(transform.position.IntXY(VectorConversions.Ceil)));
     }
     if (ChaosConsole.GlitchEnemies | ChaosConsole.GlitchEverything)
     {
         if (UnityEngine.Random.value <= m_GlitchOdds)
         {
             m_GlitchModeActive = true;
         }
     }
     transform.position = m_startingPos;
     specRigidbody.Reinitialize();
     aiAnimator.LockFacingDirection = true;
     aiAnimator.FacingDirection     = DungeonData.GetAngleFromDirection(m_facingDirection);
     if (!m_failedWallConfigure)
     {
         m_fakeWall = ChaosUtility.GenerateWallMesh(m_facingDirection, pos1, "Mimic Wall", null, true, m_GlitchModeActive);
         if (aiActor.ParentRoom != null)
         {
             m_fakeWall.transform.parent = aiActor.ParentRoom.hierarchyParent;
         }
         m_fakeWall.transform.position = pos1.ToVector3().WithZ(pos1.y - 2) + Vector3.down;
         if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             StaticReferenceManager.AllShadowSystemDepthHavers.Add(m_fakeWall.transform);
         }
         else if (m_facingDirection == DungeonData.Direction.WEST)
         {
             m_fakeWall.transform.position = m_fakeWall.transform.position + new Vector3(-0.1875f, 0f);
         }
         m_fakeCeiling = ChaosUtility.GenerateRoomCeilingMesh(GetCeilingTileSet(pos1, pos2, m_facingDirection), "Mimic Ceiling", null, true, m_GlitchModeActive);
         if (aiActor.ParentRoom != null)
         {
             m_fakeCeiling.transform.parent = aiActor.ParentRoom.hierarchyParent;
         }
         m_fakeCeiling.transform.position = pos1.ToVector3().WithZ(pos1.y - 4);
         if (m_facingDirection == DungeonData.Direction.NORTH)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 0f);
         }
         else if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 2f);
         }
         else if (m_facingDirection == DungeonData.Direction.EAST)
         {
             m_fakeCeiling.transform.position += new Vector3(-1f, 0f);
         }
         m_fakeCeiling.transform.position = m_fakeCeiling.transform.position.WithZ(m_fakeCeiling.transform.position.y - 5f);
         for (int i = 0; i < specRigidbody.PixelColliders.Count; i++)
         {
             specRigidbody.PixelColliders[i].Enabled = false;
         }
         if (m_facingDirection == DungeonData.Direction.NORTH)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 38, 38, 32, 8, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 38, 54, 32, 8, true));
         }
         else if (m_facingDirection == DungeonData.Direction.SOUTH)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 38, 38, 32, 16, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 38, 54, 32, 16, true));
         }
         else if (m_facingDirection == DungeonData.Direction.WEST || m_facingDirection == DungeonData.Direction.EAST)
         {
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.LowObstacle, 46, 38, 16, 32, true));
             specRigidbody.PixelColliders.Add(PixelCollider.CreateRectangle(CollisionLayer.HighObstacle, 46, 38, 16, 32, true));
         }
         specRigidbody.ForceRegenerate(null, null);
     }
     aiActor.HasDonePlayerEnterCheck    = true;
     m_collisionKnockbackStrength       = aiActor.CollisionKnockbackStrength;
     aiActor.CollisionKnockbackStrength = 0f;
     aiActor.CollisionDamage            = 0f;
     m_goopDoer = GetComponent <GoopDoer>();
 }
Ejemplo n.º 12
0
        List <WayPoint> FindPathToLocation(Vector2 destination)
        {
            PixelCollider pixelCollider = transform.GetComponentInChildren <PixelCollider>();

            Debug.Assert(pixelCollider != null);
            PixelRoom pixelRoom = pixelCollider.GetPixelRoom();

            Debug.Assert(pixelRoom != null);

            // Dijkstra's Algorithm Parameters
            int   stepSize            = pixelRoom.stepSize;
            float minDistanceToTarget = stepSize * 2;

            // Initialization
            HashSet <WayPoint> Q      = pixelRoom.GetNavigationalMesh(pixelCollider);
            WayPoint           target = new WayPoint
            {
                position = destination,
                distance = float.MaxValue,
                previous = null
            };
            WayPoint current = Q.Aggregate((i1, i2) => (i1.position - (Vector2)transform.position).sqrMagnitude < (i2.position - (Vector2)transform.position).sqrMagnitude ? i1 : i2);

            current.distance = 0;

            // Propogation
            while (Q.Count > 0)
            {
                WayPoint u = Q.Aggregate((i1, i2) => i1.distance < i2.distance ? i1 : i2);
                Q.Remove(u);

                if (WayPoint.Distance(u, target) < minDistanceToTarget)
                {
                    target.previous = u;

                    List <WayPoint> path = new List <WayPoint>();
                    if (u.previous == null)
                    {
                        return(path);
                    }
                    while (u.previous != null)
                    {
                        path.Add(u);
                        u = u.previous;
                    }
                    path.Add(u);
                    path.Reverse();
                    return(path);
                }

                foreach (WayPoint v in u.neighbours)
                {
                    float alt = u.distance + WayPoint.Distance(u, v);
                    if (alt < v.distance)
                    {
                        v.distance = alt;
                        v.previous = u;
                    }
                }
            }

            return(new List <WayPoint>());
        }
 private void KatanaPreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody.projectile != null)
     {
         PhysicsEngine.SkipCollision = true;
     }
     if (otherRigidbody.aiActor != null)
     {
         PhysicsEngine.SkipCollision = true;
         if (!this.actorsPassed.Contains(otherRigidbody.aiActor))
         {
             otherRigidbody.aiActor.DelayActions(1f);
             this.actorsPassed.Add(otherRigidbody.aiActor);
         }
     }
     if (otherRigidbody.majorBreakable != null)
     {
         PhysicsEngine.SkipCollision = true;
         if (!this.breakablesPassed.Contains(otherRigidbody.majorBreakable))
         {
             this.breakablesPassed.Add(otherRigidbody.majorBreakable);
         }
     }
 }
        private IEnumerator HandleDash(PlayerController user, Vector2 dashDirection)
        {
            this.m_isDashing = true;
            if (this.poofVFX != null)
            {
                user.PlayEffectOnActor(this.poofVFX, Vector3.zero, false, false, false);
            }
            Vector2 startPosition = user.sprite.WorldCenter;

            this.actorsPassed.Clear();
            this.breakablesPassed.Clear();
            user.IsVisible = false;
            user.SetInputOverride("katana");
            user.healthHaver.IsVulnerable = false;
            user.FallingProhibited        = true;
            PixelCollider playerHitbox = user.specRigidbody.HitboxPixelCollider;

            playerHitbox.CollisionLayerCollidableOverride |= CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox);
            SpeculativeRigidbody specRigidbody = user.specRigidbody;

            specRigidbody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Combine(specRigidbody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.KatanaPreCollision));
            float duration = Mathf.Max(0.0001f, this.dashDistance / this.dashSpeed);
            float elapsed  = -BraveTime.DeltaTime;

            while (elapsed < duration)
            {
                user.healthHaver.IsVulnerable = false;
                elapsed += BraveTime.DeltaTime;
                float adjSpeed = Mathf.Min(this.dashSpeed, this.dashDistance / BraveTime.DeltaTime);
                user.specRigidbody.Velocity = dashDirection.normalized * adjSpeed;
                yield return(null);
            }
            user.IsVisible = true;
            user.ToggleGunRenderers(false, "katana");

            base.renderer.enabled        = true;
            base.transform.localPosition = new Vector3(-0.3f, -0.4f, 0f);
            base.transform.localRotation = new Quaternion(0, 0, 0, 1);

            if (this.poofVFX != null)
            {
                user.PlayEffectOnActor(this.poofVFX, Vector3.zero, false, false, false);
            }
            base.StartCoroutine(this.EndAndDamage(new List <AIActor>(this.actorsPassed), new List <MajorBreakable>(this.breakablesPassed), user, dashDirection, startPosition, user.sprite.WorldCenter));
            if (this.finalDelay > 0f)
            {
                user.healthHaver.IsVulnerable = false;
                yield return(new WaitForSeconds(this.finalDelay));
            }
            user.healthHaver.IsVulnerable = true;
            base.renderer.enabled         = false;
            user.ToggleGunRenderers(true, "katana");
            playerHitbox.CollisionLayerCollidableOverride &= ~CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox);
            SpeculativeRigidbody specRigidbody2 = user.specRigidbody;

            specRigidbody2.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Remove(specRigidbody2.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.KatanaPreCollision));
            user.FallingProhibited = false;
            user.ClearInputOverride("katana");
            this.m_isDashing = false;
            yield break;
        }
Ejemplo n.º 15
0
        // Token: 0x0600025A RID: 602 RVA: 0x00019660 File Offset: 0x00017860
        private void OnPreCollison(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody other, PixelCollider otherCollider)
        {
            bool flag  = base.Owner != null;
            bool flag2 = flag;

            if (flag2)
            {
                Projectile component = other.GetComponent <Projectile>();
                bool       flag3     = component != null && (component.Owner is PlayerController);
                bool       flag4     = flag3;
                if (flag4)
                {
                    bool flag5 = !ArtifactOfHatred.onCooldown;
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        ArtifactOfHatred.onCooldown = true;
                        GameManager.Instance.StartCoroutine(ArtifactOfHatred.StartCooldown(base.Owner));
                        {
                            PlayableCharacters characterIdentity = base.Owner.characterIdentity;
                            bool flag7 = characterIdentity != PlayableCharacters.Robot;
                            if (flag7)
                            {
                                AkSoundEngine.PostEvent("Play_VO_lichA_cackle_01", base.gameObject);
                                base.Owner.healthHaver.ApplyHealing(-0.5f);
                            }
                            else
                            {
                                bool flag8 = characterIdentity == PlayableCharacters.Robot;
                                if (flag8)
                                {
                                    AkSoundEngine.PostEvent("Play_VO_lichA_cackle_01", base.gameObject);
                                    base.Owner.healthHaver.Armor = base.Owner.healthHaver.Armor - 1f;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 private void OnHitEnemy(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody != null && otherRigidbody.aiActor != null && myRigidbody != null && myRigidbody.projectile && otherRigidbody.aiActor.healthHaver)
     {
         float hpercent = otherRigidbody.aiActor.healthHaver.GetCurrentHealthPercentage();
         if (hpercent == 1f)
         {
             myRigidbody.projectile.baseData.damage *= 2;
         }
     }
 }
Ejemplo n.º 17
0
 public static void BuildSynergyPrefab()
 {
     if (synergyPrefab == null && !CompanionBuilder.companionDictionary.ContainsKey("Synergy_Cross_Chamber"))
     {
         synergyPrefab = CompanionBuilder.BuildPrefab("Synergy Cross Chamber", "Synergy_Cross_Chamber", "LichItems/Resources/CrossChamber/IdleRight/tomb_idle_right_001", new IntVector2(0, 0), new IntVector2(14, 16));
         var           companion = synergyPrefab.AddComponent <CompanionController>();
         PixelCollider collider  = new PixelCollider();
         collider.ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual;
         collider.CollisionLayer         = CollisionLayer.PlayerHitBox;
         collider.ManualWidth            = 14;
         collider.ManualHeight           = 16;
         collider.ManualOffsetX          = 0;
         collider.ManualOffsetY          = 0;
         KnockbackDoer knockback = companion.gameObject.GetOrAddComponent <KnockbackDoer>();
         knockback.weight = 100f;
         companion.aiActor.IsNormalEnemy = false;
         companion.CanInterceptBullets   = true;
         companion.specRigidbody.PrimaryPixelCollider.CollisionLayer = CollisionLayer.PlayerCollider;
         companion.specRigidbody.PixelColliders.Add(collider);
         companion.gameObject.AddComponent <IgnoreEnemyCollisions>();
         companion.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox));
         companion.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyCollider));
         companion.specRigidbody.CollideWithOthers = true;
         companion.aiActor.CollisionDamage         = 0f;
         companion.aiActor.MovementSpeed           = 3f;
         companion.aiActor.CanDropCurrency         = false;
         companion.healthHaver.PreventAllDamage    = false;
         GameObject gunAttachPointObject = new GameObject("GunAttachPoint");
         FakePrefab.MarkAsFakePrefab(gunAttachPointObject);
         UnityEngine.Object.DontDestroyOnLoad(gunAttachPointObject);
         Transform gunAttachPoint = gunAttachPointObject.transform;
         gunAttachPoint.parent        = synergyPrefab.transform;
         gunAttachPoint.localPosition = new Vector3(-0.1250f, 0.3125f, 0f);
         GameObject hand = SpriteBuilder.SpriteFromResource("LichItems/Resources/CrossChamber/Hand/hand_001", new GameObject("SynergyCrossChamberHand"));
         FakePrefab.MarkAsFakePrefab(hand);
         UnityEngine.Object.DontDestroyOnLoad(hand);
         LichsBookItem.ConstructOffsetsFromAnchor(hand.GetComponent <tk2dBaseSprite>().GetCurrentSpriteDef(), tk2dBaseSprite.Anchor.MiddleCenter);
         PlayerHandController handController = hand.AddComponent <PlayerHandController>();
         handController.ForceRenderersOff = false;
         handController.attachPoint       = null;
         handController.handHeightFromGun = 0.05f;
         SetupBasicAIShooter(synergyPrefab, 38 /*38 is the id of magnum*/, gunAttachPoint, hand);
         synergyPrefab.AddAnimation("idle_right", "LichItems/Resources/CrossChamber/IdleRight", 4, AnimationType.Idle, DirectionType.TwoWayHorizontal);
         synergyPrefab.AddAnimation("idle_left", "LichItems/Resources/CrossChamber/IdleLeft", 4, AnimationType.Idle, DirectionType.TwoWayHorizontal);
         synergyPrefab.AddAnimation("run_right", "LichItems/Resources/CrossChamber/MoveRight", 10, AnimationType.Move, DirectionType.TwoWayHorizontal);
         synergyPrefab.AddAnimation("run_left", "LichItems/Resources/CrossChamber/MoveLeft", 10, AnimationType.Move, DirectionType.TwoWayHorizontal);
         synergyPrefab.AddAnimation("hit_left", "LichItems/Resources/CrossChamber/HitLeft", 6, AnimationType.Hit, DirectionType.TwoWayHorizontal).wrapMode   = tk2dSpriteAnimationClip.WrapMode.Once;
         synergyPrefab.AddAnimation("hit_right", "LichItems/Resources/CrossChamber/HitRight", 6, AnimationType.Hit, DirectionType.TwoWayHorizontal).wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
         BehaviorSpeculator component = CrossChamber.synergyPrefab.GetComponent <BehaviorSpeculator>();
         component.MovementBehaviors.Add(new CompanionFollowPlayerBehavior
         {
             IdleAnimations = new string[]
             {
                 "idle"
             },
             DisableInCombat = false
         });
         component.TargetBehaviors = new List <TargetBehaviorBase>
         {
             new TargetPlayerBehavior
             {
                 Radius              = 35f,
                 LineOfSight         = true,
                 ObjectPermanence    = true,
                 SearchInterval      = 0.25f,
                 PauseOnTargetSwitch = false,
                 PauseTime           = 0.25f
             }
         };
         component.AttackBehaviors = new List <AttackBehaviorBase>
         {
             new ShootGunBehavior()
             {
                 GroupCooldownVariance        = -1f,
                 LineOfSight                  = true,
                 WeaponType                   = WeaponType.AIShooterProjectile,
                 OverrideBulletName           = "default",
                 BulletScript                 = null,
                 FixTargetDuringAttack        = false,
                 StopDuringAttack             = false,
                 LeadAmount                   = 0f,
                 LeadChance                   = 1f,
                 RespectReload                = true,
                 MagazineCapacity             = 6,
                 ReloadSpeed                  = 2f,
                 EmptiesClip                  = false,
                 SuppressReloadAnim           = false,
                 TimeBetweenShots             = -1f,
                 PreventTargetSwitching       = false,
                 OverrideAnimation            = string.Empty,
                 OverrideDirectionalAnimation = string.Empty,
                 HideGun                      = false,
                 UseLaserSight                = false,
                 UseGreenLaser                = false,
                 PreFireLaserTime             = -1f,
                 AimAtFacingDirectionWhenSafe = false
             }
         };
         AIBulletBank bulletBank = synergyPrefab.GetOrAddComponent <AIBulletBank>();
         bulletBank.Bullets = new List <AIBulletBank.Entry>
         {
             new AIBulletBank.Entry()
             {
                 Name = "default",
                 OverrideProjectile = true,
                 ProjectileData     = new ProjectileData()
                 {
                     damage  = 10f,
                     speed   = 16f,
                     range   = 60f,
                     force   = 20f,
                     damping = 0f,
                     UsesCustomAccelerationCurve     = false,
                     AccelerationCurve               = null,
                     CustomAccelerationCurveDuration = 0f,
                     IgnoreAccelCurveTime            = 0f,
                     onDestroyBulletScript           = null
                 },
                 BulletObject = null
             }
         };
         bulletBank.useDefaultBulletIfMissing = false;
         bulletBank.transforms = new List <Transform>
         {
             synergyPrefab.transform
         };
         bulletBank.rampBullets                   = false;
         bulletBank.rampStartHeight               = 0f;
         bulletBank.rampTime                      = 0f;
         bulletBank.OverrideGun                   = null;
         bulletBank.OnProjectileCreated           = null;
         bulletBank.OnProjectileCreatedWithSource = null;
         bulletBank.FixedPlayerPosition           = null;
     }
 }
        private void OnGuonHitByBullet(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody other, PixelCollider otherCollider)
        {
            if (Owner && this.m_extantOrbital)
            {
                if (other.projectile && other.projectile.Owner && !(other.projectile.Owner is PlayerController))
                {
                    float maxDMGMult = 5f;
                    if (Owner.PlayerHasActiveSynergy("Silverer Guon Stone"))
                    {
                        maxDMGMult = 8f;
                    }
                    if (other.projectile.IsBlackBullet && storedDamageMult < maxDMGMult)
                    {
                        storedDamageMult += 0.5f;
                    }

                    if (Owner.PlayerHasActiveSynergy("Turn Gundead") && other.projectile.Owner.aiActor && other.projectile.Owner.aiActor.IsBlackPhantom)
                    {
                        if (other.projectile.Owner.healthHaver && !other.projectile.Owner.healthHaver.IsBoss && UnityEngine.Random.value <= 0.1f)
                        {
                            other.projectile.Owner.aiActor.UnbecomeBlackPhantom();
                        }
                        else if (other.projectile.Owner.healthHaver && other.projectile.Owner.healthHaver.IsBoss && UnityEngine.Random.value <= 0.05f)
                        {
                            other.projectile.Owner.aiActor.UnbecomeBlackPhantom();
                        }
                    }
                }
            }
        }
            private void OnPreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
            {
                if (base.specRigidbody && base.aiActor && base.healthHaver && base.healthHaver.IsAlive && Owner && base.sprite)
                {
                    if (otherRigidbody.projectile && !(otherRigidbody.projectile.Owner is PlayerController))
                    {
                        if (Owner.PlayerHasActiveSynergy("Deviled Gregs"))
                        {
                            if (UnityEngine.Random.value <= 0.15f)
                            {
                                float spawnAngle = 0f;
                                for (int i = 0; i < 8; i++)
                                {
                                    GameObject gameObject = SpawnManager.SpawnProjectile((PickupObjectDatabase.GetById(336) as Gun).DefaultModule.projectiles[0].gameObject, base.sprite.WorldCenter, Quaternion.Euler(0f, 0f, spawnAngle), true);
                                    Projectile component  = gameObject.GetComponent <Projectile>();
                                    if (component)
                                    {
                                        component.SpawnedFromOtherPlayerProjectile = false;
                                        if (Owner != null)
                                        {
                                            //COMPANION SHIT

                                            component.TreatedAsNonProjectileForChallenge = true;
                                            component.baseData.damage           *= Owner.stats.GetStatValue(PlayerStats.StatType.Damage);
                                            component.baseData.speed            *= Owner.stats.GetStatValue(PlayerStats.StatType.ProjectileSpeed);
                                            component.baseData.force            *= Owner.stats.GetStatValue(PlayerStats.StatType.KnockbackMultiplier);
                                            component.AdditionalScaleMultiplier *= Owner.stats.GetStatValue(PlayerStats.StatType.PlayerBulletScale);
                                            component.UpdateSpeed();
                                            base.HandleCompanionPostProcessProjectile(component);
                                        }
                                    }
                                    spawnAngle += 45;
                                }
                            }
                        }
                        if (Owner.PlayerHasActiveSynergy("Hard Boiled Gregs"))
                        {
                            PassiveReflectItem.ReflectBullet(otherRigidbody.projectile, true, Owner.specRigidbody.gameActor, 10f, 1f, 1f, 0f);
                            if (base.healthHaver)
                            {
                                base.healthHaver.ApplyDamage(13, Vector2.zero, "Greggo");
                            }


                            PhysicsEngine.SkipCollision = true;
                        }
                    }
                }
            }
Ejemplo n.º 20
0
        public static GameObject MainHook(GameObject objectToInstantiate, RoomHandler targetRoom,
                                          IntVector2 location, bool deferConfiguration, AIActor.AwakenAnimationType awakenAnimType = AIActor.AwakenAnimationType.Default, bool autoEngage = false)
        {   //hooks into InstantiateDungeonPlaceable
            GameObject result;

            System.Random rnd = new System.Random();
            int           nu  = 0;
            string        enemyGuid;

            GRandomHook.wasBoss = false;
            bool isbossroom = false;


            if (targetRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS &&
                targetRoom.area.PrototypeRoomBossSubcategory == PrototypeDungeonRoom.RoomBossSubCategory.FLOOR_BOSS)
            {
                isbossroom = true;
            }

            else if (GRandomRoomDatabaseHelper.AllSpecificDeathRooms.Contains(targetRoom.GetRoomName()))
            {
                isbossroom = true;
            }


            try
            {
                if (objectToInstantiate != null)
                {
                    Vector3 vector = location.ToVector3(0f) + targetRoom.area.basePosition.ToVector3();
                    vector.z = vector.y + vector.z;
                    AIActor component   = objectToInstantiate.GetComponent <AIActor>(); //notused
                    AIActor ogcomponent = component;


                    if (component is AIActorDummy)
                    {
                        objectToInstantiate = (component as AIActorDummy).realPrefab;
                        component           = objectToInstantiate.GetComponent <AIActor>();
                    }

                    SpeculativeRigidbody component2 = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); //notused
                    if (component && component2)
                    {
                        if (component.EnemyGuid != null)
                        {
                            //Here gets enemyGuid based on room. Pulls from EnemyDatabase   ///////////////////////
                            if (isbossroom)
                            {
                                if (component.healthHaver.IsBoss)
                                {
                                    GRandomHook.wasBoss = true;
                                    if (component.healthHaver.GetMaxHealth() != 60) //sometimes gets health as regular enemy health, 60
                                    {
                                        GRandomHook.boss_health = component.healthHaver.GetMaxHealth();
                                        //getting boss health to set for replacement boss
                                    }

                                    //replacement for Boss
                                    nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedBossRoomDatabase.Count);
                                    enemyGuid = GRandomEnemyDataBaseHelper.UsedBossRoomDatabase[nu];
                                }


                                else
                                { //normal enemies as bosses is off and the enemy is not a boss; pull from no bosses database for enemy spawnings
                                    nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly.Count);
                                    enemyGuid = GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly[nu];
                                }
                            }

                            else if (targetRoom.GetRoomName() == "ResourcefulRat_PitEntrance_01" | targetRoom.GetRoomName() == "ResourcefulRat_Entrance")
                            {
                                nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase.Count);
                                enemyGuid = GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase[nu];
                            }

                            else
                            {
                                nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase.Count);
                                enemyGuid = GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase[nu];
                            }


                            if (component.EnemyGuid == "479556d05c7c44f3b6abb3b2067fc778") //wallmimic
                            {
                                enemyGuid = "479556d05c7c44f3b6abb3b2067fc778";
                            }

                            //
                            //can add specific Guid here for debugging
                            //


                            if (enemyGuid == "465da2bb086a4a88a803f79fe3a27677") //replace DraGun, can't remove him from database or forge dragunroom breaks
                            {
                                enemyGuid = "05b8afe0b6cc4fffa9dc6036fa24c8ec";
                            }

                            // End getting guid //////////////////////////////

                            //initializing new AIActor, not sure why they do it again below
                            AIActor prefabActor = EnemyDatabase.GetOrLoadByGuid(enemyGuid);


                            objectToInstantiate = prefabActor.gameObject;
                            component           = objectToInstantiate.GetComponent <AIActor>();
                            component2          = objectToInstantiate.GetComponent <SpeculativeRigidbody>();
                            //bool specificdeathdoer = prefabActor.healthHaver.ManualDeathHandling;



                            GenericIntroDoer genericIntroDoer = component.GetComponent <GenericIntroDoer>();

                            //if (genericIntroDoer) // is boss
                            // handles initiated boss settings
                            if (component.healthHaver.IsBoss)
                            {
                                if (isbossroom)
                                {
                                    prefabActor.healthHaver.SetHealthMaximum(GRandomHook.boss_health);
                                    ETGModConsole.Log("Newbosshealth " + prefabActor.healthHaver.GetMaxHealth());
                                }
                                else
                                {
                                    prefabActor.healthHaver.SetHealthMaximum(60f);
                                }

                                objectToInstantiate = RandomHandleEnemyInfo.RemoveBossIntros(objectToInstantiate);
                                objectToInstantiate = RandomHandleEnemyInfo.ReplaceSpecificBossDeathController(objectToInstantiate);
                                objectToInstantiate = RandomHandleEnemyInfo.AttackBehaviorManipulator(objectToInstantiate);

                                DemonWallController dwc = objectToInstantiate.GetComponent <DemonWallController>();
                                if (dwc)
                                {
                                    Destroy(dwc);
                                }
                            }

                            if (!component.IsNormalEnemy)
                            {
                                objectToInstantiate = RandomHandleEnemyInfo.HandleCompanions(objectToInstantiate);
                            }
                        }


                        PixelCollider pixelCollider = component2.GetPixelCollider(ColliderType.Ground);
                        if (pixelCollider.ColliderGenerationMode != PixelCollider.PixelColliderGeneration.Manual)
                        {
                            Debug.LogErrorFormat("Trying to spawn an AIActor who doesn't have a manual ground collider... do we still do this? Name: {0}", new object[]
                            {
                                objectToInstantiate.name
                            });
                        }
                        Vector2 a       = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualOffsetX, pixelCollider.ManualOffsetY));
                        Vector2 vector2 = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualWidth, pixelCollider.ManualHeight));
                        Vector2 vector3 = new Vector2((float)Mathf.CeilToInt(vector2.x), (float)Mathf.CeilToInt(vector2.y));
                        Vector2 b       = new Vector2((vector3.x - vector2.x) / 2f, 0f).Quantize(0.0625f);



                        if (targetRoom.GetRoomName() == "DraGunRoom01" | targetRoom.GetRoomName() == "LichRoom02" |
                            targetRoom.GetRoomName() == "LichRoom03" | targetRoom.GetRoomName() == "Bullet_End_Room_04" |
                            targetRoom.GetRoomName() == "ResourcefulRatRoom01")
                        {
                            b -= new Vector2(0.0f, 5.0f);
                        }

                        Vector3 v3 = a - b;
                        vector -= v3;
                        //vector -= a - b; //Vector3
                    }

                    if (component)
                    {
                        component.AwakenAnimType = awakenAnimType;
                    }


                    GameObject NewEnemyObject = UnityEngine.Object.Instantiate <GameObject>(objectToInstantiate, vector, Quaternion.identity);


                    if (!deferConfiguration)
                    {
                        Component[] componentsInChildren = NewEnemyObject.GetComponentsInChildren(typeof(IPlaceConfigurable));
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            IPlaceConfigurable placeConfigurable = componentsInChildren[i] as IPlaceConfigurable;
                            if (placeConfigurable != null)
                            {
                                placeConfigurable.ConfigureOnPlacement(targetRoom);
                            }
                        }
                    }
                    ObjectVisibilityManager component3 = NewEnemyObject.GetComponent <ObjectVisibilityManager>();
                    if (component3 != null)
                    {
                        component3.Initialize(targetRoom, autoEngage);
                    }
                    MinorBreakable componentInChildren = NewEnemyObject.GetComponentInChildren <MinorBreakable>();
                    if (componentInChildren != null)
                    {
                        IntVector2 key      = location + targetRoom.area.basePosition;
                        CellData   cellData = GameManager.Instance.Dungeon.data[key];
                        if (cellData != null)
                        {
                            cellData.cellVisualData.containsObjectSpaceStamp = true;
                        }
                    }
                    PlayerItem component4 = NewEnemyObject.GetComponent <PlayerItem>();
                    if (component4 != null)
                    {
                        component4.ForceAsExtant = true;
                    }


                    //[Randomizer] Add AIActor GameObjectInfo
                    AIActor enemy_component = NewEnemyObject.GetComponent <AIActor>();
                    if (enemy_component)
                    {
                        if (enemy_component.healthHaver.IsBoss)
                        {
                            if (isbossroom)

                            { //Boss Room
                                enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar;
                            }
                            else
                            {
                                enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.None;
                                autoEngage = true;
                            }
                            NewEnemyObject = RandomHandleEnemyInfo.ReinstateBossObjectInfo(NewEnemyObject); //removes boss status if regular boss, needs hitbox stuff reinstated
                        }


                        if (GRandomEnemyDataBaseHelper.SpecificEnemyDatabase.Contains(enemy_component.EnemyGuid))
                        {
                            NewEnemyObject = RandomHandleEnemyInfo.SpecificEnemyHelper(NewEnemyObject);
                        }

                        NewEnemyObject = UniqueBossRoomDeathHandler.SpecificRoomHandler(targetRoom, NewEnemyObject);
                    }


                    result = NewEnemyObject;
                }

                else
                {
                    result = null;
                    //return null;
                }
            }

            catch (Exception message)
            {
                Debug.Log("[RANDOMIZER ERROR] " + message.ToString());


                result = null;
            }

            return(result);
        }
Ejemplo n.º 21
0
 private void HandlePreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody.gameObject.name != null)
     {
         if (otherRigidbody.gameObject.name == "Table_Vertical" || otherRigidbody.gameObject.name == "Table_Horizontal")
         {
             if (!tablesHitAlready.Contains(otherRigidbody))
             {
                 tablesHitAlready.Add(otherRigidbody);
                 myRigidbody.projectile.baseData.damage *= 1.2f;
                 myRigidbody.projectile.RuntimeUpdateScale(1.2f);
             }
             PhysicsEngine.SkipCollision = true;
         }
     }
 }
        private void HandleHitEnemyHitEnemy(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
        {
            if (otherRigidbody && otherRigidbody.aiActor && myRigidbody && myRigidbody.healthHaver)
            {
                AIActor aiActor = otherRigidbody.aiActor;
                myRigidbody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Remove(myRigidbody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.HandleHitEnemyHitEnemy));


                if (aiActor.healthHaver.IsBoss)
                {
                    aiActor.healthHaver.ApplyDamage(myRigidbody.healthHaver.GetMaxHealth() * 1f, myRigidbody.Velocity, "Pinball", CoreDamageTypes.None, DamageCategory.Normal, false, null, true);
                }
                else
                {
                    aiActor.healthHaver.ApplyDamage(myRigidbody.healthHaver.GetMaxHealth() * 2f, myRigidbody.Velocity, "Pinball", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                }
            }
        }
Ejemplo n.º 23
0
 private void OnHitEnemy(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody != null && otherRigidbody.aiActor != null && myRigidbody != null && myRigidbody.projectile && otherRigidbody.aiActor.healthHaver)
     {
         float hpercent = otherRigidbody.aiActor.healthHaver.GetMaxHealth() / 600;
         if (hpercent > 0.5f)
         {
             hpercent = 0.5f;
         }
         myRigidbody.projectile.baseData.damage *= 1 + hpercent;
     }
 }
Ejemplo n.º 24
0
        private void DoBlankDisappear(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody other, PixelCollider otherCollider)
        {
            PlayerController owner     = base.Owner;
            Projectile       component = other.GetComponent <Projectile>();

            if (component != null && !(component.Owner is PlayerController))
            {
                GameObject silencerVFX = (GameObject)ResourceCache.Acquire("Global VFX/BlankVFX_Ghost");
                AkSoundEngine.PostEvent("Play_OBJ_silenceblank_small_01", base.gameObject);
                GameObject       gameObject                = new GameObject("silencer");
                SilencerInstance silencerInstance          = gameObject.AddComponent <SilencerInstance>();
                float            additionalTimeAtMaxRadius = 0.25f;
                silencerInstance.TriggerSilencer(myRigidbody.UnitCenter, 25f, 5f, silencerVFX, 0f, 3f, 3f, 3f, 250f, 5f, additionalTimeAtMaxRadius, owner, false, false);
            }
            ArmourGuonStone.guonHook.Dispose();
        }
Ejemplo n.º 25
0
    protected void method_16(float float_14, Vector2 vector2_1, string string_6, GEnum1 genum1_0, GEnum165 genum165_0 = GEnum165.const_0, bool bool_18 = false, PixelCollider pixelCollider_0 = null, bool bool_19 = false)
    {
        if (currentHealth == 0)
        {
            orig_method_16(float_14, vector2_1, string_6, genum1_0, genum165_0, bool_18, pixelCollider_0, bool_19);
            return;
        }

        float currHP = this.currentHealth;

        orig_method_16(float_14, vector2_1, string_6, genum1_0, genum165_0, bool_18, pixelCollider_0, bool_19);

        float newHP = this.currentHealth;

        float deltaHP = currHP - newHP;

        Vector3 centerPos = this.SpeculativeRigidbody_0.Vector2_4;

        centerPos += this.transform.up;

        if (ETGModGUI.UseDamageIndicators)
        {
            ETGDamageIndicatorGUI.CreateIndicator(centerPos, deltaHP);
            ETGDamageIndicatorGUI.CreateBar(this);
        }
        ETGDamageIndicatorGUI.maxHP[this]     = maximumHealth;
        ETGDamageIndicatorGUI.currentHP[this] = currentHealth;

        ETGDamageIndicatorGUI.UpdateHealthBar(this, deltaHP);

        if (currentHealth == 0)
        {
            ETGDamageIndicatorGUI.toRemoveBars.Add(this);
            ETGDamageIndicatorGUI.maxHP.Remove(this);
            ETGDamageIndicatorGUI.currentHP.Remove(this);
        }
    }
Ejemplo n.º 26
0
 private void OnPreCollide(SpeculativeRigidbody myRigidbody, PixelCollider myCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherCollider)
 {
     if (CurrentChallenge == ChallengeType.TOIL_AND_TROUBLE && linkedOther != null & linkedOther.specRigidbody != null)
     {
         if (otherRigidbody == linkedOther.specRigidbody)
         {
             PhysicsEngine.SkipCollision = true;
         }
     }
 }
Ejemplo n.º 27
0
 public void OnPreRigidbodyCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (myRigidbody.projectile != null && myRigidbody.sprite != null && this.m_owner.PlayerHasActiveSynergy("#BE_SERIOUS"))
     {
         if (!this.m_owner.IsInCombat || this.smarterMinions.Count >= 4)
         {
             return;
         }
         AIActor    orLoadByGuid         = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5");
         IntVector2?nearestAvailableCell = null;
         if (this.m_owner.CurrentRoom != null)
         {
             nearestAvailableCell = this.m_owner.CurrentRoom.GetNearestAvailableCell(myRigidbody.projectile.sprite.WorldCenter, new IntVector2?(orLoadByGuid.Clearance), new CellTypes?(CellTypes.FLOOR), false, null);
         }
         Vector3             vector         = nearestAvailableCell != null ? (nearestAvailableCell.Value.ToVector2()).ToVector3ZUp(0f) : myRigidbody.projectile.sprite.WorldCenter.ToVector3ZUp(0f);
         GameObject          enemyObj       = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);
         CompanionController orAddComponent = enemyObj.GetOrAddComponent <CompanionController>();
         orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE;
         orAddComponent.Initialize(this.m_owner);
         orAddComponent.behaviorSpeculator.MovementBehaviors.Add(new CompanionFollowPlayerBehavior());
         AIActor aiactor = enemyObj.GetComponent <AIActor>();
         aiactor.HitByEnemyBullets         = true;
         aiactor.healthHaver.ModifyDamage += this.ModifyDamageForCompanions;
         aiactor.StartCoroutine(this.InvisibleCoroutine(aiactor));
         aiactor.procedurallyOutlined = false;
         aiactor.CorpseObject         = null;
         aiactor.ImmuneToAllEffects   = true;
         aiactor.SetIsFlying(true, "I'm a bullet too!");
         SmarterDumbEnemyBehavior smartBehavior = aiactor.gameObject.AddComponent <SmarterDumbEnemyBehavior>();
         smartBehavior.layer      = myRigidbody.projectile.gameObject.layer;
         smartBehavior.collection = myRigidbody.projectile.sprite.Collection;
         smartBehavior.spriteId   = myRigidbody.projectile.sprite.spriteId;
         foreach (AIBulletBank.Entry entry in orAddComponent.bulletBank.Bullets)
         {
             if (aiactor.IsBlackPhantom)
             {
                 entry.BulletObject.GetComponent <Projectile>().baseData.damage = 15;
             }
             else
             {
                 entry.BulletObject.GetComponent <Projectile>().baseData.damage = 10;
             }
         }
         foreach (AttackBehaviorBase behavior in aiactor.behaviorSpeculator.AttackBehaviors)
         {
             if ((behavior as ShootGunBehavior) != null)
             {
                 if (aiactor.IsBlackPhantom)
                 {
                     aiactor.aiShooter.GetBulletEntry((behavior as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = 15;
                 }
                 else
                 {
                     aiactor.aiShooter.GetBulletEntry((behavior as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = 10;
                 }
             }
         }
         this.smarterMinions.Add(aiactor);
     }
     else if (myRigidbody.projectile != null && myRigidbody.sprite != null)
     {
         AIActor    aiactor    = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"), myRigidbody.projectile.sprite.WorldCenter, myRigidbody.transform.position.GetAbsoluteRoom(), true, AIActor.AwakenAnimationType.Default, true);
         GameObject gameObject = new GameObject("suck image");
         gameObject.layer = myRigidbody.projectile.gameObject.layer;
         tk2dSprite tk2dSprite = gameObject.AddComponent <tk2dSprite>();
         gameObject.transform.parent   = SpawnManager.Instance.Projectiles;
         gameObject.transform.position = aiactor.sprite.WorldCenter;
         tk2dSprite.SetSprite(myRigidbody.projectile.sprite.Collection, myRigidbody.projectile.sprite.spriteId);
         tk2dSprite.transform.parent     = aiactor.transform;
         aiactor.sprite.renderer.enabled = false;
         aiactor.procedurallyOutlined    = false;
         aiactor.CanTargetEnemies        = true;
         aiactor.CanTargetPlayers        = false;
         aiactor.CorpseObject            = null;
         aiactor.ImmuneToAllEffects      = true;
         aiactor.SetIsFlying(true, "I'm a bullet too!");
         aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.PlayerHitBox, CollisionLayer.PlayerCollider));
         if (aiactor.IgnoreForRoomClear)
         {
             aiactor.IgnoreForRoomClear = false;
             if (aiactor.ParentRoom != null)
             {
                 aiactor.ParentRoom.DeregisterEnemy(aiactor);
             }
         }
         DumbEnemyBehavior dumbEnemyBehavior = aiactor.gameObject.AddComponent <DumbEnemyBehavior>();
         if (myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>() != null)
         {
             dumbEnemyBehavior.sourceAmmoType     = myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>().ammoType;
             dumbEnemyBehavior.customAmmoType     = myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>().customAmmoType;
             dumbEnemyBehavior.usesNewUsesSynergy = true;
         }
         myRigidbody.projectile.DieInAir();
     }
 }
 public static void DamageHook(Action <HealthHaver, float, Vector2, string, CoreDamageTypes, DamageCategory, bool, PixelCollider, bool> orig, HealthHaver hh, float damage, Vector2 direction, string damageSource, CoreDamageTypes damageTypes,
                               DamageCategory damageCategory, bool ignoreInvulnerabilityFrames, PixelCollider hitPixelCollider, bool ignoreDamageCaps)
 {
     damageSource = string.Empty;
     orig(hh, damage, direction, damageSource, damageTypes, damageCategory, ignoreInvulnerabilityFrames, hitPixelCollider, ignoreDamageCaps);
     hh.lastIncurredDamageSource = string.Empty;
 }
 private void HandlePreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     if (otherRigidbody && otherRigidbody.projectile)
     {
         if (otherRigidbody.projectile.Owner is PlayerController)
         {
             Projectile projectile = otherRigidbody.projectile;
             if (projectile.gameObject.GetComponent <EyeProjUp>() != null || projectile.gameObject.GetComponent <EyeProjDown>() != null)
             {
                 if (!this.immuneToCollision)
                 {
                     Gun           voidCannon = (PickupObjectDatabase.GetById(593) as Gun);
                     Gun           heroine    = (PickupObjectDatabase.GetById(41) as Gun);
                     ExplosionData data0      = GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultExplosionData;
                     ExplosionData data       = new ExplosionData
                     {
                         doDamage             = true,
                         damageRadius         = this.ownerHasThunderstormSynergy ? 5f : 3.75f,
                         damageToPlayer       = 0,
                         damage               = 25,
                         breakSecretWalls     = true,
                         secretWallsRadius    = this.ownerHasThunderstormSynergy ? 4.75f : 3.25f,
                         doDestroyProjectiles = true,
                         doForce              = true,
                         pushRadius           = this.ownerHasThunderstormSynergy ? 4.75f : 3.25f,
                         force                  = data0.force,
                         debrisForce            = data0.debrisForce,
                         preventPlayerForce     = true,
                         explosionDelay         = data0.explosionDelay,
                         usesComprehensiveDelay = data0.usesComprehensiveDelay,
                         comprehensiveDelay     = data0.comprehensiveDelay,
                         effect                 = data0.effect,
                         doScreenShake          = true,
                         ss = data0.ss,
                         doStickyFriction             = data0.doStickyFriction,
                         doExplosionRing              = data0.doExplosionRing,
                         isFreezeExplosion            = false,
                         freezeEffect                 = null,
                         playDefaultSFX               = true,
                         IsChandelierExplosion        = false,
                         rotateEffectToNormal         = data0.rotateEffectToNormal,
                         ignoreList                   = new List <SpeculativeRigidbody>(),
                         overrideRangeIndicatorEffect = data0.overrideRangeIndicatorEffect
                     };
                     if (voidCannon.DefaultModule.projectiles[0].GetComponent <ExplosiveModifier>() != null)
                     {
                         data.effect = voidCannon.DefaultModule.projectiles[0].GetComponent <ExplosiveModifier>().explosionData.effect;
                     }
                     Exploder.Explode(this._proj.sprite.sprite.WorldCenter, data, new Vector2(), null, false, CoreDamageTypes.Electric, true);
                     DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(StormEyeController.goopDefs[0]).AddGoopCircle(this._proj.sprite.WorldCenter, this.ownerHasThunderstormSynergy ? 5f : 3.75f);
                     for (int i = 0; i < StaticReferenceManager.AllGoops.Count; i++)
                     {
                         StaticReferenceManager.AllGoops[i].ElectrifyGoopCircle(this._proj.sprite.WorldBottomCenter, 1f);
                     }
                     projectile.DieInAir(true);
                     this._proj.DieInAir(true);
                     if (this.boundUp != null)
                     {
                         this.boundUp.DieInAir(true);
                     }
                     if (this.boundDown != null)
                     {
                         this.boundDown.DieInAir(true);
                     }
                 }
             }
         }
         PhysicsEngine.SkipCollision = true;
     }
 }
Ejemplo n.º 30
0
 private void DoCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
 {
     PhysicsEngine.SkipCollision = true;
     if (otherRigidbody.gameObject.GetComponent <PlayerController>())
     {
         otherRigidbody.gameObject.GetComponent <PlayerController>().healthHaver.ApplyDamage(0.5f, Vector2.zero, "Prince Of The Jammed", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
     }
 }