示例#1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            //--Cargar los assets
            _sfxBotonPresionado = Content.Load <SoundEffect>(SONIDO_BOTON);
            _sfxImpacto         = Content.Load <SoundEffect>(SONIDO_IMPACTO);
            _sfxRecordAlcanzado = Content.Load <SoundEffect>(SONIDO_RECORDALCANZADO);

            _hojaDeImagenes = Content.Load <Texture2D>(SPRITE_SHEET);

            _texturaDelFadeIn = new Texture2D(GraphicsDevice, 1, 1);
            _texturaDelFadeIn.SetData(new Color[] { Color.White });

            _trex = new Trex(_hojaDeImagenes, new Vector2(TREX_POS_INICIAL_X, TREX_POS_INICIAL_Y - Trex.TREX_SPRITE_POS_ALTO), _sfxBotonPresionado);
            _trex.OrdenDeDibujo  = 10;
            _trex.SaltoCompleto += trex_SaltoCompleto;

            _puntajes = new MostrarPuntaje(_hojaDeImagenes, new Vector2(PUNTAJE_POS_X, PUNTAJE_POS_Y), _trex);
            //_puntajes.Puntaje = 498;
            //_puntajes.PuntajeRecord = 12345;

            _entrada    = new ControladorDeEntrada(_trex);
            _terreno    = new ManagerDeTerreno(_hojaDeImagenes, _manager, _trex);
            _obstaculos = new ManagerDeObstaculos(_hojaDeImagenes, _manager, _trex, _puntajes);

            _manager.Agregar(_trex);
            _manager.Agregar(_terreno);
            _manager.Agregar(_puntajes);
            _manager.Agregar(_obstaculos);
            _terreno.Inicializar();
        }
示例#2
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     ai             = animator.GetComponent <Trex>();
     perception     = animator.GetComponent <Perception>();
     shootTimer     = ai.attackCooldown;
     aiProjectile   = ai.projectile;
     rigidbody      = ai.GetComponent <Rigidbody2D>();
     spriteRenderer = ai.GetComponent <SpriteRenderer>();
     aimOrigin      = ai.aimOrigin;
 }
示例#3
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _sfxButtonPress  = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS);
            _sfxHit          = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT);
            _sfxScoreReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED);

            _spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET);

            _trex = new Trex(_spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - Trex.TREX_DEFAULT_SPRITE_HEIGHT));
        }
示例#4
0
        static void AbstractDemo()
        {
            Trex        trex        = new Trex();
            Triceratops triceratops = new Triceratops();

            trex.EatFood();
            trex.Move();
            trex.Speed();
            trex.Habitat();

            triceratops.EatFood();
            triceratops.Move();
            triceratops.Speed();
            triceratops.Habitat();
        }
示例#5
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            sfxButtonPress  = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS);
            sfxScoreReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED);
            sfxHit          = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT);

            _font = Content.Load <SpriteFont>("MyFont");

            spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET);

            _fadeInTexture = new Texture2D(GraphicsDevice, 1, 1);
            _fadeInTexture.SetData(new Color[] { Color.White });

            trex           = new Trex(spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - Trex.TREX_DEF_SPRITE_HEIGHT), sfxButtonPress, GraphicsDevice);
            trex.DrawOrder = 10;

            trex.JumpComplete += TrexJumpComplete;
            trex.Died         += TrexDied;

            _scoreBoard = new ScoreBoard(spriteSheetTexture, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), trex, sfxScoreReached);

            _inputController = new InputController(trex);

            _groundManager = new GroundManager(spriteSheetTexture, _entityManager, trex);

            _obstacleManager = new ObstacleManager(_entityManager, trex, _scoreBoard, spriteSheetTexture, GraphicsDevice);

            _backroundManager = new BackGroundManager(spriteSheetTexture, _entityManager, trex);

            _gameOverScreen = new GameOverScreen(
                spriteSheetTexture,
                new Vector2(
                    (WINDOW_WIDTH - GameOverScreen.GAME_OVER_TEXTURE_WIDTH) / 2,
                    (WINDOW_HEIGHT - GameOverScreen.GAME_OVER_TEXTURE_HEIGHT) / 3
                    ),
                this
                );

            _entityManager.AddEntity(trex);
            _entityManager.AddEntity(_groundManager);
            _entityManager.AddEntity(_scoreBoard);
            _entityManager.AddEntity(_obstacleManager);
            _entityManager.AddEntity(_gameOverScreen);
            _entityManager.AddEntity(_backroundManager);
        }
