コード例 #1
0
ファイル: GameState.cs プロジェクト: Aggrathon/LudumDare40
 public void DefeatCharacter(CharacterWrapper c)
 {
     battleManager.CloseBattleUI();
     tournament.DefeatCombatant(c);
     if (league.Remove(c))
     {
         matchIndex++;
     }
     else
     {
         Debug.LogError("Could not find character to remove from league");
     }
     if (matchIndex >= league.Count)
     {
         for (int i = 0; i < league.Count; i++)
         {
             league[i].NextStage();
         }
         tournament.SetStage(league);
         if (tournament.IsTournamentOver)
         {
             return;
         }
         matchIndex = 1;
     }
     battleManager.Battle(league[matchIndex - 1], league[matchIndex]);
 }
コード例 #2
0
    IEnumerator AIvsAI(CharacterWrapper playerOne, CharacterWrapper playerTwo)
    {
        while (true)
        {
            yield return(null);

            Equipment.Ability oneAction;
            EquipmentWrapper  oneEquip = playerOne.GetAbility(out oneAction);
            Equipment.Ability twoAction;
            EquipmentWrapper  twoEquip = playerTwo.GetAbility(out twoAction);
            HandleAction(playerOne, playerTwo, ref oneAction, ref twoAction);
            HandleAction(playerTwo, playerOne, ref twoAction, ref oneAction);
            if (oneEquip != null)
            {
                playerOne.RemoveEquipment(oneEquip);
            }
            if (twoEquip != null)
            {
                playerTwo.RemoveEquipment(twoEquip);
            }
            if (playerOne.health <= 0 && playerTwo.health >= playerOne.health)
            {
                GameState.State.DefeatCharacter(playerOne);
                yield break;
            }
            else if (playerTwo.health <= 0 && playerOne.health > playerTwo.health)
            {
                GameState.State.DefeatCharacter(playerTwo);
                yield break;
            }
            playerOne.NextTurn();
            playerTwo.NextTurn();
        }
    }
コード例 #3
0
 public void LoadAllCharacters()
 {
     // Instantiate our entity wrappers.
     this.Characters = new CharacterWrapper();
     this.Characters.GetByName("jack - Copy");
     //this.Characters.GetByName("test1");
     //this.Characters.GetByName("test2");
     //this.Characters.GetByName("test3");
 }
コード例 #4
0
ファイル: TournamentUI.cs プロジェクト: Aggrathon/LudumDare40
    public void DefeatCombatant(CharacterWrapper character)
    {
        int i = currentStage.IndexOf(character);

        if (i >= 0)
        {
            stages[currentStageNum - 1].GetChild(i + 1).GetComponent <Image>().color = Color.red;
        }
    }
コード例 #5
0
 public void PlayerBattle(CharacterWrapper player, CharacterWrapper enemy)
 {
     this.player    = player;
     this.enemy     = enemy;
     enemyName.text = enemy.character.name;
     playerFightButton.interactable = true;
     reward = 7 + player.inventory.Count * 5;
     playerAnimation.SetLook(player.character.look);
     enemyAnimation.SetLook(enemy.character.look);
 }
コード例 #6
0
ファイル: RewardPopup.cs プロジェクト: Aggrathon/LudumDare40
 public static void Show(CharacterWrapper looser, int audRew, int matRew)
 {
     AudioPlayer.PlayTrumpet();
     instance.audienceReward.text = "" + audRew;
     instance.matchReward.text    = "" + matRew;
     instance.total.text          = "Total: " + (audRew + matRew) + " Denarius";
     GameState.State.money       += matRew + audRew;
     instance.looser = looser;
     instance.gameObject.SetActive(true);
 }
コード例 #7
0
ファイル: CardUI.cs プロジェクト: Aggrathon/LudumDare40
    public void SetCards(CharacterWrapper character, Action <EquipmentWrapper, Equipment.Ability> onSelect)
    {
        bool hasAction = false;
        List <EquipmentWrapper> list = character.equipment;
        bool hasInventory            = character.inventory.Count > 0;

        while (transform.childCount < list.Count + 2)
        {
            Instantiate(transform.GetChild(0).gameObject, transform);
        }
        for (int i = 0; i < list.Count; i++)
        {
            EquipmentWrapper e = list[i];
            Transform        t = transform.GetChild(i);
            t.GetChild(0).GetComponent <Image>().sprite = e.equipment.icon;
            t.GetChild(1).GetComponent <Text>().text    = e.ActionString();
            Button b = t.GetComponent <Button>();
            b.onClick.RemoveAllListeners();
            b.onClick.AddListener(() => { onSelect(e, null); });
            b.interactable = e.cooldown <= 0;
            hasAction      = hasAction | b.interactable;
            t.gameObject.SetActive(true);
        }
        for (int i = list.Count; i < transform.childCount; i++)
        {
            transform.GetChild(i).gameObject.SetActive(false);
        }
        if (hasInventory)
        {
            Transform t = transform.GetChild(list.Count);
            t.GetChild(0).GetComponent <Image>().sprite = changeIcon;
            Button b = t.GetComponent <Button>();
            b.onClick.RemoveAllListeners();
            t.GetChild(1).GetComponent <Text>().text = "Swap Equipment";
            b.onClick.AddListener(() => { onSelect(null, null); });
            b.interactable = true;
            t.gameObject.SetActive(true);
        }
        if (!hasAction)
        {
            Transform t = transform.GetChild(list.Count + 1);
            t.GetChild(0).GetComponent <Image>().sprite = changeIcon;
            Button b = t.GetComponent <Button>();
            b.onClick.RemoveAllListeners();
            Equipment.Ability playerAction = new Equipment.Ability();
            playerAction.action = Equipment.Action.none;
            playerAction.name   = "Wait";
            t.GetChild(1).GetComponent <Text>().text = "Wait";
            b.onClick.AddListener(() => { onSelect(null, playerAction); });
            b.interactable = true;
            t.gameObject.SetActive(true);
        }
    }
