Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        // init players
        // TODO get players from player select scene, for now hard coded to 2 players and 2 enemies
        players = new List <PlayerClassBase>();
        for (int i = 1; i < Meta.CURRENTPLAYERS + 1; i++)
        {
            PlayerClassBase player = new Barbarian($"{i}", statusPrefab);  // todo this loop stupid, there are other classes (soon)
            player.Init();
            players.Add(player);
        }

        // set turn order
        // TODO for now just all players then all enemies
        currentPlayer = players[0];
        currentTurn   = new Tuple <string, int>(PLAYERS, 0); // access with currentTurn.Item1 and currentTurn.Item2
        Debug.Log($"Current player is {currentTurn.Item2}");

        phaseIndex = 0;

        // init enemies TODO make dynamic
        enemies = new List <EnemyBase>();
        EnemyBase e1 = new Bandit("1");

        enemies.Add(e1);
        enemies[0].Init();
        EnemyBase e2 = new Bandit("2");

        enemies.Add(e2);
        enemies[1].Init();

        SetupUi();

        lookCard    = 0;
        deselectedY = hand1.transform.position.y;
        selectedY   = deselectedY + cardLift;
        last_select = Time.time;
        last_play   = Time.time;

        for (int i = 0; i < Meta.MAX_HAND_SIZE; i++)
        {
            // find the card, set it inactive
            GameObject hcard = GameObject.Find($"Hand{i + 1}");
            GameObject hcd   = hcard.transform.Find("CardDesc").gameObject;
            hcd.GetComponent <MeshRenderer>().enabled = false;

            GameObject hcn = hcard.transform.Find("CardName").gameObject;
            hcn.GetComponent <MeshRenderer>().enabled = false;

            GameObject hcc = hcard.transform.Find("CardCost").gameObject;
            hcc.GetComponent <MeshRenderer>().enabled = false;
            hcard.GetComponent <Renderer>().enabled   = false;
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (currentTurn.Item1 == PLAYERS)
     {
         var passTurn = HandlePlayerTurn();
         if (passTurn)
         {
             if (currentTurn.Item2 + 1 >= players.Count)
             {
                 currentTurn = new Tuple <string, int>(ENEMIES, 0);
             }
             else
             {
                 currentPlayer = players[currentTurn.Item2 + 1];
                 currentTurn   = new Tuple <string, int>(PLAYERS, currentTurn.Item2 + 1);
                 phaseIndex    = 0; // set to draw phase of next turn
             }
         }
     }
     if (currentTurn.Item1 == "enemies")
     {
         var passTurn = HandleEnemyTurn();
         if (passTurn)
         {
             if (currentTurn.Item2 + 1 >= enemies.Count)
             {
                 currentPlayer = players[0];
                 currentTurn   = new Tuple <string, int>(PLAYERS, 0);
                 phaseIndex    = 0; // set to draw phase of next player turn
             }
             else
             {
                 currentTurn = new Tuple <string, int>(ENEMIES, currentTurn.Item2 + 1);
             }
         }
     }
     CleanUpDead();
 }
Ejemplo n.º 3
0
        public BarbarianCards()
        {
            cardPool = new Dictionary <string, CardBase>();

            // Common
            cardPool.Add("Axe Swing", new CardBase()
            {
                name     = "Axe Swing",
                cost     = 1,
                cardText = delegate(PlayerClassBase caster)
                {
                    int damMod = caster.getModdedDamage(this.GetCard("Axe Swing").baseDamage, DamageTypes.PHYSICAL);
                    return($"Deals {damMod} slashing damage");
                },
                cardType   = CardTypes.ATTACK,
                targetType = TargetTypes.ENEMY,
                baseDamage = 6,
                action     = delegate(object targetObj, PlayerClassBase caster)
                {
                    EnemyBase target = (EnemyBase)targetObj;
                    Barbarian me     = (Barbarian)caster;

                    int damMod = me.getModdedDamage(this.GetCard("Axe Swing").baseDamage, DamageTypes.PHYSICAL);
                    int meDmg  = (int)Mathf.Floor(damMod / 4);
                    target.TakeDamage(damMod, DamageTypes.PHYSICAL);
                    Debug.Log($"axe swing hit for {damMod}");
                }
            });
            cardPool.Add("Drop Shoulder", new CardBase()
            {
                name     = "Drop Shoulder",
                cost     = 1,
                cardText = delegate(PlayerClassBase caster)
                {
                    return("Gain 5 physical armor");
                },
                cardType   = CardTypes.SKILLS,
                targetType = TargetTypes.SELF,
                action     = delegate(object target, PlayerClassBase caster)
                {
                    PlayerClassBase t = (PlayerClassBase)target;
                    t.gainArmour(DamageTypes.PHYSICAL, 5);
                }
            });

            // Uncommon
            cardPool.Add("Enrage", new CardBase()
            {
                name     = "Enrage",
                cost     = 1,
                cardText = delegate(PlayerClassBase caster)
                {
                    return("Become Enraged\n(Increase physical damage by 50% and\nphysical damage taken by 25%)");
                },
                cardType   = CardTypes.AURA,
                targetType = TargetTypes.SELF,
                action     = delegate(object target, PlayerClassBase caster)
                {
                    PlayerClassBase t = (PlayerClassBase)target;
                    t.statuses.Add(new Enrage());
                    t.UpdateStatuses();
                }
            });

            cardPool.Add("Wild Swing", new CardBase()
            {
                name     = "Wild Swing",
                cost     = 2,
                cardText = delegate(PlayerClassBase caster)
                {
                    int damMod = caster.getModdedDamage(this.GetCard("Wild Swing").baseDamage, DamageTypes.PHYSICAL);
                    return($"Deals {damMod} slashing damage. \nTake a quarter as" +
                           " much physical \ndamage rounded down.");
                },
                cardType   = CardTypes.ATTACK,
                targetType = TargetTypes.ENEMY,
                baseDamage = 16,
                action     = delegate(object targetObj, PlayerClassBase caster)
                {
                    EnemyBase target = (EnemyBase)targetObj;
                    Barbarian me     = (Barbarian)caster;

                    int damMod = me.getModdedDamage(this.GetCard("Wild Swing").baseDamage, DamageTypes.PHYSICAL);
                    int meDmg  = (int)Mathf.Floor(damMod / 4);
                    target.TakeDamage(damMod, DamageTypes.PHYSICAL);
                    me.TakeDamage(meDmg, DamageTypes.PHYSICAL);
                    Debug.Log($"wild swing hits for {damMod} and caster takes {meDmg}");
                }
            });
        }