Exemple #1
0
        public void Setup()
        {
            mockCollectionsSelector = new Mock <ICollectionSelector>();
            mockFeatsSelector       = new Mock <IFeatsSelector>();
            mockFeatFocusGenerator  = new Mock <IFeatFocusGenerator>();
            mockDice       = new Mock <Dice>();
            featsGenerator = new FeatsGenerator(mockCollectionsSelector.Object, mockFeatsSelector.Object, mockFeatFocusGenerator.Object, mockDice.Object);

            abilities                = new Dictionary <string, Ability>();
            skills                   = new List <Skill>();
            featSelections           = new List <FeatSelection>();
            specialQualitySelections = new List <SpecialQualitySelection>();
            hitPoints                = new HitPoints();
            attacks                  = new List <Attack>();
            specialQualities         = new List <Feat>();
            speeds                   = new Dictionary <string, Measurement>();
            creatureType             = new CreatureType();
            alignment                = new Alignment("creature alignment");

            hitPoints.HitDice.Add(new HitDice {
                Quantity = 1
            });
            creatureType.Name = "creature type";

            abilities[AbilityConstants.Intelligence] = new Ability(AbilityConstants.Intelligence);

            mockFeatsSelector.Setup(s => s.SelectFeats()).Returns(featSelections);
            mockFeatsSelector.Setup(s => s.SelectSpecialQualities("creature", creatureType)).Returns(specialQualitySelections);
            mockCollectionsSelector.Setup(s => s.SelectRandomFrom(It.IsAny <IEnumerable <FeatSelection> >())).Returns((IEnumerable <FeatSelection> fs) => fs.First());
        }
        public override void OnSingleClick(Mobile from)
        {
            if (from.NetState != null)
            {
                LabelTo(from, Name);
            }

            if (DamageState != DamageStateType.Broken)
            {
                LabelTo(from, "[Durability " + HitPoints.ToString() + "/" + m_MaxHitPoints.ToString() + "]");
            }

            else
            {
                if (RequiresFullRepair)
                {
                    LabelTo(from, "[Construction: " + HitPoints.ToString() + "/" + m_MaxHitPoints.ToString() + "]");
                }

                else
                {
                    LabelTo(from, "[Broken: " + HitPoints.ToString() + "/" + m_MaxHitPoints.ToString() + "]");
                }
            }
        }
        private IEnumerable <Skill> InitializeSkills(
            Dictionary <string, Ability> abilities,
            IEnumerable <SkillSelection> skillSelections,
            HitPoints hitPoints,
            bool includeFirstHitDieBonus)
        {
            var skills = new List <Skill>();
            var skillsWithArmorCheckPenalties = collectionsSelector.SelectFrom(TableNameConstants.Collection.SkillGroups, GroupConstants.ArmorCheckPenalty);

            foreach (var skillSelection in skillSelections)
            {
                if (!abilities[skillSelection.BaseAbilityName].HasScore)
                {
                    continue;
                }

                var skill = new Skill(skillSelection.SkillName, abilities[skillSelection.BaseAbilityName], hitPoints.RoundedHitDiceQuantity, skillSelection.Focus);

                if (includeFirstHitDieBonus)
                {
                    skill.RankCap += 3;
                }

                skill.HasArmorCheckPenalty = skillsWithArmorCheckPenalties.Contains(skill.Name);
                skill.ClassSkill           = skillSelection.ClassSkill;

                skills.Add(skill);
            }

            return(skills);
        }
Exemple #4
0
        public HitPoints GenerateFor(string creatureName, CreatureType creatureType, Ability constitution, string size, int additionalHitDice = 0, bool asCharacter = false)
        {
            var hitPoints = new HitPoints();

            var quantity = adjustmentSelector.SelectFrom <double>(TableNameConstants.Adjustments.HitDice, creatureName);
            var die      = adjustmentSelector.SelectFrom <int>(TableNameConstants.Adjustments.HitDice, creatureType.Name);

            quantity += additionalHitDice;

            if (asCharacter && creatureType.Name == CreatureConstants.Types.Humanoid)
            {
                quantity--;
            }

            hitPoints.Constitution = constitution;
            hitPoints.Bonus        = GetBonus(creatureType, size);

            if (quantity > 0)
            {
                hitPoints.HitDice.Add(new HitDice {
                    Quantity = quantity, HitDie = die
                });
            }

            hitPoints.RollDefaultTotal(dice);
            hitPoints.RollTotal(dice);

            return(hitPoints);
        }
