예제 #1
0
    public void UseAbility()
    {
        if (onGround)
        {
            onGround     = false;
            sprite.color = new Color(1, 1, 1, 1);
        }

        foreach (behaviour_AI behaviour in behaviours)
        {
            behaviour.currentCoolDown--;
        }
        foreach (behaviour_AI behaviour in behaviours)
        {
            if (BattleAI.CheckCondition(behaviour, this, _system.enemies))
            {
                if (behaviour.behaviour == AI_behaviour.summon)
                {
                    _system.Enemy_Summons((int)behaviour.B_Value1, GetComponent <EnemySummon>().GetEnemyArray((int)behaviour.B_Value2));
                    return;
                }
                currentAbility = behaviour.abilities[Random.Range(0, behaviour.abilities.Length)];
                currentAbility.Set_enemy_target(BattleAI.FindTarget(behaviour, this, _system.enemies, FindObjectOfType <PlayerStats>()));
                currentAbility.SetUser(gameObject);

                _system.Enemy_Acts(currentAbility);
                return;
            }
        }
    }
예제 #2
0
        private void AITurn(Battler user)
        {
            Battler  opponent = GetOpponent(user);
            BattleAI ai       = new BattleAI(ref user, ref opponent);

            while (ai.KeepMoving())
            {
                if (ai.KeepMoving())
                {
                    Monster Summon   = ai.GetBestSummon();
                    int     openslot = ai.GetFirstOpenMonsterZone();
                    if (Summon != null && openslot >= 0)
                    {
                        user.Summon(Summon, ai.GetFirstOpenMonsterZone());
                        ShowText(user.Name + " summoned " + Summon.Name + "!");
                    }

                    //TODO: check for monster effects

                    for (int i = 0; i < user.Field.Length; i++)
                    {
                        if (user.Field.Monsters[i] != null)
                        {
                            Monster mon = (Monster)user.Field.Monsters[i];
                            if (mon.CanAttack)
                            {
                                if (ai.Opponent.HasMonstersSummoned())
                                {
                                    int targetIndex = ai.GetBestTarget(i);
                                    if (targetIndex > -1)
                                    {
                                        Monster target = (Monster)opponent.Field.Monsters[targetIndex];
                                        MonsterAttacking(user, mon, target, i, targetIndex);
                                    }
                                    else
                                    {
                                        mon.CanAttack = false;
                                        return;
                                    }
                                }
                                else
                                {
                                    StealingMana(user, mon, i);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
 internal void ReplaceActiveMenu()
 {
     activeMenu.transform.position = units[0].transform.position;
     if (units[0].tag.Equals("Player"))
     {
         activeMenu.SetActive(true);
     }
     else
     {
         int dmg = units[0].GetComponent <Unit>().Attack(1);
         activeMenu.SetActive(false);
         BattleAI.ChoiceTarget();
         //  print(units[0].name + " ударил " + target.name + " на " + dmg + "осталось ХП " + target.GetComponent<Unit>().hitPoint);
         Fight(dmg);
     }
 }
예제 #4
0
    internal void StartBattle()
    {
        units[0].GetComponent <Unit>().ActivateEffect(); //активация эффекта
        if (units[0].tag.Equals("Player"))
        {
            units[0].GetComponent <SelectUnit>().self.SetActive(true);
            activeMenu.GetComponent <ActiveMenu>().ReplaceActiveMenu(units);
        }
        else
        {
            //прописать AI

            // skill = units[0].GetComponent<Unit>().activeSkills[0];
            BattleAI.ChoiceSkill(units[0]);
            BattleAI.ChoiceTarget();
            Fight();
        }
    }
예제 #5
0
    static void Main(string[] args)
    {
        // game loop
        while (true)
        {
            var me       = new Player(Console.ReadLine());
            var opponent = new Player(Console.ReadLine());

            var isDraftPhase = me.mana == 0;

            int opponentHand = int.Parse(Console.ReadLine());
            int cardCount    = int.Parse(Console.ReadLine());

            Card[] cards = new Card[cardCount];

            for (int i = 0; i < cardCount; i++)
            {
                var description = Console.ReadLine();
                Game.Debug(description);
                cards[i] = new Card(description);
            }

            if (isDraftPhase)
            {
                var draftAI = new DraftAI(cards);
                var command = draftAI.GetCommand();
                Console.WriteLine(command.ToString());
            }
            else
            {
                var battleAI = new BattleAI(me, opponent, cards);
                var commands = battleAI.GetCommands();

                Console.WriteLine(string.Join(";", commands.Select(c => c.ToString()).ToArray()));
            }
        }
    }
예제 #6
0
 void Awake()
 {
     instance = this;
 }
예제 #7
0
 // Use this for initialization
 void Awake()
 {
     battleAI = GetComponent <BattleAI>();
 }
예제 #8
0
    /// <summary>
    /// Allows to highlight or unhighlight the entity
    /// </summary>
    //public bool Highlight
    //{
    //    get { return BattleUI.HighlighterObject.activeSelf; }
    //    set
    //    {
    //        BattleUI.HighlighterObject.SetActive(value);
    //        GetComponent<ClickableOnEnable>().enabled = value;
    //    }
    //}

    #endregion

    #region Initialisation
    void Start()
    {
        BattleAI = new BattleAI(this);
    }
예제 #9
0
 public static BattleAI[] Remove(int index, BattleAI[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(BattleAI str in list) tmp.Add(str);
     tmp.RemoveAt(index);
     return tmp.ToArray(typeof(BattleAI)) as BattleAI[];
 }
예제 #10
0
 public static BattleAI[] Add(BattleAI n, BattleAI[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(BattleAI str in list) tmp.Add(str);
     tmp.Add(n);
     return tmp.ToArray(typeof(BattleAI)) as BattleAI[];
 }
예제 #11
0
    public void LoadData()
    {
        ArrayList data = XMLHandler.LoadXML(dir+filename);

        if(data.Count > 0)
        {
            foreach(Hashtable entry in data)
            {
                if(entry[XMLHandler.NODE_NAME] as string == BattleAIData.AIS)
                {
                    if(entry.ContainsKey(XMLHandler.NODES))
                    {
                        ArrayList subs = entry[XMLHandler.NODES] as ArrayList;
                        name = new string[subs.Count];
                        ai = new BattleAI[subs.Count];
                        foreach(Hashtable val in subs)
                        {
                            if(val[XMLHandler.NODE_NAME] as string == BattleAIData.AI)
                            {
                                int i = int.Parse((string)val["id"]);
                                ai[i] = new BattleAI();
                                ai[i].needed = (AIConditionNeeded)System.Enum.Parse(typeof(AIConditionNeeded), (string)val["needed"]);
                                ai[i].condition = new AICondition[int.Parse((string)val["conditions"])];

                                ArrayList s = val[XMLHandler.NODES] as ArrayList;
                                foreach(Hashtable ht in s)
                                {
                                    if(ht[XMLHandler.NODE_NAME] as string == BattleAIData.NAME)
                                    {
                                        name[i] = ht[XMLHandler.CONTENT] as string;
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == BattleAIData.CONDITION)
                                    {
                                        int j = int.Parse((string)ht["id"]);
                                        ai[i].condition[j] = new AICondition();
                                        ai[i].condition[j].target = (AIConditionTarget)System.Enum.Parse(typeof(AIConditionTarget), (string)ht["target"]);
                                        ai[i].condition[j].type = (AIConditionType)System.Enum.Parse(typeof(AIConditionType), (string)ht["type"]);
                                        if(AIConditionType.STATUS.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].statusID = int.Parse((string)ht["statusid"]);
                                            ai[i].condition[j].statusSetter = (ValueSetter)System.Enum.Parse(typeof(ValueSetter), (string)ht["statussetter"]);
                                            ai[i].condition[j].statusValue = int.Parse((string)ht["statusvalue"]);
                                            ai[i].condition[j].statusCheck = (ValueCheck)System.Enum.Parse(typeof(ValueCheck), (string)ht["statuscheck"]);
                                            ai[i].condition[j].checkStatusID = int.Parse((string)ht["checkstatusid"]);
                                        }
                                        else if(AIConditionType.EFFECT.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].effectID = int.Parse((string)ht["effectid"]);
                                            ai[i].condition[j].effectActive = (ActiveSelection)System.Enum.Parse(typeof(ActiveSelection), (string)ht["effectactive"]);
                                        }
                                        else if(AIConditionType.ELEMENT.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].elementID = int.Parse((string)ht["elementid"]);
                                            ai[i].condition[j].elementValue = int.Parse((string)ht["elementvalue"]);
                                            ai[i].condition[j].elementCheck = (ValueCheck)System.Enum.Parse(typeof(ValueCheck), (string)ht["elementcheck"]);
                                        }
                                        else if(AIConditionType.TURN.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].turn = int.Parse((string)ht["turn"]);
                                            ai[i].condition[j].everyTurn = bool.Parse((string)ht["everyturn"]);
                                        }
                                        else if(AIConditionType.CHANCE.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].chance = int.Parse((string)ht["chance"]);
                                        }
                                        else if(AIConditionType.DEATH.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].isDead = bool.Parse((string)ht["isdead"]);
                                        }
                                        else if(AIConditionType.RACE.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].raceID = int.Parse((string)ht["race"]);
                                        }
                                        else if(AIConditionType.SIZE.Equals(ai[i].condition[j].type))
                                        {
                                            ai[i].condition[j].sizeID = int.Parse((string)ht["size"]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }