Esempio n. 1
0
 public UI()
 {
     dialogue = new Dialogue();
     this.AddChild(dialogue);
     background = new FSprite("bg");
     slotA = new FSprite("slot_a");
     slotB = new FSprite("slot_b");
     slotASelected = new FSprite("jump_soul");
     slotBSelected = new FSprite("sword_soul");
     hearts = new FSprite("heart_full");
     this.AddChild(background);
     this.AddChild(slotA);
     this.AddChild(slotB);
     this.AddChild(slotASelected);
     this.AddChild(slotBSelected);
     this.AddChild(hearts);
     slotASelected.isVisible = false;
     slotBSelected.isVisible = false;
     background.y = Futile.screen.halfHeight - background.height / 2f;
     slotB.y = background.y;
     slotA.y = background.y;
     slotB.x = -Futile.screen.halfWidth + slotB.width / 2f + 20;
     slotA.x = slotB.x + slotB.width / 2f + slotA.width / 2f + 3;
     slotASelected.SetPosition(slotA.GetPosition());
     slotBSelected.SetPosition(slotB.GetPosition());
     slotASelected.x += 1;
     slotBSelected.x += 1;
     hearts.y = background.y;
     hearts.x = Futile.screen.halfWidth - hearts.width / 2f - 20;
 }
Esempio n. 2
0
    public bool InScreenRect(FSprite sprite)
    {
        Vector2 position = sprite.GetPosition() + _camera.worldContainer.GetPosition();
        Vector2 halfSize = new Vector2(sprite.width * sprite.scaleX, sprite.height * sprite.scaleY) * 0.5f;

        return((position.x + halfSize.x > -Futile.screen.halfWidth && position.x - halfSize.x < Futile.screen.halfWidth) &&
               (position.y + halfSize.y > -Futile.screen.halfHeight && position.y - halfSize.y < Futile.screen.halfHeight));
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        Vector2 position = TextureA.GetPosition();

        position.y = Mathf.Lerp(position.y - 10f, position.y + 10f, Mathf.PingPong(Time.time, 1.0f));
        TextureA.SetPosition(position);
        TextureA.alpha = Mathf.PingPong(Time.time, 1);

        position   = TextureB.GetPosition();
        position.x = Mathf.Lerp(position.x - 10f, position.x + 10f, Mathf.PingPong(Time.time, 1.0f));
        TextureB.SetPosition(position);
        TextureB.alpha = Mathf.PingPong(Time.time, 1);

        // bad collision detection:
        if (TextureA.textureRect.CloneAndOffset(TextureA.GetPosition().x, TextureA.GetPosition().y).CheckIntersect(TextureB.textureRect.CloneAndOffset(TextureB.GetPosition().x, TextureB.GetPosition().y)))
        {
            //flash the screen
            Background.alpha = Background.alpha == 0 ? Background.alpha = 1 : Background.alpha = 0;
        }
    }
Esempio n. 4
0
    private Ym90_GUI() : base()
    {
        FSprite statusBar = new FSprite("statusBar_bg");

        statusBar.y = Futile.screen.halfHeight - statusBar.height / 2;
        guiLayer.AddChild(statusBar);

        FSprite boxGPS = new FSprite("box_gps");

        boxGPS.x = -Futile.screen.halfWidth + boxGPS.width / 2 + 7;
        boxGPS.y = statusBar.y;
        guiLayer.AddChild(boxGPS);

        FSprite centerGPS = new FSprite("gps_center");

        centerGPS.x = boxGPS.x - boxGPS.width / 4;
        centerGPS.y = boxGPS.y;
        guiLayer.AddChild(centerGPS);

        FSprite[] healthSprites = new FSprite[4];
        float     healthPadding = 1;

        for (int x = 0; x < 4; x++)
        {
            healthSprites[x] = new FSprite("health_full");
            float startX = -(healthSprites[x].width + healthPadding) * 1.8f;
            healthSprites[x].x = startX + (healthSprites[x].width + healthPadding) * x;
            healthSprites[x].y = statusBar.y;
            guiLayer.AddChild(healthSprites[x]);
        }

        FSprite primaryWeaponBox = new FSprite("box_items");

        primaryWeaponBox.x = Futile.screen.halfWidth - primaryWeaponBox.width * 2 - 2;
        primaryWeaponBox.y = statusBar.y;
        guiLayer.AddChild(primaryWeaponBox);

        FSprite secondaryWeaponBox = new FSprite("box_items");

        secondaryWeaponBox.x = primaryWeaponBox.x + primaryWeaponBox.width + 5;
        secondaryWeaponBox.y = statusBar.y;
        guiLayer.AddChild(secondaryWeaponBox);

        FSprite primaryWeapon = new FSprite("weapon_swordArm");

        primaryWeapon.SetPosition(primaryWeaponBox.GetPosition());
        guiLayer.AddChild(primaryWeapon);

        this.AddChild(guiLayer);
        this.AddChild(overlay);
    }
Esempio n. 5
0
        public override void Update(float deltaTime)
        {
            Vector2 backgroundTargetPosition = -mousePosition * 0.03f +
                                               new Vector2(Mathf.PerlinNoise(time, 0f) - 0.5f, Mathf.PerlinNoise(0f, time) - 0.5f) * 5f;

            _background.SetPosition(Vector2.Lerp(_background.GetPosition(), backgroundTargetPosition, deltaTime * 3f));

            _background.alpha = Mathf.Lerp(0f, 0.5f, (time - 1f) * 0.5f);
            for (int i = 0; i < _titleSprites.Length; i++)
            {
                _titleSprites[i].y = Mathf.Lerp(-screenHeight, screenHeight * 0.5f - 60f, CustomMath.Curve(time - (i * 0.2f), -3f)) + Mathf.Sin(time * 3f - i) * 4f;
            }
            for (int i = 0; i < _buttons.Length; i++)
            {
                _buttons[i].position = new Vector2(-screenWidth * 0.5f + Mathf.Lerp(-24f, 40f, CustomMath.Curve(time - 1f - (i * 0.2f), -3f)), _buttons[i].position.y);
            }
            _visitDevLog.position = new Vector2(screenWidth * 0.5f + Mathf.Lerp(48f, -64f, CustomMath.Curve(time - 3f, -3f)), _visitDevLog.position.y);

            base.Update(deltaTime);
        }