コード例 #8
0
ファイル: GameState.cs プロジェクト: Aggrathon/LudumDare40
 void Awake()
 {
     State  = this;
     league = new List <CharacterWrapper>();
     for (int i = 0; i < startingLeauge.Length; i++)
     {
         league.Add(new CharacterWrapper(startingLeauge[i]));
         if (startingLeauge[i].name == "Player")
         {
             player = league[league.Count - 1];
         }
     }
     ShuffleLeage();
     battleManager = GetComponent <BattleManager>();
 }
コード例 #9
0
 public void Battle(CharacterWrapper playerOne, CharacterWrapper playerTwo)
 {
     playerOne.NextMatch();
     playerTwo.NextMatch();
     if (playerOne == GameState.State.player)
     {
         PlayerBattle(playerOne, playerTwo);
     }
     else if (playerTwo == GameState.State.player)
     {
         PlayerBattle(playerTwo, playerOne);
     }
     else
     {
         StartCoroutine(AIvsAI(playerOne, playerTwo));
     }
 }
コード例 #10
0
    IEnumerator BattleOver(CharacterWrapper looser)
    {
        int mr = GameState.State.tournament.currentStageNum * (GameState.State.tournament.currentStageNum + 1) * 50;
        int ar = reward;

        yield return(new WaitForSeconds(0.1f));

        battleUI.SetActive(false);
        Inventory.Close();
        playerFightButton.interactable = false;
        GameState.State.DefeatCharacter(looser);
        yield return(new WaitForSeconds(0.1f));

        if (looser == player)
        {
            LostPopup.Show();
        }
        else
        {
            RewardPopup.Show(looser, ar, mr);
        }
    }
コード例 #11
0
    void DoDamage(CharacterWrapper c, float amount)
    {
        int rnd = Random.Range(0, c.equipment.Count);

        for (int i = 0; i < c.equipment.Count; i++)
        {
            var e = c.equipment[(rnd + i) % c.equipment.Count];
            if (e.equipment.type == Equipment.Type.armor)
            {
                c.health     -= Mathf.RoundToInt(amount * 0.5f);
                e.durability -= Mathf.RoundToInt(amount * 0.3f);
                if (e.durability <= 0)
                {
                    c.RemoveEquipment(e);
                    if (c == player)
                    {
                        FlashText.Flash("Your " + e.equipment.name.ToLower() + " broke!", Color.red);
                    }
                }
                return;
            }
        }
        c.health -= Mathf.RoundToInt(amount);
    }
コード例 #12
0
 public static void Show(CharacterWrapper cw)
 {
     instance.cw = cw;
     instance.Refresh();
     instance.gameObject.SetActive(true);
 }
コード例 #13
0
 public static void Save(IValueSink sink, CharacterWrapper value)
 {
     Value<string>.Save(sink, value.Item);
 }
コード例 #14
0
    void HandleAction(CharacterWrapper p1, CharacterWrapper p2, ref Equipment.Ability a1, ref Equipment.Ability a2, CombatAnimation ca1 = null, CombatAnimation ca2 = null)
    {
        switch (a1.action)
        {
        case Equipment.Action.none:
            break;

        case Equipment.Action.damage:
            if (ca1 != null)
            {
                ca1.PlayAttack();
            }
            if (a2.action != Equipment.Action.block)
            {
                DoDamage(p2, a1.amount);
                if (ca2 != null)
                {
                    ca2.PlayDamage();
                }
            }
            else if (p2 == player)
            {
                reward += 15;
            }
            break;

        case Equipment.Action.damageStrength:
            if (ca1 != null)
            {
                ca1.PlayAttack();
            }
            if (a2.action != Equipment.Action.block)
            {
                float damage = p1.strength * a1.amount;
                DoDamage(p2, damage);
                if (ca2 != null)
                {
                    ca2.PlayDamage();
                }
            }
            else if (p2 == player)
            {
                reward += 15;
            }
            break;

        case Equipment.Action.damageAgility:
            if (ca1 != null)
            {
                ca1.PlayAttack();
            }
            if (a2.action != Equipment.Action.block)
            {
                float damage = p1.agility * a1.amount;
                DoDamage(p2, damage);
                if (ca2 != null)
                {
                    ca2.PlayDamage();
                }
            }
            else if (p2 == player)
            {
                reward += 15;
            }
            break;

        case Equipment.Action.block:
            if (ca1 != null)
            {
                ca1.PlayBlock();
            }
            break;

        case Equipment.Action.cheer:
            if (ca1 != null)
            {
                ca1.PlayUtility();
            }
            if (p1 == player)
            {
                reward += 30;
            }
            break;

        default:
            break;
        }
    }
コード例 #15
0
 public static void Save(IValueSink sink, CharacterWrapper value)
 {
     Value <string> .Save(sink, value.Item);
 }