Пример #1
0
        protected override void Update(GameTime gameTime)
        {
            mouseChk();
            switch (sceneFlg)
            {
                case 3:
                    map.UPMoney(Money);
                    if (enemys2[co] != -1)
                    {
                        dtNow = DateTime.Now;
                        now = dtNow;
                        if (now >= w)
                        {

                            w = dtNow.AddSeconds(second);
                            enemy = new Enemy(sprite, Gm.GraphicsDevice, enemys2[co], stageNo);
                            kazu++;

                            listenemy.Add(enemy);
                            if (enemyco >= enemys[co])
                            {
                                co++;
                                second = enemydata.getSecond(enemys2[co]);

                                enemyco = 0;
                            }
                            enemyco++;
                        }
                    }
                    else if(kazu ==kazu2)
                    {
                        for (int j = 0; j < kazuuni1; j++)
                        {
                            listunit.RemoveAt(0);
                        }
                        stageselect.nextstage(stageFlg, stageNo);
                        talkevent.setEvent(stageNo+8);
                        staCliFlg = false;
                        bgm.setBGM(6);
                        sceneFlg = 2;
                    }

                    for (int i = 0; i < listenemy.Count; i++)
                        {
                            if (listenemy[i].enemymove())
                            {
                                hp -= listenemy[i].getATC();
                                listenemy.RemoveAt(i);
                                kazu--;

                                if (hp <= 0)
                                {
                                    co = 4;

                                    for (int j = 0; j < kazu-kazu2; j++)
                                    {
                                        listenemy.RemoveAt(0);
                                    }
                                    for (int j = 0; j < kazuuni1; j++)
                                    {
                                        listunit.RemoveAt(0);
                                    }

                                    bgm.setBGM(7);
                                    sceneFlg = 4;
                                }
                            }
                        }

                        for (int i = 0; i < listunit.Count; i++)
                        {
                            listunit[i].UPdate();
                            randomNumber = rnd.Next(4);
                            if (listunit[i].getInterval())
                            {
                                pos3Unit.X = listunit[i].getX();
                                pos3Unit.Y = listunit[i].getY();
                                bsUnit.Center = pos3Unit;
                                bsUnit.Radius = listunit[i].getRNG();
                                for (int j = 0; j < listenemy.Count ; j++)
                                {
                                    int lex=0, ley=0, no=0;
                                    pos3Enemy.X = listenemy[j].getX();
                                    pos3Enemy.Y = listenemy[j].getY();
                                    bsEnemy.Center = pos3Enemy;
                                    bsEnemy.Radius = 20;
                                    if (hitbox.hitcheck2(bsUnit, bsEnemy))
                                    {
                                        listunit[i].setInterval();

                                        if (listunit[i].getUnitNo() == 6)
                                        {

                                           BoundingBox  box1 = new BoundingBox();

                                           muni = randomNumber;

                                           switch (muni)
                                            {
                                                case 0:
                                                    box1.Min = new Vector3(listunit[i].getX()+10,listunit[i].getY()-600,0);
                                                    box1.Max = new Vector3(listunit[i].getX() + 30, listunit[i].getY(), 0);
                                                    lex = (int)listunit[i].getX();
                                                    ley = (int)listunit[i].getY() - 600;
                                                    no=0;
                                                    break;
                                                case 1:
                                                    box1.Min = new Vector3(listunit[i].getX() + 40, listunit[i].getY()-10, 0);
                                                    box1.Max = new Vector3(listunit[i].getX()+640,listunit[i].getY ()+10,0);
                                                    lex = (int)listunit[i].getX() + 40;
                                                    ley = (int)listunit[i].getY();
                                                    no=1;
                                                    break;
                                                case 2:
                                                    box1.Min = new Vector3(listunit[i].getX()+10, listunit[i].getY()+40, 0);
                                                    box1.Max = new Vector3(listunit[i].getX() + 30, listunit[i].getY() + 640, 0);
                                                    lex = (int)listunit[i].getX();
                                                    ley = (int)listunit[i].getY()+40;
                                                    no=0;
                                                    break;
                                                case 3:
                                                    box1.Min = new Vector3(listunit[i].getX()-600, listunit[i].getY()-10 , 0);
                                                    box1.Max = new Vector3(listunit[i].getX(), listunit[i].getY() + 10, 0);
                                                     lex = (int)listunit[i].getX() -600;
                                                    ley = (int)listunit[i].getY();
                                                    no=1;
                                                    break;

                                            }

                                            for (int k = 0; k < listenemy.Count; k++)
                                            {
                                                pos3Enemy.X = listenemy[k].getX();
                                                pos3Enemy.Y = listenemy[k].getY();
                                                bsEnemy.Center = pos3Enemy;
                                                bsEnemy.Radius = 20;

                                                listunit[i].le(no, lex, ley);
                                                if (hitbox.hitcheck(bsEnemy, box1))
                                                {
                                                    if (listenemy[k].damageHP(listunit[i].getATC()))
                                                    {

                                                        Money += (int)(listenemy[k].getDRP());
                                                        listenemy.RemoveAt(k);
                                                        k--;
                                                        //kazu--;
                                                        kazu2++;
                                                    }

                                                }

                                            }

                                        }
                                       else if (listenemy[j].damageHP(listunit[i].getATC()))
                                        {
                                            Money += (int)(listenemy[j].getDRP());
                                            listenemy.RemoveAt(j);
                                            kazu2++;
                                                //kazu--;
                                        }
                                        else
                                        {
                                            switch (listunit[i].getUnitNo())
                                            {
                                                case 4:
                                                    listenemy[j].damageSPD();
                                                    break;
                                                case 5:
                                                    int wmo = (int)(listenemy[j].getDRP()) / 10;
                                                    if (wmo <= 1)
                                                    {
                                                        wmo = 1;
                                                    }
                                                    Money += wmo;
                                                    break;
                                            }

                                        }
                                    }

                                }
                            }
                        }
                        break;
            }

            base.Update(gameTime);
        }