Esempio n. 6
0
    public UI(World w)
    {
        this.w = w;
        for (int i = 0; i < MAX_HEALTH; i++)
        {
            hearts[i] = new FSprite("heart");
            hearts[i].x = Futile.screen.halfWidth - hearts[i].width / 2f - uiSideMargin - (i * (hearts[i].width + heartSpace));
            hearts[i].y = Futile.screen.halfHeight - hearts[i].height / 2f - uiSideMargin;
            this.AddChild(hearts[i]);

        }
        selectedPowerupBG = new FSprite("powerupSelect");
        selectedPowerupBG.x = -Futile.screen.halfWidth + selectedPowerupBG.width / 2f + uiSideMargin + 20;
        selectedPowerupBG.y = hearts[0].y;
        this.AddChild(selectedPowerupBG);

        selectedPowerup = new FSprite("normalpowerup");
        selectedPowerup.SetPosition(selectedPowerupBG.GetPosition());
        this.AddChild(selectedPowerup);

        killCount = new FLabel(C.smallFontName, "0");
        killCount.y = Futile.screen.halfHeight - killCount.textRect.height / 2f - uiSideMargin;
        this.AddChild(killCount);
    }
Esempio n. 7
0
 public void HandlePlayerCollision(Player p)
 {
     if (p.isColliding(this))
     {
         //FSoundManager.PlaySound("powerup");
         isBeingPickedUp = true;
         FSoundManager.TweenVolume(.3f);
         p.isVisible = false;
         Go.killAllTweensWithTarget(p);
         p.State = Player.PlayerState.IDLE;
         p.xVel = 0;
         p.yVel = 0;
         Go.killAllTweensWithTarget(this);
         FSprite playerPickup = new FSprite("player_13");
         C.getCameraInstance().AddChild(playerPickup);
         Vector2 playerRelativePosition = p.GetPosition() + Futile.stage.GetPosition() - Vector2.up * 16f;
         playerPickup.SetPosition(playerRelativePosition);
         this.SetPosition(this.GetPosition() + Futile.stage.GetPosition() - Vector2.up * 16f);
         world.removeObject(this);
         C.getCameraInstance().AddChild(this);
         world.forceWaitLoad = true;
         RXDebug.Log(this.GetPosition(), playerPickup.GetPosition());
         this.MoveToFront();
         FLabel label = new FLabel(C.largeFontName, type.ToString().ToUpper() + " SPIRIT");
         C.getCameraInstance().AddChild(label);
         label.y = Futile.screen.halfHeight - label.textRect.height / 2f - 10;
         label.x = Futile.screen.halfWidth + label.textRect.width / 2f + 10;
         world.ShowLoading(() =>
         {
             Go.to(playerPickup, 2.0f, new TweenConfig().floatProp("x", 0).floatProp("y", -15).setEaseType(EaseType.QuadOut));
             Go.to(this, 2.0f, new TweenConfig().floatProp("x", 0).floatProp("y", 15).setEaseType(EaseType.QuadOut));
             Go.to(label, 1.5f, new TweenConfig().floatProp("x", 0).setEaseType(EaseType.BackOut).setDelay(1.5f).onComplete(() =>
             {
                 Go.to(this, .01f, new TweenConfig().floatProp("x", 1, true).onComplete(() =>
                 {
                     Go.to(this, .01f, new TweenConfig().floatProp("x", -2, true).setIterations(100, LoopType.PingPong).onComplete(() =>
                     {
                         FSoundManager.PlaySound("orbExplosion");
                         FSoundManager.PlaySound("powerup");
                         SpawnParticles(30);
                         this.x -= 1;
                         sprite.SetElementByName(type.ToString().ToLower() + "_soul");
                         Go.to(label, 1.5f, new TweenConfig().floatProp("x", -Futile.screen.halfWidth - label.textRect.width / 2f - 10).setEaseType(EaseType.BackIn).setDelay(2.0f).onStart((AbstractTween t) => { }).onComplete(() =>
                         {
                             label.RemoveFromContainer();
                             Go.to(playerPickup, 1.0f, new TweenConfig().floatProp("x", playerRelativePosition.x).floatProp("y", playerRelativePosition.y).setEaseType(EaseType.QuadInOut).onComplete(() =>
                             {
                                 FSoundManager.TweenVolume(1.0f);
                                 p.PickupSoul(this);
                                 world.HideLoading(() => { p.isVisible = true; playerPickup.RemoveFromContainer(); this.RemoveFromContainer(); });
                             }));
                             Vector2 powerupPos;
                             switch(type)
                             {
                                 case SoulType.JUMP:
                                     powerupPos = world.ui.slotAPos;
                                     break;
                                 default:
                                     powerupPos = world.ui.slotBPos;
                                     break;
                             }
                             Go.to(this, 1.0f, new TweenConfig().floatProp("x", powerupPos.x).floatProp("y", powerupPos.y).setEaseType(EaseType.QuadInOut));
                         }));
                     }));
                 }));
             }));
         });
     }
 }