Ejemplo n.º 1
0
        protected override void Initialise()
        {
            Texture2D textureAtlas = SceneService.textureAtlas;
            Dictionary <string, TextureData> textureData = SceneService.textureData;

            Animation newanim = new Animation();

            input.SubscribeToKey("Exit", delegate { SceneService.Exit(); });

            input.SubscribeToKey("Start", delegate { newanim.Play = true; });

            input.SubscribeToKey("Reset", delegate {
                objects[0].position.Y = 328 + 128;
                for (int i = 2; i < 10; i++)
                {
                    objects[i].tintColor = new Color(0, 0, 0, 0);
                }
            });

            for (int i = 0; i < 6; i++)
            {
                sprites.Add(new Sprite(textureAtlas));
            }

            sprites[0].textureSelection = textureData["OuterBattleOption"];
            sprites[1].textureSelection = textureData["InnerBattleOption"];

            sprites[2].textureSelection = textureData["MoveLeft"];
            sprites[2].animationFrames  = 1;
            sprites[2].animationSpeed   = 100;
            sprites[3].textureSelection = textureData["MoveRight"];

            sprites[4].textureSelection = textureData["BasicMoveLeft"];
            sprites[5].textureSelection = textureData["BasicMoveRight"];

            objects.Add(new Object2D(sprites[1], 248, 328 + 128));
            objects.Add(new Object2D(sprites[0], 248, 328 + 16 + 128));

            objects.Add(new Object2D(sprites[2], 88 + 50, 357));
            objects.Add(new Object2D(sprites[2], 108 + 50, 416));
            objects.Add(new Object2D(sprites[2], 128 + 50, 475));

            objects.Add(new Object2D(sprites[3], 472 - 50, 357));
            objects.Add(new Object2D(sprites[3], 452 - 50, 416));
            objects.Add(new Object2D(sprites[3], 432 - 50, 475));

            objects.Add(new Object2D(sprites[4], 5 + 50, 475));
            objects.Add(new Object2D(sprites[5], 587 - 50, 475));

            input.SubscribeToKey("Select", objects[2].OnButtonPress);
            objects[2].PressedEvent += delegate {
                objects[0].position.Y = 328 + 128;
                for (int i = 2; i < 10; i++)
                {
                    objects[i].tintColor = new Color(0, 0, 0, 0);
                }
            };

            input.SubscribeToKey("Select", objects[3].OnButtonPress);
            objects[3].PressedEvent += delegate {
                SceneService.OpenOverlay(new SettingsMenu(this));
            };

            input.SubscribeToKey("Select", objects[4].OnButtonPress);
            objects[4].PressedEvent += delegate {
                //objects[4].Animate();
            };

            for (int i = 2; i < 10; i++)
            {
                objects[i].tintColor = new Color(0, 0, 0, 0);
            }

            newanim.AddTransition(objects[0], 0.35, 0, new DiscreteVector2(248, 328 + 128), new DiscreteVector2(248, 328));

            newanim.AddTransition(objects[2], 0.2, 0.2, -50, 0);
            newanim.AddTransition(objects[3], 0.2, 0.15, -50, 0);
            newanim.AddTransition(objects[4], 0.2, 0.1, -50, 0);
            newanim.AddTransition(objects[8], 0.2, 0.05, -50, 0);
            newanim.AddTint(objects[2], 0.2, 0.2, false);
            newanim.AddTint(objects[3], 0.2, 0.15, false);
            newanim.AddTint(objects[4], 0.2, 0.1, false);
            newanim.AddTint(objects[8], 0.2, 0.05, false);

            newanim.AddTransition(objects[5], 0.2, 0.2, 50, 0);
            newanim.AddTransition(objects[6], 0.2, 0.15, 50, 0);
            newanim.AddTransition(objects[7], 0.2, 0.1, 50, 0);
            newanim.AddTransition(objects[9], 0.2, 0.05, 50, 0);
            newanim.AddTint(objects[5], 0.2, 0.2, false);
            newanim.AddTint(objects[6], 0.2, 0.15, false);
            newanim.AddTint(objects[7], 0.2, 0.1, false);
            newanim.AddTint(objects[9], 0.2, 0.05, false);


            objects[0].animator.AddAnimation(newanim);
        }
