Inheritance: MonoBehaviour
示例#1
0
    // Update is called once per frame

    public void DecideWhoTurn()
    {
        GatherEnenmyForFight();
        GatherHeroForFight();
        int avgMotivation = 0;
        int totalhero     = 0;

        for (int i = 0; i < allLivingHeroes.Count; i++)
        {
            avgMotivation += allLivingHeroes[i].Motivation;
            totalhero++;
        }
        avgMotivation = avgMotivation / totalhero;
        int chanceNum  = DiceRoller.RollDice();
        int heroChance = 100 - avgMotivation;

        if (chanceNum > heroChance)
        {
            NowPlayerTurn();
        }
        else
        {
            StartEnemyTurn();
        }
    }
示例#2
0
    private void Awake()
    {
        _dice = this;
        var go = new GameObject("DEBUG CANVAS");
        var c  = go.AddComponent <Canvas>();

        c.renderMode = RenderMode.ScreenSpaceOverlay;

        var box = new GameObject("box");

        box.transform.parent = c.transform;
        var rbox = box.AddComponent <RectTransform>();

        rbox.anchorMin        = Vector2.one;
        rbox.anchorMax        = Vector2.one;
        rbox.pivot            = Vector2.one;
        rbox.anchoredPosition = Vector2.zero;

        var img = box.AddComponent <Image>();

        img.color = Color.black;

        var txtG = new GameObject("Text");

        txtG.transform.parent = box.transform;
        _txt = txtG.AddComponent <Text>();

        _txt.text = "1-6";
        _txt.resizeTextForBestFit = true;
        _txt.font      = Font.CreateDynamicFontFromOSFont("Arial", 34);
        _txt.alignment = TextAnchor.MiddleCenter;
        _txt.rectTransform.anchoredPosition = Vector2.zero;
    }
示例#3
0
        public void GiveNameToActor(DiceRoller roller, Actor actor, string[] firstNames, string[] lastNames)
        {
            actor.IsProperName = true;
            string randomName = firstNames[roller.Roll(0, firstNames.Length)] + " " + lastNames[roller.Roll(0, lastNames.Length)];

            actor.Name = randomName;
        }
示例#4
0
    void Initialize()
    {
        supplyLines = new List <HexPath>();
        Name        = "Army";
        Food        = Mathf.Floor(Random.value * Global.MAXIMUM_FOOD);
        Manpower    = 100;
        roller      = new DiceRoller(6);
        // Create a drawer.
        drawer = new EntityDrawer(transform);

        //Attempt to wire the SelectionInterface.
        SelectionInterface = transform.GetComponent <SelectableObj>();
        if (SelectionInterface == null)
        {
            throw new UnityException("Failed to link Army Entity to a SelectionInterface.");
        }
        else
        {
            WireSelectionInterface();
        }

        //Wire up the GM
        Global.GM.ArmyUpdate += OnStartTurn;

        //Present UI Components.

        // Create sprites
        CreateSprites();
    }
示例#5
0
 public void GiveRandomSkillsToActor(DiceRoller roller, Actor actor, int count)
 {
     for (int i = 0; i < count; i++)
     {
         GiveRandomSkillToActor(roller, actor);
     }
 }
示例#6
0
 public void SkinNakedHuman(DiceRoller roller, Actor actor, string[] eyes, string[] skins, string[] heads)
 {
     actor.Doll.RemoveAllDecorations();
     actor.Doll.AddDecoration(DollPart.EYES, eyes[roller.Roll(0, eyes.Length)]);
     actor.Doll.AddDecoration(DollPart.SKIN, skins[roller.Roll(0, skins.Length)]);
     actor.Doll.AddDecoration(DollPart.HEAD, heads[roller.Roll(0, heads.Length)]);
 }
示例#7
0
        private string RollDice(int dicepool, int explode = 10, int success = 8)
        {
            var genie    = new DiceRoller();
            var results  = new List <int>();
            var exploded = 0;

            while (dicepool > 0)
            {
                var result = genie.RollDice(10);
                if (result >= success)
                {
                    _successes++;
                }

                if (result >= explode)
                {
                    exploded++;
                }

                results.Add(result);
                dicepool--;
            }

            results.Sort();

            var response = string.Format("[ {0} ]", string.Join(",", results));

            if (exploded > 0)
            {
                return(response + " " + RollDice(exploded, explode, success));
            }

            return(response);
        }
