Beispiel #1
0
Datei: Ai.cs Projekt: shuyi3/AIPJ
        //private static Ai instance;

        //public static Ai Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Ai());
        //    }
        //}

        public Ai(Silverfish sf)
        {
            this.sf = sf;
            this.nextMoveGuess = new Playfield(sf);
            PenalityManager penman = sf.PenalityManager;
            hp = sf.Hrtprozis;
            hm = sf.Handmanager;
            help = sf.Helpfunctions;

            this.nextMoveGuess = new Playfield (sf) { mana = -100 };

            this.mainTurnSimulator = new MiniSimulator(sf, maxdeep, maxwide, 0); // 0 for unlimited
            this.mainTurnSimulator.setPrintingstuff(true);

            /*this.nextTurnSimulator = new MiniSimulatorNextTurn();
            this.enemyTurnSim = new EnemyTurnSimulator();
            this.enemySecondTurnSim = new EnemyTurnSimulator();*/

            for (int i = 0; i < sf.Settings.numberOfThreads; i++)
            {
                this.nextTurnSimulator.Add(new MiniSimulatorNextTurn(sf));
                this.enemyTurnSim.Add(new EnemyTurnSimulator(sf));
                this.enemySecondTurnSim.Add(new EnemyTurnSimulator(sf));

                this.nextTurnSimulator[i].thread = i;
                this.enemyTurnSim[i].thread = i;
                this.enemySecondTurnSim[i].thread = i;
            }

        }
Beispiel #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Constantly move player to the desired position with movement speed.
        Vector2 vectorToDesiredPoint = desiredPosition - new Vector2(transform.position.x, transform.position.y);

        if (vectorToDesiredPoint.magnitude > 0.1f)
        {
            playerRigidbody.velocity = vectorToDesiredPoint;
            playerRigidbody.velocity = playerRigidbody.velocity.normalized * movementSpeed;

            int angle = (int)Helpfunctions.getAngle(vectorToDesiredPoint, new Vector2(0, 0)) + 90;
            if (angle > 180 - 45 && angle < 180 + 45)
            {
                movingInDirection = 1;     //right
            }
            else if (angle > 0 - 45 && angle < 0 + 45)
            {
                movingInDirection = 2;     //left
            }
            else if (angle > 270 - 45 && angle < 270 + 45)
            {
                movingInDirection = 3;     //up
            }
            else if (angle > 90 - 45 && angle < 90 + 45)
            {
                movingInDirection = 4;     //down
            }
            animator.SetInteger("direction", movingInDirection);
        }
        else
        {
            movingInDirection = 0;
            animator.SetInteger("direction", movingInDirection);
            playerRigidbody.velocity = Vector2.zero;

            OptionsClass.getChoices();
        }
    }
Beispiel #3
0
        private Handmanager()
        {
            this.help = Helpfunctions.Instance;

        }
Beispiel #4
0
        //private static Handmanager instance;

        //public static Handmanager Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Handmanager());
        //    }
        //}


        public Handmanager(Silverfish sf)
        {
            this.help =sf.Helpfunctions;
            this.sf = sf;
        }
Beispiel #5
0
        private Handmanager()
        {
            this.help = Helpfunctions.Instance;

            int i = 0;
            Cardsposi c = new Cardsposi();
            c.Amount = 1;
            c.DetectPosix = 450;
            c.DetectPosiy = 675;
            c.cardsHooverPosx = 490;
            c.cardsHooverdiff = 1;
            c.cardsBigPosx = 366;
            c.cardsBigdiff = 1;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 2;
            c.DetectPosix = 403;
            c.DetectPosiy = 674;
            c.cardsHooverPosx = 438;
            c.cardsHooverdiff = 100;
            c.cardsBigPosx = 317;
            c.cardsBigdiff = 99;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 3;
            c.DetectPosix = 356;
            c.DetectPosiy = 675;
            c.cardsHooverPosx = 390;
            c.cardsHooverdiff = 100;
            c.cardsBigPosx = 267;
            c.cardsBigdiff = 99;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 4;
            c.DetectPosix = 291;
            c.DetectPosiy = 715;
            c.cardsHooverPosx = 350;
            c.cardsHooverdiff = 90;
            c.cardsBigPosx = 220;
            c.cardsBigdiff = 97;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 5;
            c.DetectPosix = 280;
            c.DetectPosiy = 712;
            c.cardsHooverPosx = 340;
            c.cardsHooverdiff = 75;
            c.cardsBigPosx = 210;
            c.cardsBigdiff = 78;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 6;
            c.DetectPosix = 273;
            c.DetectPosiy = 726;
            c.cardsHooverPosx = 323;
            c.cardsHooverdiff = 65;
            c.cardsBigPosx = 204;
            c.cardsBigdiff = 65;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 7;
            c.DetectPosix = 267;
            c.DetectPosiy = 724;
            c.cardsHooverPosx = 314;
            c.cardsHooverdiff = 56;
            c.cardsBigPosx = 199;
            c.cardsBigdiff = 56;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 8;
            c.DetectPosix = 262;
            c.DetectPosiy = 740;
            c.cardsHooverPosx = 300;
            c.cardsHooverdiff = 47;
            c.cardsBigPosx = 196;
            c.cardsBigdiff = 49;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 9;
            c.DetectPosix = 260;
            c.DetectPosiy = 738;
            c.cardsHooverPosx = 295;
            c.cardsHooverdiff = 42;
            c.cardsBigPosx = 193;
            c.cardsBigdiff = 43;
            this.cardsdata.Add(c);

            i = i + 1;
            c = new Cardsposi();
            c.Amount = 10;
            c.DetectPosix = 257;
            c.DetectPosiy = 752;
            c.cardsHooverPosx = 286;
            c.cardsHooverdiff = 38;
            c.cardsBigPosx = 191;
            c.cardsBigdiff = 39;
            this.cardsdata.Add(c);

        }