Exemple #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (DefName.Length != 0)
            {
                hash ^= DefName.GetHashCode();
            }
            if (StackCount != 0)
            {
                hash ^= StackCount.GetHashCode();
            }
            if (StuffDefName.Length != 0)
            {
                hash ^= StuffDefName.GetHashCode();
            }
            if (Quality != 0)
            {
                hash ^= Quality.GetHashCode();
            }
            if (HitPoints != 0)
            {
                hash ^= HitPoints.GetHashCode();
            }
            if (innerProtoThing_ != null)
            {
                hash ^= InnerProtoThing.GetHashCode();
            }
            return(hash);
        }
Exemple #6
0
 public DnDObject(ArmorClass ac, HitPoints hp, PhysicalProperties physicalProperties, Resistance resistance)
 {
     AC = ac;
     HP = hp;
     PhysicalProperties = physicalProperties;
     Resistance         = resistance;
 }
    // Repair robot on trigger or over a certain duration
    private void OnTriggerEnter(Collider other)
    {
        _hp = other.GetComponent <HitPoints>();
        if (_hp == null)
        {
            return;
        }
        if (_canRepair == false)
        {
            return;
        }
        _canRepair = false;
        GameObject particles = Instantiate(_repairParticles, other.transform.position, _repairParticles.transform.rotation, other.transform);

        Destroy(particles, _particleLifetime);
        if (_repairSound != null)
        {
            _repairSound.Play();
        }
        if (_isRepairOverTime == false)
        {
            _hp.AddHitPoints(_repairAmount);
            Destroy(gameObject);
        }
        else
        {
            GetComponent <MeshRenderer>().enabled = false;
            _repairStarted = true;
        }
    }
Exemple #8
0
        public void DealDamages_ShouldSumAllDamage_WhenMultipleDamages()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 1
                },
                new DealDamage {
                    DamageType = DamageTypes.Cold, Hp = 2
                },
                new DealDamage {
                    DamageType = DamageTypes.Necrotic, Hp = 3
                },
                new DealDamage {
                    DamageType = DamageTypes.Psychic, Hp = 4
                },
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(32);
        }
Exemple #9
0
        public static string Measure(HitPoints hitPoints)
        {
            var percentHealthy = (double)hitPoints.Current / hitPoints.Max;

            if (percentHealthy >= 1.0)
            {
                return("Healthy");
            }
            else if (percentHealthy >= 0.80)
            {
                return("Slightly Injured");
            }
            else if (percentHealthy >= 0.40)
            {
                return("Injured");
            }
            else if (percentHealthy >= 0.15)
            {
                return("Badly Injured");
            }
            else if (percentHealthy > 0 && percentHealthy < 0.15)
            {
                return("Near Death");
            }
            else
            {
                return("Dead");
            }
        }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        if (flashColor == null)
        {
            flashColor = GetComponent <FlashColor> ();
        }
        flashColorExists = flashColor != null;

        if (flashScale == null)
        {
            flashScale = GetComponent <FlashScale> ();
        }
        flashScaleExists = flashScale != null;

        if (myParticleSystem == null)
        {
            myParticleSystem = GetComponent <ParticleSystem> ();
        }
        particleSystemExists = myParticleSystem != null;

        if (hitpoints == null)
        {
            hitpoints = GetComponent <HitPoints> ();
        }
        hitPointsExists = hitpoints != null;
    }
