/// <summary>
        /// Helper to relink caster type and ID back to a real DaggerfallEntityBehaviour in scene.
        /// May experience concurrency issues once enemies start casting spells as very likely that
        /// player will save while under effect of a bundle cast by an enemy monster.
        /// Likewise possible for monster A and monster B to both catch each other in their AOEs and
        /// have a co-depdendency on each other as caster. So the first monster loaded will not be
        /// able to find reference for second monster as it has not been loaded yet.
        /// Already have strategies in mind to resolve this, depending on how bad problem is in practice.
        /// Don't want to "prematurely optimise" until this is actually a problem worth fixing.
        /// </summary>
        DaggerfallEntityBehaviour GetCasterReference(EntityTypes entityType, ulong loadID)
        {
            DaggerfallEntityBehaviour caster = null;

            // Only supporting player and enemy entity types as casters for now
            if (entityType == EntityTypes.Player)
            {
                caster = GameManager.Instance.PlayerEntityBehaviour;
            }
            else if ((entityType == EntityTypes.EnemyMonster || entityType == EntityTypes.EnemyClass) && loadID != 0)
            {
                SerializableEnemy serializableEnemy = SaveLoadManager.StateManager.GetEnemy(loadID);
                if (!serializableEnemy)
                {
                    throw new Exception(string.Format("EntityEffect.RestoreEffectSaveData() could not find SerializableEnemy for LoadID {0} in StateManager.", loadID));
                }

                caster = serializableEnemy.GetComponent <DaggerfallEntityBehaviour>();
                if (!caster)
                {
                    throw new Exception(string.Format("EntityEffect.RestoreEffectSaveData() could not find DaggerfallEntityBehaviour for LoadID {0} in StateManager.", loadID));
                }
            }

            return(caster);
        }
Exemple #2
0
    private void SaveEnemyData()
    {
        SerializableEnemy serializedEnemy = new SerializableEnemy()
        {
            enemyName = this.name,
            health = this.currentHealth,
            positionX = transform.position.x,
            positionY = transform.position.y,
            positionZ = transform.position.z,
        };

        SaveLoad.Save<SerializableEnemy>(serializedEnemy, "Enemy" + this.name);
    }
Exemple #3
0
    private void LoadEnemyData()
    {
        if (SaveLoad.SaveExists("Enemy" + this.name))
        {
            SerializableEnemy enemyData = SaveLoad.Load<SerializableEnemy>("Enemy" + this.name);

            currentHealth = enemyData.health;

            Vector3 position;
            position.x = enemyData.positionX;
            position.y = enemyData.positionY;
            position.z = enemyData.positionZ;

            transform.position = position;
        }

    }
Exemple #4
0
 public void loadEnemy(SerializableEnemy se, bool inEditorLoad = true)
 {
     startPosition.x = se.startX;
     startPosition.y = se.startY;
     nextPosition    = startPosition;
     if (inEditorLoad)
     {
         moveList = new List <EnemyAction>();
     }
     else
     {
         moveList = se.ea;
     }
     defaultLookAt = se.defaultLook;
     isHelicopter  = se.isHelicopter;
     turnEnemy(defaultLookAt, true);
 }
Exemple #5
0
 public void loadEnemy(SerializableEnemy se, bool inEditorLoad = true)
 {
     startPosition.x = se.startX;
     startPosition.y = se.startY;
     nextPosition = startPosition;
     if(inEditorLoad)
     {
         moveList = new List<EnemyAction>();
     }
     else{
         moveList = se.ea;
     }
     defaultLookAt = se.defaultLook;
     isHelicopter = se.isHelicopter;
     turnEnemy(defaultLookAt, true);
 }