public void Init(Player player, DieFace dieFace)
        {
            if (Utils.isMissing("StatPanelController", new UnityEngine.Object[] { LabelText, IncreaseButton, DecreaseButton, BaseText, DiceText, CardsText, TotalText }))
            {
                return;
            }

            Player  = player;
            DieFace = dieFace;

            if (dieFace == DieFace.Attack)
            {
                baseStat = 1;
            }
            LabelText.text = dieFace + " ";

            IncreaseButton.onClick.AddListener(delegate { IncreaseBaseStat(true); });
            DecreaseButton.onClick.AddListener(delegate { IncreaseBaseStat(false); });

            player.RegisterOnCardAddedCallback(OnCardAdded);
            player.RegisterOnCardRemovedCallback(OnCardRemoved);
            player.RegisterOnDieAddedCallback(OnDieAdded);
            player.RegisterOnDieRemovedCallback(OnDieRemoved);
            player.RegisterOnChargeChangedCallback(OnChargeChanged);
        }
Beispiel #2
0
    private void SkillTest()
    {
        player = GSC.map.SelectedUnit.GetComponent <Unit>();
        int[] temp = new int[3];
        if (skillTest == 0)
        {
            int damage = 0;
            for (int i = 0; i < player.strength.Length; i++)
            {
                DieFace d = GSC.map.dice[player.strength[i]].faces[Random.Range(0, 6)];
                damage += d.hit;
                //Debug.Log(damage);
            }
            if (damage > 3)
            {
                Debug.Log("You got 2 more medpacks");
                GSC.items["medpack"] += 2;
            }
            else
            {
                Debug.Log("Skill test failed");
            }
        }

        if (skillTest == 1)
        {
            temp = GSC.map.SelectedUnit.GetComponent <Unit>().insight;
        }

        if (skillTest == 2)
        {
            temp = GSC.map.SelectedUnit.GetComponent <Unit>().tech;
        }
    }
Beispiel #3
0
    private void SetupForGame()
    {
        originalCameraShakeStrength = cameraShakeStrength;

        gameOverPanel.Hide();

        for (int i = 0; i < gameGrid.Length; i++)
        {
            gameGrid[i].SetToUnused();
        }

        DieFace startingFace = dice[0].RandomFace();

        if (recorder.dice[0] == null || !retrySame)
        {
            recorder.dice[0] = startingFace;
        }
        else
        {
            startingFace = recorder.dice[0];
        }
        GetSquare(0, 0).SetViewAnimated(startingFace);
        recordDieIndex = 1;

        selectedDie         = null;
        selectedSquare      = null;
        cameraShakeStrength = 10f;

        CalculateScore();
        StartRound();
    }
Beispiel #4
0
        public void TestDieFaceConstruction()
        {
            var    die     = new DieFace("Qu");
            String dieFace = die.FaceCharacter;

            Assert.AreEqual("Qu", dieFace);
        }
Beispiel #5
0
        public DieFace RollDie()
        {
            Random random = new Random();
            int    face   = random.Next(1, 7);

            dieFace = face == 1 ? DieFace.ONE: face == 2 ? DieFace.TWO: face == 3 ? DieFace.THREE:face == 4 ? DieFace.FOUR:
                      face == 5 ? DieFace.FIVE: DieFace.SIX;
            return(dieFace);
        }
Beispiel #6
0
        public Sprite GetSpriteByDieFace(DieFace dieface)
        {
            if (!IconSprites.ContainsKey(dieface.ToString()))
            {
                Debug.LogError("Missing a sprite? " + dieface.ToString());
                return(null);
            }

            return(IconSprites[dieface.ToString()]);
        }
