private IEnumerator EatEnemy(AIActor targetEnemy)
        {
            float      elapsed      = 0f;
            float      duration     = 0.5f;
            Vector3    startPos     = targetEnemy.transform.position;
            Vector3    finalOffset  = sprite.WorldCenter - startPos.XY();
            tk2dSprite targetSprite = targetEnemy.GetComponentInChildren <tk2dSprite>();

            if (targetEnemy.behaviorSpeculator)
            {
                targetEnemy.behaviorSpeculator.enabled = false;
            }
            RoomHandler m_ParentRoom = targetEnemy.GetAbsoluteParentRoom();

            if (m_ParentRoom != null)
            {
                m_ParentRoom.DeregisterEnemy(targetEnemy);
            }
            // Destroy(targetEnemy);
            // Destroy(targetEnemy.specRigidbody);
            targetEnemy.specRigidbody.CollideWithOthers = false;
            spriteAnimator.PlayForDuration("baby_dragun_weak_eat", -1f, "baby_dragun_weak_idle", false);
            AkSoundEngine.PostEvent("Play_NPC_BabyDragun_Munch_01", gameObject);
            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                if (!targetSprite || !targetSprite.transform)
                {
                    m_currentlyEatingEnemy = false; yield break;
                }
                targetSprite.transform.localScale = Vector3.Lerp(Vector3.one, new Vector3(0.01f, 0.01f, 1f), elapsed / duration);
                targetSprite.transform.position   = Vector3.Lerp(startPos, startPos + finalOffset, elapsed / duration);
                yield return(null);
            }
            if (!targetSprite || !targetSprite.transform)
            {
                m_currentlyEatingEnemy = false; yield break;
            }
            yield return(null);

            // Destroy(targetSprite.gameObject);
            m_ParentRoom.DeregisterEnemy(targetEnemy);
            targetEnemy.EraseFromExistence(true);
            m_enemiesEaten++;
            if (m_enemiesEaten >= RequiredEnemies)
            {
                while (spriteAnimator.IsPlaying("baby_dragun_weak_eat"))
                {
                    yield return(null);
                }
                LootEngine.GivePrefabToPlayer(PickupObjectDatabase.GetById(ItemID).gameObject, GameManager.Instance.BestActivePlayer);
                Destroy(gameObject);
            }
            yield return(null);

            m_currentlyEatingEnemy = false;
            yield break;
        }
Esempio n. 2
0
        // Re-use code from baby dragun NPC to make Enemy get sucked into ball. Looks cooler then a simple poof effect. :D
        private IEnumerator SuckUpEnemy(AIActor targetEnemy, DebrisObject obj, PlayerController owner)
        {
            float          elapsed      = 0f;
            float          duration     = 0.5f;
            Vector3        startPos     = targetEnemy.transform.position;
            Vector3        finalOffset  = obj.sprite.WorldCenter - startPos.XY();
            tk2dBaseSprite targetSprite = targetEnemy.GetComponentInChildren <tk2dBaseSprite>();

            targetEnemy.behaviorSpeculator.InterruptAndDisable();
            Destroy(targetEnemy);
            Destroy(targetEnemy.specRigidbody);
            yield return(null);

            AkSoundEngine.PostEvent("Play_NPC_BabyDragun_Munch_01", obj.gameObject);
            while (elapsed < duration)
            {
                elapsed += BraveTime.DeltaTime;
                if (!targetSprite || !targetSprite.transform)
                {
                    yield return(null);
                }
                else
                {
                    targetSprite.transform.localScale = Vector3.Lerp(Vector3.one, new Vector3(0.01f, 0.01f, 1f), elapsed / duration);
                    targetSprite.transform.position   = Vector3.Lerp(startPos, startPos + finalOffset, elapsed / duration);
                }
                yield return(null);
            }
            Destroy(targetSprite.gameObject);

            MonsterBall monsterBall = obj.GetComponent <MonsterBall>();

            if (monsterBall)
            {
                if (monsterBall.AutoPickup)
                {
                    yield return(new WaitForSeconds(0.2f));

                    LootEngine.DoDefaultItemPoof(obj.transform.position, false, false);
                    monsterBall.Pickup(owner);
                }
            }
            yield break;
        }
        private void HandleHideKeyOnEnemy()
        {
            List <AIActor> PuzzleEnemyList = new List <AIActor>();

            if (m_ParentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.All))
            {
                PuzzleEnemyList = m_ParentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
            }

            if (PuzzleEnemyList.Count > 0)
            {
                AIActor selectedActor = BraveUtility.RandomElement(PuzzleEnemyList);
                ExpandShaders.Instance.ApplyGlitchShader(selectedActor.GetComponentInChildren <tk2dBaseSprite>());
                selectedActor.gameObject.AddComponent <ExpandSpawnGlitchObjectOnDeath>();
                selectedActor.CanDropItems = true;
                selectedActor.AdditionalSimpleItemDrops = new List <PickupObject> {
                    PickupObjectDatabase.GetById(727)
                };
            }
        }
Esempio n. 4
0
        public static void BuildWestBrosBossPrefabs(AssetBundle assetBundle)
        {
            // all 3 west bros animation sets are actually in their 3 cut guns (752,753,754), they all contain the same ones, so we just take the first one
            // 752 is nome
            // 753 is tuc
            // 754 is angel
            WestBrosGun = PickupObjectDatabase.GetById(752);

            Collection = WestBrosGun.gameObject.GetComponent <tk2dSprite>().Collection;
            Animation  = WestBrosGun.gameObject.GetComponent <tk2dSpriteAnimator>().Library;

            Shades       = ExpandCustomEnemyDatabase.GetOfficialEnemyByGuid("c00390483f394a849c36143eb878998f");
            ShadesDebris = Shades.GetComponentInChildren <ExplosionDebrisLauncher>().debrisSources[0];

            SetupHand(assetBundle, out WestBrosHandPrefab, ExpandCustomEnemyDatabase.WestBrosCollection.GetComponent <tk2dSpriteCollectionData>());

            BuildWestBrosHatPrefab(assetBundle, out WestBrosAngelHatPrefab, WestBros.Angel, Collection, ShadesDebris);
            BuildWestBrosHatPrefab(assetBundle, out WestBrosNomeHatPrefab, WestBros.Nome, Collection, ShadesDebris);
            BuildWestBrosHatPrefab(assetBundle, out WestBrosTucHatPrefab, WestBros.Tuc, Collection, ShadesDebris);

            BuildWestBrosBossPrefab(assetBundle, out WestBrosAngelPrefab, WestBros.Angel, false, Collection, Animation);
            BuildWestBrosBossPrefab(assetBundle, out WestBrosNomePrefab, WestBros.Nome, true, Collection, Animation, true);
            BuildWestBrosBossPrefab(assetBundle, out WestBrosTucPrefab, WestBros.Tuc, true, Collection, Animation);
        }