void OnModelSet()
        {
            ActorModel model = this.Model;

            m_Doll  = new Doll(model.DollBody);
            m_Sheet = new ActorSheet(model.StartingSheet);

            // starting points maxed.
            m_ActionPoints  = m_Doll.Body.Speed;
            m_HitPoints     = m_previousHitPoints = m_Sheet.BaseHitPoints;
            m_StaminaPoints = m_previousStamina = m_Sheet.BaseStaminaPoints;
            m_FoodPoints    = m_previousFoodPoints = m_Sheet.BaseFoodPoints;
            m_SleepPoints   = m_previousSleepPoints = m_Sheet.BaseSleepPoints;
            m_Sanity        = m_previousSanity = m_Sheet.BaseSanity;

            // create inventory.
            if (model.Abilities.HasInventory)
            {
                m_Inventory = new Inventory(model.StartingSheet.BaseInventoryCapacity);
            }

            // starting attacks.
            m_CurrentMeleeAttack  = model.StartingSheet.UnarmedAttack;
            m_CurrentDefence      = model.StartingSheet.BaseDefence;
            m_CurrentRangedAttack = Attack.BLANK;
        }
        public ActorModel(string imageID, string name, string pluralName, int scoreValue, DollBody body, Abilities abilities, ActorSheet startingSheet, Type defaultController)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (body == null)
            {
                throw new ArgumentNullException("body");
            }
            if (abilities == null)
            {
                throw new ArgumentNullException("abilities");
            }
            if (startingSheet == null)
            {
                throw new ArgumentNullException("startingSheet");
            }
            if (defaultController != null && !defaultController.IsSubclassOf(typeof(ActorController)))
            {
                throw new ArgumentException("defaultController is not a subclass of ActorController");
            }

            m_ImageID           = imageID;
            m_DollBody          = body;
            m_Name              = name;
            m_PluralName        = pluralName;
            m_StartingSheet     = startingSheet;
            m_Abilities         = abilities;
            m_DefaultController = defaultController;
            m_ScoreValue        = scoreValue;

            m_CreatedCount = 0;
        }
Пример #3
0
 public ActorSheet(ActorSheet copyFrom)
 {
     BaseHitPoints         = copyFrom.BaseHitPoints;
     BaseStaminaPoints     = copyFrom.BaseStaminaPoints;
     BaseFoodPoints        = copyFrom.BaseFoodPoints;
     BaseSleepPoints       = copyFrom.BaseSleepPoints;
     BaseSanity            = copyFrom.BaseSanity;
     UnarmedAttack         = copyFrom.UnarmedAttack;
     BaseDefence           = copyFrom.BaseDefence;
     BaseViewRange         = copyFrom.BaseViewRange;
     BaseAudioRange        = copyFrom.BaseAudioRange;
     BaseSmellRating       = copyFrom.BaseSmellRating;
     BaseInventoryCapacity = copyFrom.BaseInventoryCapacity;
     if (0 < copyFrom.SkillTable.CountSkills)
     {
         SkillTable = new SkillTable(copyFrom.SkillTable);
     }
 }
        public ActorSheet(ActorSheet copyFrom)
        {
            if (copyFrom == null)
            {
                throw new ArgumentNullException("copyFrom");
            }

            this.BaseHitPoints         = copyFrom.BaseHitPoints;
            this.BaseStaminaPoints     = copyFrom.BaseStaminaPoints;
            this.BaseFoodPoints        = copyFrom.BaseFoodPoints;
            this.BaseSleepPoints       = copyFrom.BaseSleepPoints;
            this.BaseSanity            = copyFrom.BaseSanity;
            this.UnarmedAttack         = copyFrom.UnarmedAttack;
            this.BaseDefence           = copyFrom.BaseDefence;
            this.BaseViewRange         = copyFrom.BaseViewRange;
            this.BaseAudioRange        = copyFrom.BaseAudioRange;
            this.BaseSmellRating       = copyFrom.BaseSmellRating;
            this.BaseInventoryCapacity = copyFrom.BaseInventoryCapacity;

            if (copyFrom.SkillTable.Skills != null)
            {
                m_SkillTable = new SkillTable(copyFrom.SkillTable.Skills);
            }
        }
Пример #5
0
        public ActorModel(Gameplay.GameActors.IDs id, string?imageID, string name, string pluralName, int scoreValue, string flavor, DollBody body, Abilities abilities, ActorSheet startingSheet, Type defaultController)
        {
#if DEBUG
            // using logical XOR to restate IFF, logical AND to restate logical implication
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (string.IsNullOrEmpty(flavor))
            {
                throw new ArgumentNullException(nameof(flavor));
            }
            if (!defaultController.IsSubclassOf(typeof(ActorController)))
            {
                throw new InvalidOperationException("!defaultController.IsSubclassOf(typeof(ActorController))");
            }
            if (abilities.HasInventory ^ (0 < startingSheet.BaseInventoryCapacity))
            {
                throw new InvalidOperationException("abilities.HasInventory ^ (0 < startingSheet.BaseInventoryCapacity)");
            }
            if ((abilities.HasToEat || abilities.IsRotting) ^ (0 < startingSheet.BaseFoodPoints))
            {
                throw new InvalidOperationException("(abilities.HasToEat || abilities.IsRotting) ^ (0 < startingSheet.BaseFoodPoints)");
            }
            if (abilities.HasToSleep ^ (0 < startingSheet.BaseSleepPoints))
            {
                throw new InvalidOperationException("abilities.HasToSleep ^ (0 < startingSheet.BaseSleepPoints)");
            }
            if (abilities.HasSanity ^ (0 < startingSheet.BaseSanity))
            {
                throw new InvalidOperationException("abilities.HasSanity ^ (0 < startingSheet.BaseSanity)");
            }
            // OrderableAI should implement all of STD_LIVING, STD_HUMAN, and STD_SANE flags
            // InsaneHumanAI currently implements all of STD_LIVING and STD_HUMAN flags, but not STD_SANE flags
            if (abilities.CanTrade && !defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI)))
            {
                throw new InvalidOperationException("abilities.CanTrade && !defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI))");
            }
            if (!abilities.CanBarricade && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI)))
            {
                throw new InvalidOperationException("!abilities.CanBarricade && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI))");
            }
            if (!abilities.CanUseItems && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI)))
            {
                throw new InvalidOperationException("!abilities.CanUseItems && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI))");
            }
            if (!abilities.HasInventory && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI)))
            {
                throw new InvalidOperationException("!abilities.HasInventory && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI))");
            }
            if (!abilities.CanTalk && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI)))
            {
                throw new InvalidOperationException("!abilities.CanTalk && defaultController.IsSubclassOf(typeof(Gameplay.AI.OrderableAI))");
            }
#endif
            ID                = id;
            ImageID           = imageID;
            DollBody          = body;
            Name              = name;
            PluralName        = pluralName;
            StartingSheet     = startingSheet;
            Abilities         = abilities;
            DefaultController = defaultController;
            ScoreValue        = scoreValue;
            FlavorDescription = flavor;
        }