Exemple #1
0
    void Start()
    {
        SoundManager.instance.PlayMusic();

        foreach (Unit u in units)
        {
            RhythmEngine.GetTagged().AddMarching(u);
        }
    }
Exemple #2
0
    void Start()
    {
        RhythmEngine rm = RhythmEngine.GetTagged();

        foreach (Unit unit in units)
        {
            rm.AddMarching(unit);
        }
        if (boss != null)
        {
            rm.SetBoss(boss);
        }
    }
Exemple #3
0
 void Update()
 {
     for (int i = units.Count - 1; i >= 0; --i)
     {
         Unit u = units[i];
         if (u.transform.localPosition.x < 1.0f)
         {
             RhythmEngine.GetTagged().RemoveMarching(u);
             u.Kill(despawnDelta);
             units.RemoveAt(i);
         }
     }
     if (units.Count == 0)
     {
         SceneManager.LoadScene("Lose");
     }
 }
Exemple #4
0
 public RhythmRenderer(RhythmEngine engine)
 {
     host        = engine;
     leftRender  = new TrackRenderer(host.LeftPlayer);
     rightRender = new TrackRenderer(host.RightPlayer);
 }
Exemple #5
0
    void Update()
    {
        if (Time.time >= Constants.Level1Duration)
        {
            if (isBossAdded)
            {
                return;
            }

            if (boss != null)
            {
                boss.EnterLevel();
                RhythmEngine.GetTagged().SetBoss(boss);
                isBossAdded = true;
                print("Added boss, great success!");
            }
            else
            {
                print("Boss not attached to this GameObject, ignoring");
            }

            return;
        }

        if (ProgressUpdated != null)
        {
            float passed   = SoundManager.instance.GetCurrentTime();
            float progress = passed / Constants.Level1Duration * 100;
            ProgressUpdated(progress, EventArgs.Empty);
        }

        // Movement
        Vector3 movement = new Vector3(speed.x * direction.x, speed.y * direction.y, 0);

        movement *= Time.deltaTime;
        transform.Translate(movement);

        // Move the camera
        if (isLinkedToCamera)
        {
            Camera.main.transform.Translate(movement);
        }

        // 4 - Loop
        if (isLooping)
        {
            // Get the first object.
            // The list is ordered from left (x position) to right.
            SpriteRenderer firstChild = backgroundPart.FirstOrDefault();

            if (firstChild != null)
            {
                // Check if the child is already (partly) before the camera.
                // We test the position first because the IsVisibleFrom
                // method is a bit heavier to execute.
                if (firstChild.transform.position.x < Camera.main.transform.position.x)
                {
                    // If the child is already on the left of the camera,
                    // we test if it's completely outside and needs to be
                    // recycled.
                    if (firstChild.IsVisibleFrom(Camera.main) == false)
                    {
                        // Get the last child position.
                        SpriteRenderer lastChild = backgroundPart.LastOrDefault();

                        Vector3 lastPosition = lastChild.transform.position;
                        Vector3 lastSize     = (lastChild.bounds.max - lastChild.bounds.min);

                        // Set the position of the recyled one to be AFTER
                        // the last child.
                        // Note: Only work for horizontal scrolling currently.
                        firstChild.transform.position = new Vector3(lastPosition.x + lastSize.x, firstChild.transform.position.y, firstChild.transform.position.z);

                        // Set the recycled child to the last position
                        // of the backgroundPart list.
                        backgroundPart.Remove(firstChild);
                        backgroundPart.Add(firstChild);
                    }
                }
            }
        }
    }
        // Methods
        public PlayingState(ActGame Host, Configuration.IOConfig.KeyboardConfig.PlayerKeyConfig LeftControlConfig, Configuration.IOConfig.KeyboardConfig.PlayerKeyConfig RightControlConfig, LinkedList <TrackSelection>[] Selections)
            : base(Host)
        {
            FighterSpriteSheets      = new SpriteSheet[noPlayers];
            FighterSpriteSheets[atk] = Host.fighterSpriteSheet;
            FighterSpriteSheets[def] = Host.fighterSpriteSheet;

            InitialPositions      = new Vector2[noPlayers];
            InitialPositions[atk] = new Vector2(400, 400);
            InitialPositions[def] = new Vector2(400, 200);

            ValidRects      = new Rectangle[noPlayers];
            ValidRects[atk] = new Rectangle(250, 250, 300, 150);
            ValidRects[def] = new Rectangle(250, 50, 300, 150);

            bullet        = new Bullet();
            bullet.Sprite = Host.bulletSpriteSheet.FrameSprite(0);

            Fighters = new Fighter[noPlayers];
            for (int i = 0; i < noPlayers; ++i)
            {
                Fighters[i]        = new Fighter(Host, ValidRects[i], bullet, RegisterBullet);
                Fighters[i].Sprite = FighterSpriteSheets[i].FrameSprite(0);
            }

            Keyconfigs      = new Configuration.IOConfig.KeyboardConfig.PlayerKeyConfig[noPlayers];
            Keyconfigs[atk] = LeftControlConfig;
            Keyconfigs[def] = RightControlConfig;

            SetActivePlayer(PlayerIndex.One);

            Ps = new ParticleSystem();

            Re = new RhythmEngine(Host.Config);
            Re.SelectionList = Selections;

            Re.LeftPlayer.VisibleRange  = 2000;
            Re.RightPlayer.VisibleRange = 2000;

            Re.LeftPlayer.ShowDebug  = false;
            Re.RightPlayer.ShowDebug = true;

            Rr      = new RhythmRenderer(Re);
            Rr.Font = Host.sysFont;

            Rr.LeftDrawRect  = new Rectangle(8, 8, 192, 350);
            Rr.RightDrawRect = new Rectangle(600, 8, 192, 350);

            LeftController  = Host.LeftController;
            RightController = Host.RightController;

            // TODO: Debug AI
            //LeftController = new AiController(Host.Config.IO.Keyboard.Left.Rhythm.KeyCount, Fighters[atk], Re.players[atk]);
            RightController = new AiController(Host.Config.IO.Keyboard.Right.Rhythm.KeyCount, Fighters[def], Re.players[def]);

            Re.Lock();
            Re.Play();

            Particle particle = new Particle(Host.particle1SpriteSheet);

            GraphicsObject[] FighterGraphicObjs = new GraphicsObject[noPlayers];
            for (int i = 0; i < noPlayers; ++i)
            {
                FighterGraphicObjs[i] = new GraphicsObject(Fighters[i]);
            }

            foreach (GraphicsObject obj in FighterGraphicObjs)
            {
                obj.CreateEmitter(new Vector2(0, 5), 0.15f, -MathHelper.PiOver2, MathHelper.PiOver4, 100, 250, 150, particle, true);
                obj.CreateEmitter(new Vector2(-5, 2), 0.15f, -0.6f * MathHelper.PiOver2, MathHelper.PiOver4 / 2.0f, 50, 250, 150, particle, true);
                obj.CreateEmitter(new Vector2(5, 2), 0.15f, -1.4f * MathHelper.PiOver2, MathHelper.PiOver4 / 2.0f, 50, 250, 150, particle, true);

                Ps.RegisterGraphicsObject(obj);
            }
        }