Пример #2
0
        protected override void Update(GameTime gameTime)
        {
            mouseChk();
            switch (sceneFlg)
            {
                case 3:
                    map.UPMoney(Money);
                    if (enemys2[co] != -1)
                    {
                        dtNow = DateTime.Now;
                        now = dtNow;
                        if (now >= w)
                        {

                            w = dtNow.AddSeconds(second);
                            enemy = new Enemy(sprite, Gm.GraphicsDevice, enemys2[co], stageNo);
                            kazu++;
                            listenemy.Add(enemy);
                            if (enemyco >= enemys[co])
                            {
                                co++;
                                second = enemydata.getSecond(enemys2[co]);

                                enemyco = 0;
                            }
                            enemyco++;
                        }
                    }
                    else if(kazu ==kazu2)
                    {
                        for (int j = 0; j < kazuuni1; j++)
                        {
                            listunit.RemoveAt(0);
                        }
                        stageselect.nextstage(stageFlg, stageNo);
                        talkevent.setEvent(stageNo+8);
                        staCliFlg = false;
                        sceneFlg = 2;
                    }

                    for (int i = 0; i < listenemy.Count; i++)
                        {
                            if (listenemy[i].enemymove())
                            {
                                hp -= listenemy[i].getATC();
                                listenemy.RemoveAt(i);
                                kazu--;

                                if (hp <= 0)
                                {
                                    co = 4;
                                    Debug.WriteLine(listenemy.Count);
                                    for (int j = 0; j < kazu-kazu2; j++)
                                    {
                                        listenemy.RemoveAt(0);
                                    }
                                    for (int j = 0; j < kazuuni1; j++)
                                    {
                                        listunit.RemoveAt(0);
                                    }
                                    sceneFlg = 1;
                                }
                            }
                        }

                        for (int i = 0; i < listunit.Count; i++)
                        {
                            listunit[i].UPdate();
                            if (listunit[i].getInterval())
                            {
                                pos3Unit.X = listunit[i].getX();
                                pos3Unit.Y = listunit[i].getY();
                                bsUnit.Center = pos3Unit;
                                bsUnit.Radius = listunit[i].getRNG();
                                for (int j = 0; j < listenemy.Count; j++)
                                {
                                    pos3Enemy.X = listenemy[j].getX();
                                    pos3Enemy.Y = listenemy[j].getY();
                                    bsEnemy.Center = pos3Enemy;
                                    bsEnemy.Radius = 20;
                                    if (hitbox.hitcheck2(bsUnit, bsEnemy))
                                    {
                                        listunit[i].setInterval();
                                        if (listenemy[j].damageHP(listunit[i].getATC()))
                                        {
                                            Money += (int)(listenemy[j].getDRP());
                                            listenemy.RemoveAt(j);
                                            kazu2++;
                                        }
                                        else
                                        {
                                            switch (listunit[i].getUnitNo())
                                            {
                                                case 4:
                                                    listenemy[j].damageSPD();
                                                    break;
                                                case 5:
                                                    int wmo = (int)(listenemy[j].getDRP()) / 10;
                                                    if (wmo <= 1)
                                                    {
                                                        wmo = 1;
                                                    }
                                                    Money += wmo;
                                                    break;
                                            }

                                        }
                                    }

                                }
                            }
                        }
                        break;
            }

            base.Update(gameTime);
        }