示例#8
0
 public DiceRollerTests()
 {
     mockDie1   = new Mock <IDie>();
     mockDie2   = new Mock <IDie>();
     mockDice   = new[] { mockDie1.Object, mockDie2.Object };
     diceRoller = new DiceRoller(mockDice);
 }
示例#9
0
 public void DressBlackOps(DiceRoller roller, Actor actor)
 {
     actor.Doll.RemoveAllDecorations();
     actor.Doll.AddDecoration(DollPart.EYES, MALE_EYES[roller.Roll(0, MALE_EYES.Length)]);
     actor.Doll.AddDecoration(DollPart.SKIN, MALE_SKINS[roller.Roll(0, MALE_SKINS.Length)]);
     actor.Doll.AddDecoration(DollPart.TORSO, GameImages.BLACKOP_SUIT);
 }
示例#10
0
        public override double Fight(Character opponant)
        {
            var damageCaused = 0;

            var actionsRemaining = Actions;

            while (actionsRemaining > 0)
            {
                actionsRemaining--;

                var hit = opponant.TakeHit(AttackType.Magic, Magic);

                var damageSpread = new DamageExpression[4] {
                    new DamageExpression(0),
                    new DamageExpression(2),
                    new DamageExpression(1, DiceShape.D6, 1),
                    new DamageExpression(1, DiceShape.D6, 2)
                };

                damageCaused += opponant.TakeDamage(AttackType.Magic, hit, damageSpread, true);
            }

            damageCaused += DiceRoller.Roll(DiceShape.D6, opponant.Resilience);

            return((double)damageCaused / opponant.Health * 100);
        }
示例#11
0
        IEnumerator HandleBranch()
        {
            int value = 0;

            if (currentEvent.diceCheck != DiceType.none)
            {
                Dice diceToRoll = null;

                if (currentEvent.diceCheck == DiceType.explore)
                {
                    diceToRoll = FindObjectOfType <DiceContainer>().currentExploreDice;
                }
                else if (currentEvent.diceCheck == DiceType.combat)
                {
                    diceToRoll = FindObjectOfType <DiceContainer>().currentCombatDice;
                }

                playerDice.SetActive(true);
                DiceRoller diceRoller = playerDice.GetComponent <DiceRoller>();
                diceRoller.TriggerDiceRoll(diceToRoll);

                while (diceRoller.isRolling)
                {
                    yield return(null);
                }

                Side resultSide = diceToRoll.sides[diceRoller.resultIndex];
                value = resultSide.value;
            }

            TileEvent nextEvent = currentEvent.options[currentEvent.eventBranch.GetBranch(value)].nextEvent;

            MoveToNextEvent(nextEvent);
        }
示例#12
0
        public static String MagicCrit()
        {
            int    dice  = DiceRoller.randInt(1, 20);
            string magic = "";

            switch (dice)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                magic = "Double damage";
                break;

            case 11:
            case 12:
                magic = "Maximum Damage";
                break;

            case 13:
                magic = "Seismic (x2 damage and enemy is knocked prone)";
                break;

            case 14:
                magic = " Maddening (x2 damage and enemy is frightened for one round)";
                break;

            case 15:
                magic = "Binding (x2 damage and enemy is restrained for one minute)";
                break;

            case 16:
                magic = "Vampiric (x2 damage and caster heals 10 HP)";
                break;

            case 17:
                magic = "Deafening (x2 damage and enemy is deafened for one minute)";
                break;

            case 18:
                magic = "Dazzling (x2 damage and blinded for one round)";
                break;

            case 19:
                magic = "Forked (x2 damage and copy hits another foe within 10 feet for 1x damage)";
                break;

            case 20:
                magic = "Effortless (x2 damage and spell is not expended) ";
                break;
            }
            return(magic);
        }
示例#13
0
        public static String SlashingCrit()
        {
            int    dice  = DiceRoller.randInt(1, 20);
            string magic = "";

            switch (dice)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                magic = "Double damage";
                break;

            case 11:
            case 12:
                magic = "Maximum Damage";
                break;

            case 13:
                magic = "Leg (x2 damage and half movement until healed)";
                break;

            case 14:
                magic = "Right Arm (x2 damage and arm is disabled until healed)";
                break;

            case 15:
                magic = "Left Arm (x2 damage and arm is disabled until healed)";
                break;

            case 16:
                magic = "Chest (x2 damage and 5 damage/round until healed)";
                break;

            case 17:
                magic = "Gut (x2 damage and 10 damage/round until healed)";
                break;

            case 18:
                magic = "Head - Cheek (x2 damage and can't speak clearly until healed)";
                break;

            case 19:
                magic = "Head - Forehead (x2 damage and blinded for one round)";
                break;

            case 20:
                magic = "Head - Neck (x3 damage and free attack on adjacent foe if killed)";
                break;
            }
            return(magic);
        }
