Ejemplo n.º 1
0
 public Logo(string texName, UnitCamera cam)
     : base(Constants.TIME_TICKS_EVENT)
 {
     var tex = XNADevicesManager.Instance.ContentManager.Load<Texture2D>(texName);
     _unitCam = cam;
     _sprite = new Sprite(tex);
     _sprite.DrawRectangle = new Rectangle(0, 0, tex.Width, tex.Height);
     _scale = new Scale(0.2f, 1.0f, 0.2f, 1.0f, 1500);
     _scale.EaseFunction = EaseFunction.Out_Elastic;
     _scale.Target = _sprite;
     _timer = new Timer(2000);
     _timer.OnTimer += _timer_OnTimer;
 }
        private void LoadIntro()
        {
            _clearScreen = new Sprite(XNADevicesManager.Instance.ContentManager.Load<Texture2D>("black1x1"));
            _clearScreen.DrawRectangle = new Rectangle(0, 0, 1, 1);
            _clearScreen.Position = _player1.Sprite.Position;
            _clearScreen.Z = 315;
            _clearScreen.ScaleX = 4096.0f;
            _clearScreen.ScaleY = 4096.0f;
            Root.Add(_clearScreen);

            _fadeScreen = new Fade(1.0f, 0.0f, 2000);
            _fadeScreen.EaseFunction = EaseFunction.In_Cubic;
            _fadeScreen.Target = _clearScreen;
            _fadeScreen.OnEnd += s => { _clearScreen.IsVisible = false; };

            _boardTexs = new string[4];
            _boardTexs[0] = "intro0";
            _boardTexs[1] = "intro1";
            _boardTexs[2] = "intro2";
            _boardTexs[3] = "intro3";

            _board = new Board(_boardTexs[0], _unitCam);
            _board.Distance = 285;
            _board.OnHide += (s, e) => { Pause = false; };
            Root.Add(_board.Sprite);

            var logo = new Logo("logo", _unitCam);
            logo.Distance = 284;
            logo.Show();
            AuditionManager.Instance.PlayBGM("surrounded");
            Root.Add(logo.Sprite);

            _startTimer = new Timer(5500);
            _startTimer.OnTimer += sender =>
            {
                _fadeScreen.Start();
                Pause = false;
                _introTimer.Start();
            };
            _startTimer.Start();

            _introTimer = new Timer(1000);
            _introTimer.OnTimer += sender =>
            {
                _board.SwitchTex(_boardTexs[_countBoard]);
                _board.Show();
                Pause = true;
            };

            Pause = true;
        }
        private void LoadEnemies()
        {
            _enemies = new Collection<Character>();

            for (int i = 0; i < 30; i++)
            {
                Character enemy;
                int rand = RandomHelper.NextInt(0, 3);
                if (rand == 1)
                {
                    float size = RandomHelper.NextFloat(1.0f, 1.5f);
                    enemy = CreateCharacter(@"Data\Dan.xml", Group.PlayerTwo, RandomHelper.NextFloat(-8000, 9500), 200,
                        100, 5, 120, 400, size, size, RandomHelper.NextFloat(0.9f, 1.3f),
                        RandomHelper.NextFloat(0.5f, 1.5f), RandomHelper.NextFloat(0.9f, 1.3f));
                    enemy.Actions["Attack"].ActionStart += sender =>
                    {
                        var timer = new Timer(500);
                        timer.EventData = sender.Character;
                        timer.OnTimer += timerSender =>
                        {
                            var dan = (Character) timerSender.EventData;
                            if (dan.Actions["Attack"].IsDoing)
                            {
                                var sprite = new Sprite(_soundTex);
                                sprite.DrawRectangle = new Rectangle(0, 0, _soundTex.Width, _soundTex.Height);
                                sprite.Position = dan.Sprite.Position;
                                sprite.ScaleX = dan.Sprite.ScaleX;
                                sprite.ScaleY = dan.Sprite.ScaleY;
                                sprite.R = dan.Sprite.R;
                                sprite.G = dan.Sprite.G;
                                sprite.B = dan.Sprite.B;
                                sprite.Z += 2.0f;
                                Root.Add(sprite);
                                var soundFrame = new Frame(_soundFrameDef);
                                soundFrame.Speed = 2.0f;
                                soundFrame.OnEnd += frameSender =>
                                {
                                    var frame = (Frame) frameSender;
                                    frame.Target.Parent.Remove(frame.Target);
                                };
                                soundFrame.Target = sprite;
                                soundFrame.Start();
                            }
                        };
                        timer.Start();
                    };
                }
                else if (rand == 2)
                {
                    float size = RandomHelper.NextFloat(1.0f, 1.5f);
                    enemy = CreateCharacter(@"Data\Dan1.xml", Group.PlayerTwo, RandomHelper.NextFloat(-8000, 9500), 200,
                        100, 5, 150, 500, size, size, RandomHelper.NextFloat(0.9f, 1.3f),
                        RandomHelper.NextFloat(0.5f, 1.5f), RandomHelper.NextFloat(0.9f, 1.3f));
                }
                else //if (rand == 3)
                {
                    float size = RandomHelper.NextFloat(1.0f, 1.5f);
                    enemy = CreateCharacter(@"Data\Hua.xml", Group.PlayerTwo, RandomHelper.NextFloat(-8000, 9500), 200,
                        100, 5, 100, 450, size, size, RandomHelper.NextFloat(-0.1f, 0.3f),
                        RandomHelper.NextFloat(0.5f, 1.5f), RandomHelper.NextFloat(0.9f, 1.3f));
                }

                enemy.AI.LoadAIScript(@"AI\Enemy.py");
                _enemies.Add(enemy);

                Root.Add(enemy.Sprite);
                EventManager.Register(enemy.AI);
            }
        }
Ejemplo n.º 4
0
 private void _timer_OnTimer(Timer sender)
 {
     Hide();
 }