Beispiel #6
0
        public void print(Helpfunctions help, bool tobuffer = false)
        {
            if (tobuffer)
            {
                if (this.actionType == actionEnum.playcard)
                {
                    string playaction = "play ";

                    playaction += "id " + this.card.entity;
                    if (this.target != null)
                    {
                        playaction += " target " + this.target.entitiyID;
                    }

                    if (this.place >= 0)
                    {
                        playaction += " pos " + this.place;
                    }

                    if (this.druidchoice >= 1) playaction += " choice " + this.druidchoice;

                    help.writeToBuffer(playaction);
                }
                if (this.actionType == actionEnum.attackWithMinion)
                {
                    help.writeToBuffer("attack " + this.own.entitiyID + " enemy " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.attackWithHero)
                {
                    help.writeToBuffer("heroattack " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.useHeroPower)
                {

                    if (this.target != null)
                    {
                        help.writeToBuffer("useability on target " + this.target.entitiyID);
                    }
                    else
                    {
                        help.writeToBuffer("useability");
                    }
                }
                return;
            }
            if (this.actionType == actionEnum.playcard)
            {
                string playaction = "play ";

                playaction += "id " + this.card.entity;
                if (this.target != null)
                {
                    playaction += " target " + this.target.entitiyID;
                }

                if (this.place >= 0)
                {
                    playaction += " pos " + this.place;
                }

                if (this.druidchoice >= 1) playaction += " choice " + this.druidchoice;

                help.logg(playaction);
            }
            if (this.actionType == actionEnum.attackWithMinion)
            {
                help.logg("attacker: " + this.own.entitiyID + " enemy: " + this.target.entitiyID);
            }
            if (this.actionType == actionEnum.attackWithHero)
            {
                help.logg("attack with hero, enemy: " + this.target.entitiyID);
            }
            if (this.actionType == actionEnum.useHeroPower)
            {
                help.logg("useability ");
                if (this.target != null)
                {
                    help.logg("on enemy: " + this.target.entitiyID + " own:" + this.target.own);
                }
            }
            help.logg("");
        }
Beispiel #7
0
 private Handmanager()
 {
     this.help = Helpfunctions.Instance;
 }
Beispiel #8
0
 private Questmanager()
 {
     this.help = Helpfunctions.Instance;
 }
Beispiel #9
0
        //private static Hrtprozis instance;

        //public static Hrtprozis Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Hrtprozis());
        //    }
        //}



        public Hrtprozis(Silverfish sf)
        {
            this.sf = sf;
            this.help = sf.Helpfunctions;
        }
Beispiel #10
0
        public void print(bool tobuffer = false)
        {
            Helpfunctions help = Helpfunctions.Instance;

            if (tobuffer)
            {
                if (this.actionType == actionEnum.playcard)
                {
                    string playaction = "play ";

                    playaction += "id " + this.card.entity;
                    if (this.target != null)
                    {
                        playaction += " target " + this.target.entitiyID;
                    }

                    if (this.place >= 0)
                    {
                        playaction += " pos " + this.place;
                    }

                    if (this.druidchoice >= 1)
                    {
                        playaction += " choice " + this.druidchoice;
                    }

                    LogHelper.WriteCombatLog(playaction);
                }
                if (this.actionType == actionEnum.attackWithMinion)
                {
                    LogHelper.WriteCombatLog("attack " + this.own.entitiyID + " enemy " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.attackWithHero)
                {
                    LogHelper.WriteCombatLog("heroattack " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.useHeroPower)
                {
                    if (this.target != null)
                    {
                        LogHelper.WriteCombatLog("useability on target " + this.target.entitiyID);
                    }
                    else
                    {
                        LogHelper.WriteCombatLog("useability");
                    }
                }
                return;
            }
            if (this.actionType == actionEnum.playcard)
            {
                string playaction = "play card ";

                //playaction += "id " + this.card.entity;
                playaction += this.card.card.ChineseName;
                if (this.target != null)
                {
                    //playaction += " target " + this.target.entitiyID;
                    playaction += " target " + this.target.ChineseName;
                }

                if (this.place >= 0)
                {
                    playaction += " pos " + this.place;
                }

                if (this.druidchoice >= 1)
                {
                    playaction += " choice " + this.druidchoice;
                }

                LogHelper.WriteCombatLog(playaction);
            }
            if (this.actionType == actionEnum.attackWithMinion)
            {
                LogHelper.WriteCombatLog("attacker: " + this.own.entitiyID + " enemy: " + this.target.entitiyID);
                LogHelper.WriteCombatLog("attacker: " + this.own.ChineseName + " enemy: " + this.target.ChineseName);
            }
            if (this.actionType == actionEnum.attackWithHero)
            {
                LogHelper.WriteCombatLog("attack with hero, enemy: " + this.target.entitiyID);
                LogHelper.WriteCombatLog("attack with hero, enemy: " + this.target.ChineseName);
            }
            if (this.actionType == actionEnum.useHeroPower)
            {
                LogHelper.WriteCombatLog("useability ");
                LogHelper.WriteCombatLog($"useability {card.card.ChineseName}");
                if (this.target != null)
                {
                    LogHelper.WriteCombatLog("on enemy: " + this.target.entitiyID);
                    LogHelper.WriteCombatLog("on enemy: " + this.target.ChineseName);
                }
            }
            LogHelper.WriteCombatLog("");
        }
Beispiel #11
0
 public void setInstances()
 {
     help = Helpfunctions.Instance;
     cdb  = CardDB.Instance;
 }