Beispiel #1
0
 public void CalcUpcoming()
 {
     if (remove.Count() != 0)
     {
         Queue <CreatureBattleStatusController> NowUpcoming = new Queue <CreatureBattleStatusController>();
         while (Upcoming.Count() > 0)
         {
             CreatureBattleStatusController creature = Upcoming.Dequeue();
             if (!remove.Contains(creature))
             {
                 NowUpcoming.Enqueue(creature);
             }
         }
         remove.Clear();
     }
     while (Upcoming.Count() < 6)
     {
         turnIndex++;
         foreach (CreatureBattleStatusController creature in takeTurns)
         {
             //To do: get a better formula
             if (turnIndex % (1000 - creature.getSpeed()) == 0)
             {
                 Upcoming.Enqueue(creature);
             }
         }
     }
     for (int i = 0; i < 5; i++)
     {
         TurnLabels[i].text = Upcoming.ElementAt <CreatureBattleStatusController>(i).Target.GetName();
     }
 }
Beispiel #2
0
    public CreatureBattleStatusController getNextSpirit()
    {
        CalcUpcoming();
        CreatureBattleStatusController next = Upcoming.Dequeue();

        return(next);
    }
    public void Remove(CreatureBattleStatusController CreatureStatus)
    {
        Creature dead = Party[ActiveIndices[CreatureStatus.index]];

        ChooseNew(CreatureStatus);
        Party.Remove(dead);
    }
    public void ChooseNew(CreatureBattleStatusController CreatureStatus)
    {
        if (IsPlayer)
        {
            int healthyCount = 0;
            foreach (Creature member in Party)
            {
                if (member.currentActiveHealth > 0)
                {
                    healthyCount++;
                }
            }
            if (healthyCount > 1)
            {
                GameObject.Find("EventSystem").GetComponent <BattleMenu>().SelectSpirits(CreatureStatus);
            }
        }
        else
        {
            //Todo: make this be based on AI
            for (int i = 0; i < Party.Count; i++)
            {
                if (!Party[i].Equals(Party[ActiveIndices[0]]) && !Party[i].Equals(Party[ActiveIndices[1]]) && Party[i].currentActiveHealth > 0)
                {
                    ActiveIndices[CreatureStatus.index] = i;
                    CreatureStatus.SetTarget(Party[i]);
                    break;
                }
            }
        }

        UpdateIndicators();
    }
Beispiel #5
0
    public void execute(CreatureBattleStatusController attacker, CreatureBattleStatusController defender, float damageModifier, bool MakesContact)
    {
        user   = attacker;
        target = defender;
        this.damageModifier = damageModifier;
        this.MakesContact   = MakesContact;

        GetType().GetMethod("" + effectType.ToString()).Invoke(this, null);
    }
Beispiel #6
0
    public void Buff(CreatureBattleStatusController creatureToBuff)
    {
        Debug.Log(creatureToBuff.Target.GetName() + " used Buff (WIP)");
        GameObject ES = GameObject.Find("EventSystem");

        ES.GetComponent <BattleMenu>().messageBoxActions.Enqueue(() => ES.GetComponent <BattleMenu>().ShowMessage(creatureToBuff.Target.GetName() + " used Buff (WIP)"));
        //usage:
        //power: how much the stat is changed by (%)
        //chance: the chance of the stat change happening
    }
Beispiel #7
0
 public void ApplyDamage(float damageToTake, CreatureBattleStatusController damageTarget)
 {
     if (damageTarget.GetCreature().currentActiveHealth > damageToTake)  //No damage to crit health, just reduce active health
     {
         damageTarget.GetCreature().currentActiveHealth -= damageToTake;
     }
     else                                                                //No active health remaning, damage crit health
     {
         damageToTake -= damageTarget.GetCreature().currentActiveHealth; //How much of the damage wasn't used reducing the active health to 0?
         damageTarget.GetCreature().currentActiveHealth   = 0;
         damageTarget.GetCreature().currentCriticalHealth = Mathf.Max(0, damageTarget.GetCreature().currentCriticalHealth - damageToTake);
     }
     damageTarget.GetCreature().currentActiveHealth = Mathf.Min(damageTarget.GetCreature().currentActiveHealth, damageTarget.GetCreature().getMaxActiveHealth());
 }
 public void SwitchOut()
 {
     //Todo: make the debugs appear in-game
     if (selectedCreature.currentActiveHealth <= 0)
     {
         Debug.Log("No health");
         CloseActions();
     }
     else if (GameObject.Find("PlayerStatus").GetComponent <PartyBattleStatusController>().IsCreatureActive(selectedCreature))
     {
         Debug.Log("Already active");
         CloseActions();
     }
     else
     {
         ReturnToLast();
         CreatureBattleStatusController targetStatus = defeatedStatus == null ? ((BattleMenu)LastMenu).GetAttacker() : defeatedStatus;
         targetStatus.SetTarget(selectedCreature);
         ((BattleMenu)LastMenu).messageBoxActions.Enqueue(() => ((BattleMenu)LastMenu).EndTurn());
         defeatedStatus = null;
     }
 }