示例#14
0
        public static String BludgeoningCrit()
        {
            int    dice  = DiceRoller.randInt(1, 20);
            string magic = "";

            switch (dice)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                magic = "Double damage";
                break;

            case 11:
            case 12:
                magic = "Maximum Damage";
                break;

            case 13:
                magic = "Leg (x2 damage and can't move for one round)";
                break;

            case 14:
                magic = "Right Arm (x2 damage and held item lands 10 feet away)";
                break;

            case 15:
                magic = "Left Arm (x2 damage and held item lands 10 feet away)";
                break;

            case 16:
                magic = "Torso (x2 damage and knocked back 5 feet)";
                break;

            case 17:
                magic = "Spine (x2 damage and stunned for one round)";
                break;

            case 18:
                magic = "Head - Side (x2 damage and deafened for one minute)";
                break;

            case 19:
                magic = "Head - Skullcap (x2 damage and knocked prone)";
                break;

            case 20:
                magic = "Head - Face (x3 damage, prone and stunned for one round)";
                break;
            }
            return(magic);
        }
示例#15
0
        public static String PiercingCrit()
        {
            int    dice  = DiceRoller.randInt(1, 20);
            string magic = "";

            switch (dice)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                magic = "Double damage";
                break;

            case 11:
            case 12:
                magic = "Maximum Damage";
                break;

            case 13:
                magic = "Knee (x2 damage and can't move for one round)";
                break;

            case 14:
                magic = "Right Hand (x2 damage and hand is disabled until healed)";
                break;

            case 15:
                magic = "Left Hand (x2 damage and hand is disabled until healed)";
                break;

            case 16:
                magic = "Back (x2 damage and gain advantage on next attack)";
                break;

            case 17:
                magic = "Lung (x2 damage and 10 damage/round until healed)";
                break;

            case 18:
                magic = "Throat (x2 damage and can't speak until healed)";
                break;

            case 19:
                magic = "Heart (x3 damage)";
                break;

            case 20:
                magic = "Eye (x3 damage and blinded until healed)";
                break;
            }
            return(magic);
        }
示例#16
0
        private bool RollPrecipitationChance(bool reroll)
        {
            isRaining = false;

            if (reroll)
            {
                precipitationChanceRoll = DiceRoller.RollD100();
            }

            switch (precipitationFrequency)
            {
            case PrecipitationFrequency.Drought:
                if (precipitationChanceRoll <= 5)
                {
                    cloudCover = CloudCover.Overcast;
                    isRaining  = true;
                }
                break;

            case PrecipitationFrequency.Rare:
                if (precipitationChanceRoll <= 15)
                {
                    cloudCover = CloudCover.Overcast;
                    isRaining  = true;
                }
                break;

            case PrecipitationFrequency.Intermittent:
                if (precipitationChanceRoll <= 30)
                {
                    cloudCover = CloudCover.Overcast;
                    isRaining  = true;
                }
                break;

            case PrecipitationFrequency.Common:
                if (precipitationChanceRoll <= 60)
                {
                    cloudCover = CloudCover.Overcast;
                    isRaining  = true;
                }
                break;

            case PrecipitationFrequency.Constant:
                if (precipitationChanceRoll <= 95)
                {
                    cloudCover = CloudCover.Overcast;
                    isRaining  = true;
                }
                break;

            default:
                break;
            }

            currentTemp = tempBaseline + tempVariation;

            return(isRaining);
        }
        public void RollDiceSingleTest()
        {
            IDice      dice   = DiceManager.GetDice(rand.Next());
            DiceRoller roller = new DiceRoller();
            int        result = roller.RollDice(dice);

            Assert.IsTrue(result >= 1 && result <= dice.Sides);
        }
示例#18
0
        private string GetRandomPlantNameBasedOn(PlantCategories plantCategories)
        {
            List <Plant> plants = InformationLibrary.PlantClosedSearchByCategory(plantCategories);

            Plant plant = plants[DiceRoller.RandomRangeNumber(0, plants.Count - 1)];

            return(plant.Name);
        }