示例#6
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ai            = animator.GetComponent <Trex>();
        perception    = animator.GetComponent <Perception>();
        rigidbody     = animator.GetComponent <Rigidbody2D>();
        movementSpeed = ai.movementSpeed;
        transform     = animator.transform;
        aimOrigin     = ai.aimOrigin;
        aimOrigin.transform.rotation = Quaternion.Euler(0, 0, 0);

        groundLayer   = ai.groundLayer;
        wallLayer     = ai.wallLayer;
        platformLayer = ai.platformLayer;

        wallDetectionDistance = ai.wallDetectionDistance;
    }
示例#7
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _sfxButtonPress  = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS);
            _sfxHit          = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT);
            _sfxScoreReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED);

            _spriteSheetTexture  = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET);
            _invertedSpriteSheet = _spriteSheetTexture.InvertColors(Color.Transparent);

            _fadeInTexture = new Texture2D(GraphicsDevice, 1, 1);
            _fadeInTexture.SetData(new Color[] { Color.White });

            _trex               = new Trex(_spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - Trex.TREX_DEFAULT_SPRITE_HEIGHT), _sfxButtonPress);
            _trex.DrawOrder     = 100;
            _trex.JumpComplete += trex_JumpComplete;
            _trex.Died         += trex_Died;

            _scoreBoard = new ScoreBoard(_spriteSheetTexture, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), _trex, _sfxScoreReached);
            //_scoreBoard.Score = 498;
            //_scoreBoard.HighScore = 12345;

            _inputController = new InputController(_trex);

            _groundManager   = new GroundManager(_spriteSheetTexture, _entityManager, _trex);
            _obstacleManager = new ObstacleManager(_entityManager, _trex, _scoreBoard, _spriteSheetTexture);
            _skyManager      = new SkyManager(_trex, _spriteSheetTexture, _invertedSpriteSheet, _entityManager, _scoreBoard);

            _gameOverScreen          = new GameOverScreen(_spriteSheetTexture, this);
            _gameOverScreen.Position = new Vector2(WINDOW_WIDTH / 2 - GameOverScreen.GAME_OVER_SPRITE_WIDTH / 2, WINDOW_HEIGHT / 2 - 30);

            _entityManager.AddEntity(_trex);
            _entityManager.AddEntity(_groundManager);
            _entityManager.AddEntity(_scoreBoard);
            _entityManager.AddEntity(_obstacleManager);
            _entityManager.AddEntity(_gameOverScreen);
            _entityManager.AddEntity(_skyManager);

            _groundManager.Initialize();

            LoadSaveState();
        }