Ejemplo n.º 2
0
        public BattleScene(ContentManager Content)
        {
            Texture2D textureAtlas = SceneService.textureAtlas;
            Dictionary <string, TextureData> textureData = SceneService.textureData;

            Animation newanim = new Animation();

            battlething = new List <Object2D>();
            Initialise();

            battleEngine = new BattleEngine();
            rot          = 0;
            pos          = 0;
            angle        = 0;
            timer        = 0;
            timer2       = 0;


            tex   = Content.Load <Texture2D>("MODELS/bottom");
            model = Content.Load <Model>("MODELS/bottommod");
            Texture2D sprite  = Content.Load <Texture2D>("strip");
            Texture2D sprite2 = Content.Load <Texture2D>("strip2");
            Texture2D atk     = Content.Load <Texture2D>("133");


            modelTransforms = new Matrix[model.Bones.Count];
            model.CopyBoneTransformsTo(modelTransforms);


            input.SubscribeToKey("Exit", delegate { SceneService.Exit(); });

            input.SubscribeToKey("Start", delegate { newanim.Play = true; });

            input.SubscribeToKey("Reset", delegate {
                objects[0].position.Y = 328 + 128;
                for (int i = 2; i < 10; i++)
                {
                    objects[i].tintColor = new Color(0, 0, 0, 0);
                }
            });

            for (int i = 0; i < 11; i++)
            {
                sprites.Add(new Sprite(textureAtlas));
            }

            sprites[0].textureSelection = textureData["OuterBattleOption"];
            sprites[1].textureSelection = textureData["InnerBattleOption"];
            sprites[9].textureSelection = textureData["OptionBattleBottom"];

            sprites[2].textureSelection = textureData["MoveLeft"];

            sprites[3].textureSelection = textureData["MoveRight"];

            sprites[4].textureSelection = textureData["BasicMoveLeft"];
            sprites[5].textureSelection = textureData["BasicMoveRight"];

            sprites[6].textureSelection  = textureData["BattleHead"];
            sprites[7].textureSelection  = textureData["BattleArm"];
            sprites[8].textureSelection  = textureData["BattleBarBlue"];
            sprites[9].textureSelection  = textureData["BattleBarRed"];
            sprites[10].textureSelection = textureData["BattleBarEmpty"];



            objects.Add(new Object2D(sprites[1], 248, 328 + 128));
            objects.Add(new Object2D(sprites[0], 248, 328 + 16 + 128));

            Text text = new Text(SceneService.font, 50, 30);

            text.SetText(battleEngine.Player1.ActiveCreature.GetAction(0).Name);
            Object2D temp = new Object2D(text, 20, 10);

            temp.tintColor = Color.Black;
            objects.Add(new Object2D(sprites[2], 88 + 50, 357, temp));
            objects.Add(new Object2D(sprites[2], 108 + 50, 416));
            objects.Add(new Object2D(sprites[2], 128 + 50, 475));

            objects.Add(new Object2D(sprites[3], 472 - 50, 357));
            objects.Add(new Object2D(sprites[3], 452 - 50, 416, temp));
            objects.Add(new Object2D(sprites[3], 432 - 50, 475));

            objects.Add(new Object2D(sprites[4], 5 + 50, 475));
            objects.Add(new Object2D(sprites[5], 587 - 50, 475));

            {
                Sprite sptem = new Sprite(atk);
                sptem.textureSelection            = new TextureData();
                sptem.textureSelection.Main       = new Rectangle2D();
                sptem.textureSelection.Main.X     = 0;
                sptem.textureSelection.Main.Y     = 0;
                sptem.textureSelection.Main.XSize = 40;
                sptem.textureSelection.Main.YSize = 40;
                sptem.animationFrames             = 7;
                sptem.animationSpeed = 1;
                sptem.isAnimating    = true;
                objects.Add(new Object2D(sptem, 128, 228));
                objects.Add(new Object2D(new Sprite(sptem), 592, 228));
            }
            {
                Sprite sptem = new Sprite(sprite);
                sptem.textureSelection            = new TextureData();
                sptem.textureSelection.Main       = new Rectangle2D();
                sptem.textureSelection.Main.X     = 0;
                sptem.textureSelection.Main.Y     = 0;
                sptem.textureSelection.Main.XSize = 256;
                sptem.textureSelection.Main.YSize = 256;
                sptem.animationFrames             = 15;
                sptem.animationSpeed = 1;
                sptem.isAnimating    = true;
                objects.Add(new Object2D(sptem, 0, 100));
                objects.Add(new Object2D(new Sprite(sptem), 464, 100));
            }

            /*
             * input.SubscribeToKey("Select", objects[2].OnButtonPress);
             * objects[2].PressedEvent += delegate {
             *  objects[0].position.Y = 328 + 128;
             *  for (int i = 2; i < 10; i++) {
             *      objects[i].tintColor = new Color(0, 0, 0, 0);
             *  }
             * };*/

            input.SubscribeToKey("Select", objects[2].OnButtonPress);
            objects[2].PressedEvent += delegate {
                if (battleEngine.Player1.SelectAction(0))
                {
                }
                else
                {
                }
            };

            input.SubscribeToKey("Select", objects[3].OnButtonPress);
            objects[3].PressedEvent += delegate {
                Console.WriteLine("h");
                SceneService.OpenOverlay(new SettingsMenu(this));
            };

            input.SubscribeToKey("Select", objects[4].OnButtonPress);
            objects[4].PressedEvent += delegate {
                //objects[12].PlayAnimation(1);
                opponentAnim.Play = true;
            };

            input.SubscribeToKey("Select", objects[5].OnButtonPress);
            objects[5].PressedEvent += delegate {
                battleEngine.Player1.SelectAction(0);
            };

            input.SubscribeToKey("Select", objects[6].OnButtonPress);
            objects[6].PressedEvent += delegate {
                rot -= 2;
            };

            input.SubscribeToKey("Select", objects[7].OnButtonPress);
            objects[7].PressedEvent += delegate {
                decreaseTimer = true;
            };

            for (int i = 2; i < 10; i++)
            {
                objects[i].tintColor = new Color(0, 0, 0, 0);
            }

            newanim.AddTransition(objects[0], 0.35, 0, new DiscreteVector2(248, 328 + 128), new DiscreteVector2(248, 328));

            newanim.AddTransition(objects[2], 0.2, 0.2, -50, 0);
            newanim.AddTransition(objects[3], 0.2, 0.15, -50, 0);
            newanim.AddTransition(objects[4], 0.2, 0.1, -50, 0);
            newanim.AddTransition(objects[8], 0.2, 0.05, -50, 0);
            newanim.AddTint(objects[2], 0.2, 0.2, false);
            newanim.AddTint(objects[3], 0.2, 0.15, false);
            newanim.AddTint(objects[4], 0.2, 0.1, false);
            newanim.AddTint(objects[8], 0.2, 0.05, false);

            newanim.AddTransition(objects[5], 0.2, 0.2, 50, 0);
            newanim.AddTransition(objects[6], 0.2, 0.15, 50, 0);
            newanim.AddTransition(objects[7], 0.2, 0.1, 50, 0);
            newanim.AddTransition(objects[9], 0.2, 0.05, 50, 0);
            newanim.AddTint(objects[5], 0.2, 0.2, false);
            newanim.AddTint(objects[6], 0.2, 0.15, false);
            newanim.AddTint(objects[7], 0.2, 0.1, false);
            newanim.AddTint(objects[9], 0.2, 0.05, false);

            objects[0].animator.AddAnimation(newanim);

            userAnim.AddSprite(objects[12], 0, 1);
            userAnim.AddSprite(objects[11], 1, 1);

            objects[12].animator.AddAnimation(userAnim);

            opponentAnim.AddSprite(objects[13], 0, 1);
            opponentAnim.AddSprite(objects[10], 1, 1);

            objects[12].animator.AddAnimation(opponentAnim);
        }