示例#19
0
        public void CanRollDice()
        {
            var roller = new DiceRoller();

            var result = roller.Roll(1);

            result.ShouldBeEquivalentTo(1);
        }
示例#20
0
 public void DressCHARGuard(DiceRoller roller, Actor actor)
 {
     actor.Doll.RemoveAllDecorations();
     actor.Doll.AddDecoration(DollPart.EYES, MALE_EYES[roller.Roll(0, MALE_EYES.Length)]);
     actor.Doll.AddDecoration(DollPart.SKIN, MALE_SKINS[roller.Roll(0, MALE_SKINS.Length)]);
     actor.Doll.AddDecoration(DollPart.HEAD, CHARGUARD_HEADS[roller.Roll(0, CHARGUARD_HEADS.Length)]);
     actor.Doll.AddDecoration(DollPart.LEGS, CHARGUARD_LEGS[roller.Roll(0, CHARGUARD_LEGS.Length)]);
 }
示例#21
0
    // Start is called before the first frame update
    void Start()
    {
        diceRoller   = GameObject.FindGameObjectWithTag("DiceObj").GetComponent <DiceRoller>();
        myPlayerInfo = GetComponentInParent <PlayerInfo>();
        moneyToSteal = diceRoller.numberRolled;

        Debug.Log("Money: " + moneyToSteal);
    }
示例#22
0
        public void RollIsInRange()
        {
            var roller = new DiceRoller();

            var result = roller.Roll(100);

            result.Should().BeInRange(1, 100);
        }
示例#23
0
        public void ParseRoll_BasicCriticalRoll()
        {
            var diceRoller = new DiceRoller(numberGenerator);

            Assert.That(diceRoller.ParseForCritical("+20").Equals("_Critical Success!_ "));
            Assert.That(diceRoller.ParseForCritical("+1").Equals("_Critical Fail!_ "));
            Assert.That(diceRoller.ParseForCritical("+15").Equals(string.Empty));
        }
示例#24
0
        public DiceManager(IEnumerable <Dice> dices)
        {
            this.dices = new ObservableDiceCollection(dices.ToList());

            diceRoller     = new DiceRoller(this.dices);
            diceSorter     = new DiceSorter(this.dices);
            diceStatistics = new DiceStatistics(this.dices);
        }
示例#25
0
        internal void CompileSuccess(TestVector test)
        {
            var compiler   = new Compiler();
            var program    = compiler.CompileScript(test.Script);
            var diceRoller = new DiceRoller(1000, new Random(0));
            var result     = program(diceRoller);

            Helpers.CompareObjects(test.Results, result);
        }
示例#26
0
        public void WhitespaceStress()
        {
            const string expression = "   1     d      20 +    5      ";
            var          result     = DiceRoller.Roll(expression);

            AssertRange(result.Total, 6, 25);
            Assert.AreEqual(5, result.Modifier);
            Assert.AreEqual(1, result.Rolls.Count);
        }
示例#27
0
        public void SimpleRollShorthandUppercase()
        {
            const string expression = "D20";
            var          result     = DiceRoller.Roll(expression);

            AssertRange(result.Total, 1, 20);
            Assert.AreEqual(0, result.Modifier);
            Assert.AreEqual(1, result.Rolls.Count);
        }
示例#28
0
        public void MultiDigitNumber()
        {
            const string expression = "2895";
            var          result     = DiceRoller.Roll(expression);

            Assert.AreEqual(2895, result.Total);
            Assert.AreEqual(2895, result.Modifier);
            Assert.AreEqual(0, result.Rolls.Count);
        }
示例#29
0
        public void CompoundRollWithShorthands()
        {
            const string expression = "d12+d8";
            var          result     = DiceRoller.Roll(expression);

            AssertRange(result.Total, 2, 20);
            Assert.AreEqual(0, result.Modifier);
            Assert.AreEqual(2, result.Rolls.Count);
        }
示例#30
0
        public void CompoundRoll()
        {
            const string expression = "1d20+2d6";
            var          result     = DiceRoller.Roll(expression);

            AssertRange(result.Total, 3, 32);
            Assert.AreEqual(0, result.Modifier);
            Assert.AreEqual(2, result.Rolls.Count);
        }