Exemplo n.º 1
0
        public override void Start()
        {
            base.Start();

            AudioManager.InitPlayScene();
            //AudioManager.Load();

            //GfxManager.Load(); fatto in Game
            IsLoadingCheckpoint = false;
            IsPaused            = false;
            Player = null;

            Rect.Debug              = false;
            Circle.Debug            = false;
            PhysicsManager.RayDebug = false;

            Vector2 screenCenter = new Vector2(Game.Window.Width / 2, Game.Window.Height / 2);

            CameraManager.Init(screenCenter, screenCenter);
            CameraManager.AddCamera("GUI", 0f);

            PhysicsManager.Init();
            GuiManager.Init();
            ItemPickableManager.Init();
            BackgroundManager.Init(new Vector2(0, -158));

            GfxManager.LoadTiledMap("Assets/Tiles/level.tmx");

            // CameraManager.mainCamera.position = Player.Position;  //togliere
            CameraManager.SetTarget(Player);

            AudioManager.SetDefaultClipBackground("defaultClipBackground");
        }
Exemplo n.º 2
0
        public override void OnHit(GameObject hitObject)
        {
            if (hitObject is Player)
            {
                if (RandomGenerator.GetRandom(0, 100) < PROB_LIFE)
                {
                    ExtraLife extraLife = (ExtraLife)ItemPickableManager.GetItem(PickableType.ExtraLife);
                    extraLife.IsActive = true;
                    extraLife.Position = Position;
                    extraLife.OnPlayerPick();
                }
                else
                {
                    int             randomApples        = RandomGenerator.GetRandom(MIN_APPLE, MAX_APPLE + 1);
                    List <Pickable> apples              = ItemPickableManager.GetItems(PickableType.Apple, randomApples);
                    Vector2         offsetBetweenApples = Vector2.Zero;

                    for (int i = 0; i < apples.Count; i++)
                    {
                        Apple apple = (Apple)apples[i];
                        apple.IsActive       = true;
                        apple.Position       = Position + offsetBetweenApples;
                        offsetBetweenApples += new Vector2(apple.Width / 3, apple.Height / 2);
                        apple.OnPlayerPick();
                    }
                }
            }

            base.OnHit(hitObject);
        }
Exemplo n.º 3
0
        private void Bounce(Player player)
        {
            if (audioSourceBounce == null)
            {
                audioSourceBounce = new AudioSource();
            }

            if (!audioSourceBounce.IsPlaying)
            {
                audioSourceBounce.Play(clipBounce);
            }

            Animation.Reset();
            Animation.NextFrame();
            player.Jump(bounceMultiplierY);

            apples -= NUM_APPLES_AT_BOUNCE;

            List <Pickable> appleList = ItemPickableManager.GetItems(PickableType.Apple, NUM_APPLES_AT_BOUNCE);
            Vector2         offset    = Vector2.Zero;

            foreach (Apple apple in appleList)
            {
                apple.IsActive = true;
                apple.Position = Position + offset;
                apple.OnPlayerPick();
                offset += new Vector2((apple.Width * 2) / NUM_APPLES_AT_BOUNCE, (apple.Height * 2) / NUM_APPLES_AT_BOUNCE);
            }

            if (apples <= 0)
            {
                OnDie();
            }
        }
Exemplo n.º 4
0
        public override void OnHit(GameObject hitObject)
        {
            if (hitObject is Player)
            {
                Apple apple = (Apple)ItemPickableManager.GetItem(PickableType.Apple);
                apple.IsActive = true;
                apple.Position = Position;
                apple.OnPlayerPick();
            }

            base.OnHit(hitObject);
        }
Exemplo n.º 5
0
        public override void OnHit(GameObject hitObject)
        {
            if (hitObject is Player && !isHitted)
            {
                ExtraLife extraLife = (ExtraLife)ItemPickableManager.GetItem(PickableType.ExtraLife);
                extraLife.IsActive = true;
                extraLife.Position = Position;
                extraLife.OnPlayerPick();
            }

            base.OnHit(hitObject);
        }
Exemplo n.º 6
0
 public virtual void OnDie()
 {
     IsActive = false;
     RigidBody.IsCollisionsAffected = true;
     ItemPickableManager.RestoreItem(this);
 }