Exemplo n.º 1
0
        public void Die()
        {
            if (!mobile)
            {
                return;
            }

            // Get corpse marker texture indices
            int archive, record;

            EnemyBasics.ReverseCorpseTexture(mobile.Summary.Enemy.CorpseTexture, out archive, out record);

            // Leave corpse marker
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (dfUnity)
            {
                // Spawn marker
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, transform.parent, true);
                go.transform.position = transform.position;

                // Align to ground. Be generous with distance as flying enemies might have a way to drop.
                // This could also be hanlded by adding a Rigidbody and collider then let gravity do the work.
                GameObjectHelper.AlignBillboardToGround(go, go.GetComponent <DaggerfallBillboard>().Summary.Size, 16f);
            }

            // Disable enemy gameobject and schedule for destruction
            gameObject.SetActive(false);
            GameObject.Destroy(gameObject);
        }
Exemplo n.º 2
0
        public void PlaceCorpseMarker(int corpseTexture)
        {
            // Get corpse marker texture indices
            int archive, record;

            EnemyBasics.ReverseCorpseTexture(corpseTexture, out archive, out record);

            // Spawn corpse marker
            GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, record, transform.parent, true);

            go.transform.position = transform.position;

            // Align to ground. Be generous with distance as flying enemies might have a way to drop.
            // This could also be handled by adding a Rigidbody and collider then let gravity do the work.
            // TODO: Ensure corpse markers never land on top of other monsters
            GameObjectHelper.AlignBillboardToGround(go, go.GetComponent <DaggerfallBillboard>().Summary.Size, 16f);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a loot container for enemies slain by the player.
        /// </summary>
        /// <param name="player">Player object, must have PlayerEnterExit attached.</param>
        /// <param name="enemy">Enemy object, must have EnemyMotor attached.</param>
        /// <param name="corpseTexture">Packed corpse texture index from entity summary.</param>
        /// <param name="loadID">Unique LoadID for save system.</param>
        /// <returns>DaggerfallLoot.</returns>
        public static DaggerfallLoot CreateLootableCorpseMarker(GameObject player, GameObject enemy, EnemyEntity enemyEntity, int corpseTexture, ulong loadID)
        {
            // Player must have a PlayerEnterExit component
            PlayerEnterExit playerEnterExit = player.GetComponent <PlayerEnterExit>();

            if (!playerEnterExit)
            {
                throw new Exception("CreateLootableCorpseMarker() player game object must have PlayerEnterExit component.");
            }

            // Enemy must have an EnemyMotor component
            EnemyMotor enemyMotor = enemy.GetComponent <EnemyMotor>();

            if (!enemyMotor)
            {
                throw new Exception("CreateLootableCorpseMarker() enemy game object must have EnemyMotor component.");
            }

            // Get parent by context
            Transform parent = null;

            if (GameManager.Instance.IsPlayerInside)
            {
                if (GameManager.Instance.IsPlayerInsideDungeon)
                {
                    parent = playerEnterExit.Dungeon.transform;
                }
                else
                {
                    parent = playerEnterExit.Interior.transform;
                }
            }
            else
            {
                parent = GameManager.Instance.StreamingTarget.transform;
            }

            // Get corpse marker texture indices
            int archive, record;

            EnemyBasics.ReverseCorpseTexture(corpseTexture, out archive, out record);

            // Find ground position below player
            Vector3 position = enemyMotor.FindGroundPosition();

            // Create loot container
            DaggerfallLoot loot = CreateLootContainer(
                LootContainerTypes.CorpseMarker,
                InventoryContainerImages.Corpse2,
                position,
                parent,
                archive,
                record,
                loadID);

            // Set properties
            loot.LoadID       = loadID;
            loot.LootTableKey = enemyEntity.MobileEnemy.LootTableKey;
            loot.playerOwned  = false;
            loot.customDrop   = true;

            // If dropped outside ask StreamingWorld to track loose object
            if (!GameManager.Instance.IsPlayerInside)
            {
                GameManager.Instance.StreamingWorld.TrackLooseObject(loot.gameObject);
            }

            return(loot);
        }