Exemple #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (DefName.Length != 0)
            {
                hash ^= DefName.GetHashCode();
            }
            if (StackCount != 0)
            {
                hash ^= StackCount.GetHashCode();
            }
            if (StuffDefName.Length != 0)
            {
                hash ^= StuffDefName.GetHashCode();
            }
            if (Quality != global::Trading.Quality.Awful)
            {
                hash ^= Quality.GetHashCode();
            }
            if (HitPoints != 0)
            {
                hash ^= HitPoints.GetHashCode();
            }
            if (innerProtoThing_ != null)
            {
                hash ^= InnerProtoThing.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemple #12
0
        public override void OnSingleClick(Mobile from)
        {
            LabelTo(from, DisplayName + " Stockpile");
            LabelTo(from, "[Durability: " + HitPoints.ToString() + "/" + MaxHitPoints.ToString() + "]");

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            if (!UOACZSystem.IsUOACZValidMobile(player))
            {
                return;
            }
            if (!player.IsUOACZHuman)
            {
                return;
            }
            if (player.m_UOACZAccountEntry.HumanProfile.Stockpile == null)
            {
                return;
            }

            LabelTo(from, "Your Items: " + player.m_UOACZAccountEntry.HumanProfile.Stockpile.TotalItems.ToString() + " / " + player.m_UOACZAccountEntry.HumanProfile.Stockpile.MaxItems.ToString() + "");
        }
Exemple #13
0
        public IEnumerable <Skill> GenerateFor(
            HitPoints hitPoints,
            string creatureName,
            CreatureType creatureType,
            Dictionary <string, Ability> abilities,
            bool canUseEquipment,
            string size,
            bool includeFirstHitDieBonus = true)
        {
            if (hitPoints.RoundedHitDiceQuantity == 0)
            {
                return(Enumerable.Empty <Skill>());
            }

            var creatureSkillNames  = GetCreatureSkillNames(creatureName, creatureType);
            var untrainedSkillNames = GetUntrainedSkillsNames(canUseEquipment);

            //INFO: Must do union in this direction, so that when we build selections, the creature skills overwrite noncreature skills
            var allSkillNames   = untrainedSkillNames.Union(creatureSkillNames);
            var skillSelections = GetSkillSelections(allSkillNames, creatureSkillNames);
            var skills          = InitializeSkills(abilities, skillSelections, hitPoints, includeFirstHitDieBonus);

            skills = ApplySkillPointsAsRanks(skills, hitPoints, creatureType, abilities, includeFirstHitDieBonus);
            skills = ApplyBonuses(creatureName, creatureType, skills, size);
            skills = ApplySkillSynergy(skills);

            return(skills);
        }
Exemple #14
0
    public override void Start(RAIN.Core.AI ai)
    {
        base.Start(ai);

        _lastRunning = 0;
        m_HitPoints  = ai.Body.GetComponent <HitPoints>();
    }
Exemple #15
0
    void Start()
    {
        if (expNeededForNextLevel == 0)
        {
            Debug.LogWarning("Level up requirement not initialized.  Setting default value of 100");
            expNeededForNextLevel = 100;
        }

        if (hitPoints == null)
        {
            hitPoints = GetComponent <HitPoints>();

            if (hitPoints == null)
            {
                Debug.LogError("No HitPoints component on: " + gameObject.name);
            }
        }

        if (unitAttributes == null)
        {
            unitAttributes = GetComponent <Attack>();

            if (unitAttributes == null)
            {
                Debug.LogError("No HitPoints component on: " + gameObject.name);
            }
        }
    }
        public void WhenCurrentHitPointsIsAtMax_ThenCreatureLooksHealthy()
        {
            var hitPoints = new HitPoints(100);
            var condition = HealthinessReader.Measure(hitPoints);

            Assert.AreEqual("Healthy", condition);
        }
 public void BecameZero(HitPoints hp)
 {
     StateManager.SetState(State.Dying);
     Fader.Fade("to black", 3.0f);
     MusicController.Current.Fade(1.0f, 0.0f, 1.0f);
     Invoke("GameOverScreen", TimeToDie);
 }
Exemple #18
0
        public IEnumerable <Skill> ApplySkillPointsAsRanks(
            IEnumerable <Skill> skills,
            HitPoints hitPoints,
            CreatureType creatureType,
            Dictionary <string, Ability> abilities,
            bool includeFirstHitDieBonus)
        {
            var points = GetTotalSkillPoints(creatureType, hitPoints.RoundedHitDiceQuantity, abilities[AbilityConstants.Intelligence], includeFirstHitDieBonus);
            var totalRanksAvailable = skills.Sum(s => s.RankCap - s.Ranks);

            if (points >= totalRanksAvailable)
            {
                return(MaxOutSkills(skills));
            }

            var skillsWithAvailableRanks = skills.Where(s => !s.RanksMaxedOut);
            var creatureSkills           = skillsWithAvailableRanks.Where(s => s.ClassSkill);
            var untrainedSkills          = skillsWithAvailableRanks.Where(s => !s.ClassSkill);

            while (points > 0)
            {
                var skill          = collectionsSelector.SelectRandomFrom(creatureSkills, untrainedSkills);
                var availableRanks = Math.Min(skill.RankCap - skill.Ranks, points);
                var rankRoll       = RollHelper.GetRollWithMostEvenDistribution(1, availableRanks);
                var ranks          = dice.Roll(rankRoll).AsSum();

                skill.Ranks += ranks;
                points      -= ranks;
            }

            return(skills);
        }
Exemple #19
0
    public override void Start(RAIN.Core.AI ai)
    {
        base.Start(ai);

        _lastRunning = 0;
        m_HitPoints = ai.Body.GetComponent<HitPoints>();
    }
    // Use this for initialization
    void Start()
    {
        foreach (GameObject p in players)
        {
            p.SetActive(false);
        }

        gameOverPanel.SetActive(false);

        score = 0;
        updateScoreText();

        player = players[PlayerPrefs.GetInt(Globals.PP_PLAYER_UNIT, 0)];
        player.GetComponent <SpriteRenderer> ().color = new Color(
            PlayerPrefs.GetFloat(Globals.PP_PLAYER_COLOR_RED, UnityEngine.Random.Range(0.0f, 1.0f)),
            PlayerPrefs.GetFloat(Globals.PP_PLAYER_COLOR_GREEN, UnityEngine.Random.Range(0.0f, 1.0f)),
            PlayerPrefs.GetFloat(Globals.PP_PLAYER_COLOR_BLUE, UnityEngine.Random.Range(0.0f, 1.0f))
            );

        player.SetActive(true);

        shieldToggle = player.GetComponent <ToggleDisplay> ();
        shieldToggle.hide();

        playerHP = player.GetComponent <HitPoints> ();
        createHPBar();

        hazards           = new GameObject[][] { hazardsLevel1, hazardsLevel2, hazardsLevel3, hazardsLevel4, hazardsLevel5 };
        hazardPercentages = new float[] { 0.15f, 2.35f, 13.5f, 34f, 34f, 13.5f, 2.35f, 0.15f };

        StartCoroutine(spawnHazards());
    }
        public override int GetHashCode()
        {
            var hashCode = -595725116;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DisplayName);

            hashCode = hashCode * -1521134295 + HitPoints.GetHashCode();
            hashCode = hashCode * -1521134295 + HitPointsMax.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DescriptionLong);

            hashCode = hashCode * -1521134295 + ResistenceMax.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string[]> .Default.GetHashCode(Origins);

            hashCode = hashCode * -1521134295 + ClassType.GetHashCode();
            hashCode = hashCode * -1521134295 + Column.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ClassName);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(DescriptionShort);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PrimaryGroup);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(SecondaryGroup);

            hashCode = hashCode * -1521134295 + Playable.GetHashCode();
            hashCode = hashCode * -1521134295 + RechargeMax.GetHashCode();
            hashCode = hashCode * -1521134295 + DamageMax.GetHashCode();
            hashCode = hashCode * -1521134295 + RecoveryMax.GetHashCode();
            hashCode = hashCode * -1521134295 + RegenerationMax.GetHashCode();
            hashCode = hashCode * -1521134295 + RecoveryBase.GetHashCode();
            hashCode = hashCode * -1521134295 + RegenerationBase.GetHashCode();
            hashCode = hashCode * -1521134295 + ThreatBase.GetHashCode();
            hashCode = hashCode * -1521134295 + PerceptionBase.GetHashCode();
            return(hashCode);
        }
    // Use this for initialization
    void Start()
    {
        HitPoints     = 30;
        HPtoText      = player_HP_Text.GetComponent <Text>();
        HPtoText.text = HitPoints.ToString();

        handPosition = handPanelObject.transform.position;

        if (gameObject.name == "Player One")
        {
            DrawKarateAttackCard();
            DrawKarateAttackCard();
            DrawKarateAttackCard();
            DrawKarateMovementCard();
            DrawKarateMovementCard();
        }
        else
        {
            DrawBoxingAttackCard();
            DrawBoxingAttackCard();
            DrawBoxingAttackCard();
            DrawBoxingMovementCard();
            DrawBoxingMovementCard();
        }
    }