Beispiel #7
0
    List <GameObject> parseDiceList(string listFile)
    {
        //create new parser/readers
        List <GameObject> toReturn = new List <GameObject>();

        string[] fileLines = System.IO.File.ReadAllLines(@listFile);

        //get next line of die faces
        for (int i = 0; i < fileLines.Length; i++)
        {
            string currLine = fileLines[i];

            if (currLine[0] != '#')
            {
                string[] splitLineString = currLine.Split(',');
                int[]    splitLineInt    = new int[12];

                GameObject newDice = (GameObject)Instantiate(Resources.Load("Prefabs/Dice"));
                newDice.GetComponent <BoxCollider2D>().enabled = false;
                Dice      dice  = newDice.GetComponent <Dice>();
                DieFace[] faces = new DieFace[6];

                if (splitLineString.Length != 12)
                {
                    Debug.Log("(Line " + i + "): Dice List Parser could not parse invalid line: \n" + currLine);
                }
                else
                {
                    for (int j = 0; j < splitLineString.Length; j++)
                    {
                        try {
                            splitLineInt[j] = int.Parse(splitLineString[j]);
                        }
                        catch (System.FormatException e)
                        {
                            Debug.Log("(Line " + i + "): Dice List Parser could not parse element \"" + splitLineString[j] +
                                      "\"\nException thrown: " + e);
                        }
                    }
                    for (int j = 0; j < faces.Length; j++)
                    {
                        faces[j]       = new DieFace();
                        faces[j].Type  = splitLineInt[j];
                        faces[j].Color = splitLineInt[j + 6];
                    }

                    dice.DieFaces = faces;

                    toReturn.Add(newDice);
                }
            }
        }
        return(toReturn);
    }
Beispiel #8
0
 public void Returns_Correct_Value()
 {
     DieFaceGrids.Grids
     .ForEach(gridKvp => {
         // Arrange
         var sut      = new DieFace(gridKvp.Value);
         var expected = gridKvp.Key;
         // Act
         var actual = sut.Value;
         // Assert
         Assert.Equal(expected, actual);
     });
 }
Beispiel #9
0
    public void SetFace(DieFace newFace)
    {
        currentFace = newFace;

        if (textComponent != null)
        {
            textComponent.text = currentFace.text;
        }

        if (imageComponent != null)
        {
            imageComponent.color  = currentFace.color;
            imageComponent.sprite = currentFace.sprite;
        }
    }
Beispiel #10
0
    public void Roll()
    {
        currentFace = RandomFace();

        if (textComponent != null)
        {
            textComponent.text = currentFace.text;
        }

        if (imageComponent != null)
        {
            imageComponent.color  = currentFace.color;
            imageComponent.sprite = currentFace.sprite;
        }
    }
Beispiel #11
0
    public void SetViewAnimated(DieFace newFace)
    {
        currentFace = newFace;

        if (textComponent != null)
        {
            textComponent.text = currentFace.text;
        }

        if (imageComponent != null)
        {
            imageComponent.sprite = currentFace.sprite;

            Color noAlpha = currentFace.color; noAlpha.a = 0f;
            imageComponent.color = noAlpha;
            imageComponent.DOFade(1f, 0.4f).SetEase(Ease.OutCubic);

            imageComponent.rectTransform.localScale = Vector2.zero;
            imageComponent.rectTransform.DOScale(1f, 0.4f).SetEase(Ease.OutCubic);
        }
    }
Beispiel #12
0
    IEnumerator startCombat()
    {
        accuracy = 0;
        damage   = 0;
        surge    = 0;
        block    = 0;
        evade    = 0;
        dodge    = 0;

        initAttack.transform.gameObject.SetActive(false);

        yield return(new WaitForSeconds(1));

        for (int i = 0; i < attackDice.Length; i++)
        {
            if (i < attacker.weapon.weaponDice.Length)
            {
                DieFace d = GSC.data.dice[attacker.weapon.weaponDice[i]].faces[Random.Range(0, 6)];
                attackDice[i].color  = Color.white;
                attackDice[i].sprite = d.face;
                // add attack audio here
                accuracy += d.accuracy;
                damage   += d.hit;
                surge    += d.surge;
            }
            else
            {
                attackDice[i].color = Color.clear;
            }
            yield return(new WaitForSeconds(.5f));
        }

        if (attacker.weaken && surge > 0)
        {
            surge--;
        }

        attackResults.text = string.Format(accuracy + " Accuracy, " + damage + " Hit, " + surge + " Surge");
        attackResults.transform.gameObject.SetActive(true);

        yield return(new WaitForSeconds(.5f));

        if (accuracy >= attacker.attackRange)
        {
            mainText.text = string.Format("Attack Hit!");
        }
        else
        {
            mainText.text = string.Format("Range: " + attacker.attackRange + " Accuracy: " + accuracy);
        }
        yield return(new WaitForSeconds(.5f));

        for (int i = 0; i < defDice.Length; i++)
        {
            if (i < defender.defDice.Length)
            {
                DieFace d = GSC.data.dice[defender.defDice[i]].faces[Random.Range(0, 6)];
                defDice[i].color  = Color.white;
                defDice[i].sprite = d.face;
                // add defend audio here
                block += d.block;
                evade += d.evade;
                dodge += d.dodge;
            }
            else
            {
                defDice[i].color = Color.clear;
            }
            yield return(new WaitForSeconds(.5f));
        }

        if (defender.weaken && evade > 0)
        {
            evade--;
        }

        surge -= evade;
        if (surge < 0)
        {
            surge = 0;
        }

        if (dodge > 0)
        {
            defenseResults.text = string.Format("Attack Dodged!");
        }
        else
        {
            defenseResults.text = string.Format(block + " Block, " + evade + " Evade");
        }

        defenseResults.transform.gameObject.SetActive(true);
        if (surge > 0)
        {
            modifyDice.interactable = true;
        }
        initAttack.transform.gameObject.SetActive(false);
        confirm.transform.gameObject.SetActive(true);
        yield return(null);
    }