Beispiel #9
0
 public bool execute(CreatureBattleStatusController attacker, CreatureBattleStatusController defender)
 {
     //put a check for accuracy here:
     //if it fails the attack misses
     if (Random.Range(0.0f, 1.0f) <= Accuracy)
     {
         //then the move hits
         this.Attacker = attacker;
         this.Defender = defender;
         if (Effects != null)
         {
             foreach (Effect effect in Effects)
             {
                 effect.execute(attacker, defender, getModifier(), MakesContact);
             }
         }
         return(true);
     }
     else
     {
         //move misses
         return(false);
     }
 }
 //This is called upon fainting/death. The supplied controller is what gets replaced instead of the attacker.
 //Leaving this menu without making a selection is also disabled.
 public void SelectSpirits(CreatureBattleStatusController CreatureStatus)
 {
     GameObject.Find("EventSystem").GetComponent <BattleMenu>().OpenNewMenu("PartyScreen");
     defeatedStatus            = CreatureStatus;
     SceneManager.sceneLoaded += SetDefeated;
 }
    //Processing performed at the start of a turn before player/ai input
    public void BeginTurn()
    {
        if (ES.GetComponent <TurnManager>().whoWins().Equals("Player"))
        {
            Debug.Log("Player Wins");
            playerWon = true;
            Close();
        }
        else if (ES.GetComponent <TurnManager>().whoWins().Equals("Computer"))
        {
            Debug.Log("Player Looses");
            playerWon = false;
            Close();
        }
        else if (ES.GetComponent <TurnManager>().whoWins().Equals("No-one"))
        {
            Attacker = ES.GetComponent <TurnManager>().getNextSpirit();
            Attacker.setDefending(false); //get rid of the defense move on their next turn
            Debug.Log(Attacker.Target.GetName() + "'s turn beginning.");
            //Status effects that take place at the START of the turn go here
            float randNum         = UnityEngine.Random.Range(0.0f, 1.0f);
            float FrostBiteChance = 0.5f;
            float ParalysisChance = 0.5f;
            float RabidChance     = 0.5f;
            bool  StatusHappened  = false;
            switch (Attacker.statusEffect)
            {
            case StatusEffect.FrostBite:
                //chance of no action
                if (randNum <= FrostBiteChance)
                {
                    //then no action occurs
                    StatusHappened = true;
                    messageBoxActions.Enqueue(() => ShowMessage(Attacker.Target.GetName() + " did not take an action due to Frost Bite."));
                    messageBoxActions.Enqueue(() => EndTurn());
                }
                break;

            case StatusEffect.Paralysis:
                //chance of no action
                if (randNum <= ParalysisChance)
                {
                    //then no action occurs
                    StatusHappened = true;
                    messageBoxActions.Enqueue(() => ShowMessage(Attacker.Target.GetName() + " did not take an action due to Paralysis."));
                    messageBoxActions.Enqueue(() => EndTurn());
                }
                break;

            case StatusEffect.Rabid:
                //chance of random action
                if (randNum <= RabidChance)
                {
                    //then a random action occurs
                    StatusHappened = true;
                    RandomAction();
                }
                break;

            default:
                break;
            }
            if (!StatusHappened)
            {
                AskForAction();
            }
        }
    }
Beispiel #12
0
 public void removeFromPlay(CreatureBattleStatusController creature)
 {
     takeTurns.Remove(creature);
     remove.Add(creature);
 }
 public void SetDefeated(CreatureBattleStatusController CreatureStatus)
 {
     defeatedStatus = CreatureStatus;
 }