Exemple #23
0
    void Start()

    {
        hp      = gameObject.GetComponent <HitPoints>();
        sp      = gameObject.GetComponent <SpawnEnemy>();
        hook    = gameObject.GetComponent <Transform>();
        startHp = hp.health;
    }
Exemple #24
0
    private void OnGlobalEndBattle(ArenaManager obj)
    {
        DeactivateHealthBar();

        _bossHitPoints.OnHpChanged -= OnHpChanged;
        _bossHitPoints              = null;
        _bossStartHp = 0f;
    }
Exemple #25
0
    //public GameObject dronePrefab;
    //public Vector3 droneSpawnOffset;

    void Awake()
    {
        myMover = GetComponent <Mover>();
        hp      = GetComponent <HitPoints>();
        if (hp == null)
        {
            Debug.LogError("No hit point component on Drone");
        }
    }
Exemple #26
0
        public HitPoints RegenerateWith(HitPoints hitPoints, IEnumerable <Feat> feats)
        {
            hitPoints.Bonus += feats.Where(f => f.Name == FeatConstants.Toughness).Sum(f => f.Power);

            hitPoints.RollDefaultTotal(dice);
            hitPoints.RollTotal(dice);

            return(hitPoints);
        }
        public void ShouldEquate()
        {
            //arrange
            HitPoints hitPoints1 = new HitPoints(6);
            HitPoints hitPoints2 = new HitPoints(6);

            //assert
            hitPoints2.Should().Be(hitPoints1);
        }