Beispiel #13
0
    /*
     * Rolls
     */
    void rollDice()
    {
        int index1 = Random.Range(0, DiceList.Count);

        if (newDice1 != null)
        {
            newDice1.GetComponent <SpriteRenderer>().enabled = false;
        }

        newDice1 = DiceList[index1];
        DiceList.RemoveAt(index1);
        Dice dice1 = newDice1.GetComponent <Dice>();

        newDice1.transform.position = new Vector2(15 + xOffset, 6 + yOffset);
        newDice1.transform.parent   = this.transform;
        int face1 = Random.Range(0, 6);

        dice1.RolledFace = dice1.DieFaces[face1];
        DieFace rolledFace1 = dice1.RolledFace;

        newDice1.GetComponent <SpriteRenderer>().sprite = diceFaceSpriteList[rolledFace1.Color][rolledFace1.Type];
        newDice1.GetComponent <BoxCollider2D>().enabled = true;

        int index2 = Random.Range(0, DiceList.Count);

        if (newDice2 != null)
        {
            newDice2.GetComponent <SpriteRenderer>().enabled = false;
        }

        newDice2 = DiceList[index2];
        DiceList.RemoveAt(index2);
        Dice dice2 = newDice2.GetComponent <Dice>();

        newDice2.transform.position = new Vector2(15 + xOffset, 5 + yOffset);
        newDice2.transform.parent   = this.transform;
        int face2 = Random.Range(0, 6);

        dice2.RolledFace = dice2.DieFaces[face2];
        DieFace rolledFace2 = dice2.RolledFace;

        newDice2.GetComponent <SpriteRenderer>().sprite = diceFaceSpriteList[rolledFace2.Color][rolledFace2.Type];
        newDice2.GetComponent <BoxCollider2D>().enabled = true;

        int index3 = Random.Range(0, DiceList.Count);

        if (newDice3 != null)
        {
            newDice3.GetComponent <SpriteRenderer>().enabled = false;
        }

        newDice3 = DiceList[index3];
        DiceList.RemoveAt(index3);
        Dice dice3 = newDice3.GetComponent <Dice>();

        newDice3.transform.position = new Vector2(15 + xOffset, 4 + yOffset);
        newDice3.transform.parent   = this.transform;
        int face3 = Random.Range(0, 6);

        dice3.RolledFace = dice3.DieFaces[face3];
        DieFace rolledFace3 = dice3.RolledFace;

        newDice3.GetComponent <SpriteRenderer>().sprite = diceFaceSpriteList[rolledFace3.Color][rolledFace3.Type];
        newDice3.GetComponent <BoxCollider2D>().enabled = true;

        RolledDice = new List <GameObject>();
        RolledDice.Add(newDice1);
        RolledDice.Add(newDice2);
        RolledDice.Add(newDice3);

        state = State.ROLLED;
    }
Beispiel #14
0
 public Die()
 {
     this.dieFace = DieFace.ONE;
 }