示例#8
0
文件: Event.cs 项目: wach78/Turbofest
        public Event(DateTime ClockStart, DateTime ClockEnd, int ClockRunTime, System.Xml.Linq.XDocument XMLEvents, ref CrashHandler Crash)
        {
            ch = Crash;
            events = new Dictionary<string, List<EventItem>>();
            clock = new PartyClock(ClockStart, ClockEnd, ClockRunTime);
            Util.ShowClock = true;
            sound = new Sound(true);
            text = new Text2D();
            chess = new Chess();
            sf = new Starfield(150);

            intro = new Intro(ref sound, ref text);
            outro = new Outro(ref sound);

            advent = new Advent(ref sound);
            birthday = new Birthday(ref sound, ref text, ref chess);
            xmas = new Christmas(ref sound);
            smurf = new Datasmurf(ref sound, ref text); // random
            dif = new Dif(ref chess, ref sound); // random
            fbk = new Fbk(ref sound); // random
            hw = new Halloween(ref chess, ref sound, 25);
            lucia = new Lucia(ref chess, ref sound);
            newyear = new NewYear();
            richard = new RMS(ref sound, ref text); // random
            scroller = new Scroller(ref chess, ref sf, ref text); // random
            semla = new Semla();
            sune = new SuneAnimation(ref sound, ref text);
            tl = new TurboLogo(ref sound, ref chess, (OpenGL.Util.SpringOrFall.Equals("Spring")? true:false)/*((ClockStart.Month >= 1 && ClockStart.Month <= 8)? false:true)*/ ); // vilken termin är det? jan till början av augusti VT, resten HT... random
            valentine = new Valentine(ref sound);
            wl = new WinLinux(ref chess); //random
            creators = new Self(ref sound); // random
            bb = new BB(ref sound); // random
            GM = new GummiBears(ref sound);
            NDay = new National(ref chess, ref sound);
            easter = new Easter(ref sound);
            hajk = new Hajk(ref sound);
            mid = new Midsummer(ref sound);
            vaf = new Vaffla();
            wp = new Walpurgis();
            crayfish = new CrayFish();

            ts = new TeknatStyle(ref chess, ref sound, ref text);
            m = new Matrix(ref text);
            q = new Quiz(ref text, false, ref sound);
            talepsin = new Talespin(ref sound);
            cd = new ChipAndDale(ref sound, ref chess);
            nerd = new Nerdy(ref chess, ref sound);
            trex = new Trex(ref sound);
            sailormoon = new Sailormoon(ref sound,ref chess);
            gb = new GhostBusters(ref sound);
            zelda = new Zelda(ref sound, ref chess);
            tardis = new Tardis(ref sound);
            f**k = new F**k(ref sound, ref chess);

            silverFang = new SilverFang(ref sound);
            mt = new MoraT(ref sound);

            swine = new Swine(ref chess, ref text);
            tjall = new Tjall(ref chess, ref text);

            ronja = new Ronja(ref sound);
            emil = new Emil(ref sound);
            djungelboken = new Djungelboken(ref sound);
            fabbe = new Fabbe(ref sound);
            drink = new Drink(ref sound);
            frozen = new Frozen(ref sound);

            eventCurrent = null; // event item for events to be triggerd in clock_NewDate
            //randomEvent = new List<string>(new string[] { "starfield", "SuneAnimation", "TurboLogo", "Datasmurf", "WinLinux", "Scroller", "BB", "GummiBears", "TeknatStyle", "Matrix"});
            randomEvent = new List<string>(new string[] { "starfield", "Nerdy", "Talespin", "Sailormoon", "GhostBusters", "Zelda", "Tardis", "F**k", "SilverFang", "MoraT" });
            //new stuff
             List<UtilXML.EventData> ed = UtilXML.Loadeffectdata();

            // TODO: Make a clean list with all events allowed to be used implement so that it is actaully usable instead of a switch at the bottom of this file.
            Dictionary<string, Effect> effects = new Dictionary<string, Effect>()
            {
                {"SuneAnimation", new Effect(sune, ed.Find(e => e.Name == "SuneAnimation"))},
                {"Dif",new Effect(dif, ed.Find(e => e.Name == "Dif"))},
                {"Fbk",new Effect(fbk, ed.Find(e => e.Name == "Fbk"))},
                {"TurboLogo",new Effect(tl, ed.Find(e => e.Name == "TurboLogo"))},
                {"Datasmurf", new Effect(smurf, ed.Find(e => e.Name == "Datasmurf"))},
                {"RMS",new Effect(richard, ed.Find(e => e.Name == "RMS"))},
                {"WinLinux",new Effect(wl, ed.Find(e => e.Name == "WinLinux"))},
                {"Scroller",new Effect(scroller, ed.Find(e => e.Name == "Scroller"))},
                {"Self",new Effect(creators, ed.Find(e => e.Name == "Self"))},
                {"BB",new Effect(bb, ed.Find(e => e.Name == "BB"))},
                {"GummiBears",new Effect(GM, ed.Find(e => e.Name == "GummiBears"))},
                {"Hajk",new Effect(hajk, ed.Find(e => e.Name == "Hajk"))},
                {"TeknatStyle",new Effect(ts, ed.Find(e => e.Name == "TeknatStyle"))},
                {"Matrix",new Effect(m, ed.Find(e => e.Name == "Matrix"))},
                {"Quiz",new Effect(q, ed.Find(e => e.Name == "Quiz"))},
                {"Talespin",new Effect(talepsin, ed.Find(e => e.Name == "Talespin"))},
                {"ChipDale",new Effect(cd, ed.Find(e => e.Name == "ChipDale"))},
                {"Nerdy",new Effect(nerd, ed.Find(e => e.Name == "Nerdy"))},
              /*  {"Trex",new Effect(trex, ed.Find(e => e.Name == "Trex"))},*/
                {"Sailormoon",new Effect(sailormoon, ed.Find(e => e.Name == "Sailormoon"))},
                {"GhostBusters",new Effect(gb, ed.Find(e => e.Name == "GhostBusters"))},
                {"Zelda",new Effect(zelda, ed.Find(e => e.Name == "Zelda"))},
                {"Tardis",new Effect(tardis, ed.Find(e => e.Name == "Tardis"))},
                {"F**k",new Effect(f**k, ed.Find(e => e.Name == "F**k"))},
                {"SilverFang",new Effect(silverFang, ed.Find(e => e.Name == "SilverFang"))},
                {"MoraT",new Effect(mt, ed.Find(e => e.Name == "MoraT"))},
                {"Ronja",new Effect(ronja, ed.Find(e => e.Name == "Ronja"))},
                {"Emil",new Effect(emil, ed.Find(e => e.Name == "Emil"))},
                {"Djungelboken",new Effect(djungelboken, ed.Find(e => e.Name == "Djungelboken"))},
                {"Fabbe",new Effect(fabbe, ed.Find(e => e.Name == "Fabbe"))},
                {"Drink",new Effect(drink, ed.Find(e => e.Name == "Drink"))},
                {"Frozen",new Effect(drink, ed.Find(e => e.Name == "Frozen"))}
            };

            runEffectInMonth = new Dictionary<string, List<objdata>>();

            string[] months = Util.monthlist();
            int counter;
            foreach (KeyValuePair<string, Effect> pair in effects)
            {
                counter = 0;
                foreach (bool b in pair.Value.RunAllowedlist)
                {
                    if (b == true)
                    {
                        if (!runEffectInMonth.ContainsKey(months[counter]))
                        {
                            runEffectInMonth.Add(months[counter], new List<objdata>());
                        }

                        runEffectInMonth[months[counter]].Add(new objdata(pair.Key, pair.Value.Vetolist[counter], pair.Value.Priolist[counter], pair.Value.Runslist[counter]));
                    }
                    counter++;
                }
            }

            clock.NewDate += clock_NewDate; // Event listener

            if (ch.CrashDialogResult == System.Windows.Forms.DialogResult.Yes)
            {
                clock.clock = ch.CrashClock;
            }

            string name, date, type;
            // Event dates setup
            foreach (var item in XMLEvents.Descendants("event"))
            {
                name = item.Element("name").Value;
                date = item.Element("date").Value;
                type = item.Element("type").Value.ToLower();
                EventItem ei = new EventItem(name, type, date);
                if (!events.ContainsKey(date))
                {
                    List<EventItem> list = new List<EventItem>(); // seems most bad in my eyes...
                    events.Add(date, list);
                }

                for (int i = 0; i < events[date].Count; i++)
                {
                    EventItem e = events[date][i];
                    if ("birthday".Equals(e.Type) && "birthday".Equals(ei.Type))
                    {
                        e.Name += "\n\n" + ei.Name;
                        events[date][i] = e;
                    }
                }
                events[date].Add(ei);
                name = date = type = string.Empty;
            }

            // this needs to be fixed nicer...
            if (events.ContainsKey(ClockEnd.ToShortDateString()))
            {
                events[ClockEnd.ToShortDateString()].Clear(); // force this to be top..
                events[ClockEnd.ToShortDateString()].Add( new EventItem("outro", "outro", ClockEnd.ToShortDateString()) );
            }
            else
            {
                events.Add(ClockEnd.ToShortDateString(), new List<EventItem>() { new EventItem("outro", "outro", ClockEnd.ToShortDateString()) });
            }

            // Random effects on dates with no effects and check against new list of allowed things for them...
            DateTime dt = ClockStart;
            bool star = (Util.Rnd.Next(0, 1000) < 500 ? true:false); // make this random at the start too?
            int num = 0;

            while (dt <= ClockEnd)
            {
                date = dt.ToShortDateString();
                if (!events.ContainsKey(date))
                {
                    EventItem ei;

                    if (num == 0 || num == 1)
                    {
                        ei = new EventItem("starfield", "random", date);
                    }
                    else
                    {
                        //ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);

                        string month = "";
                        if (dt != null)
                            month = dt.Month.ToString();

                        switch (month)
                        {
                            case "1": month = "jan"; break;
                            case "2": month = "feb"; break;
                            case "3": month = "mar"; break;
                            case "4": month = "apr"; break;
                            case "5": month = "maj"; break;
                            case "6": month = "jun"; break;
                            case "7": month = "jul"; break;
                            case "8": month = "aug"; break;
                            case "9": month = "sep"; break;
                            case "10": month = "okt"; break;
                            case "11": month = "nov"; break;
                            case "12": month = "dec"; break;
                        }//switch

                        if (runEffectInMonth.ContainsKey(month))
                        {
                            List<objdata> mobj = runEffectInMonth[month];

                            List<objdata> vetolist = new List<objdata>();
                            List<objdata> novetolist = new List<objdata>();

                            foreach (objdata n in mobj)
                            {

                                if ("Quiz".Equals(n.Name) && eventnum == 4)
                                {
                                    n.vetoAgain();
                                    eventnum = 0;
                                }

                                if (n.Veto == true)
                                {
                                    if (n.Runs > 0)
                                        vetolist.Add(n);
                                }
                                else
                                {
                                    if (n.Runs > 0)
                                        novetolist.Add(n);
                                }
                            }

                            vetolist.Sort();
                            novetolist.Sort();

                            if (vetolist.Count > 0)
                            {
                                ei = new EventItem(vetolist[0].Name, "random", date);
                                vetolist[0].noMoreVeto();
                            }
                            else if (novetolist.Count > 0)
                            {
                                ei = new EventItem(novetolist[0].Name, "random", date);
                                novetolist[0].decRuns();
                                if (eventnum < 4)
                                    eventnum++;
                            }
                            else
                            {
                                ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                            }
                        }
                        else
                        {
                            ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                        }
                    }

                    num++;
                    if (num == 3)
                    {
                        num = 0;
                    }
                    ei = new EventItem("Self", "random", date); // this is for debuging new events
                    events.Add(date, new List<EventItem>());
                    events[date].Add(ei);
                }

                dt = dt.AddDays(1);
                date = string.Empty;
            }
        }
 public InputController(Trex trex)
 {
     _trex = trex;
 }
 public ControladorDeEntrada(Trex trex)
 {
     _trex = trex;
 }
        public void TestTee2()
        {
            Trex newTee = new Trex();

            Assert.True(newTee.Run());
        }
        public void TestTee()
        {
            Trex newTee = new Trex();

            Assert.True(newTee.Terrorizing());;
        }
示例#13
0
 public static void LoadAll()
 {
     Scenes.LoadAll();
     Trex.LoadAll();
 }