Exemple #28
0
    void Start()
    {
        outlineColor = GetComponent <SpriteOutline>().Color;
        HitPoints hp = GetComponent <HitPoints>();

        if (hp)
        {
            hp.EventDeath.AddListener(() => { enabled = false; EventInactive.Invoke(); });
        }
    }
Exemple #29
0
        public void AddTemporaryHp_ShouldSetTemporaryHp()
        {
            // Arrange
            var instance = new HitPoints(42);

            // Act
            instance.AddTemporaryHp(5);
            // Assert
            instance.TemporaryHp.Should().Be(5);
        }
Exemple #30
0
        public void AddDeathSavingThrowFailure_ShouldIncrementCount()
        {
            // Arrange
            var instance = new HitPoints(42);

            // Act
            instance.AddDeathSavingThrowFailure();
            // Assert
            instance.DeathSavingThrowFailures.Should().Be(1);
        }
Exemple #31
0
        public void DamageMathChecksOut(uint normalDamage, double damageMultiplier, double chance, double randomRoll, uint expectedDamage)
        {
            HitPoints initialHp      = new HitPoints(9999);
            Hero      shootingTarget = new Hero(new TeamId(255), initialHp);

            HitPoints                baseDamage               = new HitPoints(normalDamage);
            AutoAttackAbility        attackAbility            = new AutoAttackAbility(baseDamage, CreateTargeter((h, c) => shootingTarget));
            CriticalHitChanceAbility criticalHitChanceAbility = new CriticalHitChanceAbility(chance, damageMultiplier);

            Hero attacker = new Hero(new TeamId(0), initialHp: default, attackAbility, criticalHitChanceAbility);
Exemple #32
0
    void Start()
    {
        game_started = false;
        airplane = GameObject.Find("Airplane").gameObject;
        myCar = new Machine();
        myCar.tnk = GameObject.Find("M1_Abrams").gameObject;
        startTime = Time.time;
        startPoint = myCar.tnk.transform.position;
        moveState = false;
        rotState = false;
        startRot = myCar.tnk.transform.rotation;
        ok = false;
        fireMode = false;

        bullet = myCar.tnk.transform.FindChild("bullet").gameObject;
        bullet_inital_pozition = bullet.transform.position;
        unloaded = false;
        translateDuration = 0.0f;
        target = Vector3.zero;

        ParticleEmitter p;
        p = GameObject.Find("InnerCore").GetComponent<ParticleEmitter>();
        p.emit = false;
        p = GameObject.Find("OuterCore").GetComponent<ParticleEmitter>();
        p.emit = false;
        p = GameObject.Find("InnerCore_factory").GetComponent<ParticleEmitter>();
        p.emit = false;
        p = GameObject.Find("OuterCore_factory").GetComponent<ParticleEmitter>();
        p.emit = false;
        p = GameObject.Find("InnerCore_factory2").GetComponent<ParticleEmitter>();
        p.emit = false;
        p = GameObject.Find("OuterCore_factory2").GetComponent<ParticleEmitter>();
        p.emit = false;

        projectile_bonus = GameObject.Find("projectile").gameObject;
        projectile_bonus.animation.Play("projectile_bonus");
        projectile_bonus.animation.wrapMode = WrapMode.Loop;

        projectile_bonus_time_show = Time.time;
        projectile_bonus_time_hide = -1.0f;

        //getting score;
        h=GameObject.Find("M1_Abrams").GetComponent<HitPoints>();
        choose_location = false;
        airplane_end_loc = airplane_start_loc = airplane.transform.position;
        airplane_fly = false;
        flight_duration = 6.0f;
        start_flight = -1.0f;
        t3 = t4 = t5 = t6 = t7 = false;
    }
 // Use this for initialization
 void Start()
 {
     GameObject weapon=Instantiate(weaponPrefab,weaponContainer.position,weaponContainer.rotation) as GameObject;
     weapon.transform.parent=weaponContainer;
     controller = GetComponent<CharacterController> ();
     _animation = GetComponent<Animation> ();
     hpValue = GetComponent<HitPoints> () ;
     StartCoroutine (Controller ());
 }