コード例 #1
0
ファイル: TweenTerrain.cs プロジェクト: philipcass/art_game
    public TweenTerrain()
    {
        height = 768;
        width = 768;
        halfWidth = width/2;
        halfHeight = height/2;

        TextAsset t = Resources.Load("map") as TextAsset;
        IDictionary dict =  Json.Deserialize(t.text) as IDictionary;
        IList layers = dict["layers"] as IList;
        IDictionary layer = layers[0] as IDictionary;
        IList data = layer["data"] as IList;
        int index = 0;

        tiles = new FSprite[((int)height+tileSize)/tileSize,((int)width+tileSize)/tileSize];
        for(float y = -halfHeight; y < halfHeight; y+=tileSize){
            for(float x = -halfWidth; x < halfWidth; x+=tileSize){
                FSprite s = new FSprite(Futile.whiteElement);
                if((long)data[index++] == 1)
                    enablesTiles.Add(s);
                s.SetPosition(x,y);
                s.scale = 0;
                s.alpha = 0;
                tiles[(int)(y+halfHeight)/tileSize,(int)(x+halfWidth)/tileSize] = s;
                this.AddChild(s);
            }
        }
        Debug.Log(index);
    }
コード例 #2
0
ファイル: UI.cs プロジェクト: maggardJosh/SpiritGuard
 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;
 }
コード例 #3
0
ファイル: Vill.cs プロジェクト: MattRix/BewareWolf
    override public void Update()
    {
        hopper.Update();

        attackCooldown -= Time.deltaTime;

        if (attackCooldown < 0)
        {
            attackCooldown = RXRandom.Range(0.9f, 1.0f) * Config.VILLAGER_ATTACK_COOLDOWN;

            if (Arena.instance != null && Arena.instance.dayManager.isDay)
            {
                CheckForAttack();
            }
        }

        float scaleXMultiplier = body.scaleX < 0 ? -1f : 1f;
        float scaleMultiplier  = 1.0f;

        if (hopper.jumpTime > 0)
        {
            scaleXMultiplier = (hopper.speedX < 0) ? -1.0f : 1.0f;
            scaleMultiplier  = 0.75f + 0.3f * hopper.jumpY;
        }

        body.scaleX = scaleXMultiplier / scaleMultiplier;
        body.scaleY = scaleMultiplier;

        bodySprite.y  = offsetY + hopper.jumpY * hopper.config.jumpHeight;
        colorSprite.y = bodySprite.y;
        weapon.x      = bodySprite.x + 4;
        weapon.y      = bodySprite.y + 4;

        pushSpeed *= 0.93f;

        if (pushSpeed.sqrMagnitude > 0.05f)
        {
            float newX = x + pushSpeed.x;
            float newY = y + pushSpeed.y * Config.ISO_RATIO;

            if (!entityArea.CheckVillPointHit(newX, newY))
            {
                x = newX;
                y = newY;
            }
            else if (!entityArea.CheckVillPointHit(x, newY))
            {
                pushSpeed.x = -pushSpeed.x * 0.5f;
                y           = newY;
            }
            else if (!entityArea.CheckVillPointHit(newX, y))
            {
                x           = newX;
                pushSpeed.y = -pushSpeed.y * 0.5f;
            }
        }

        body.SetPosition(x, y);
        shadowSprite.SetPosition(x, y);
    }
コード例 #4
0
    public virtual void RenderUpdate(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        if (world != null)
        {
            FSprite sprite = spriteLeaser.sprites[0];

            if (element != null)
            {
                sprite.isVisible = true;
                sprite.element   = element;
            }
            else
            {
                sprite.isVisible = false;
            }
            sprite.SetPosition(camera.GetScreenPosition(worldPosition) + _positionOffset);
            sprite.rotation = _rotation;
            sprite.scaleX   = scale.x;
            sprite.scaleY   = scale.y;
            if (doesFlip)
            {
                sprite.scaleX *= (camera.GetFlipXByViewAngle(viewAngle) ? -1f : 1f);
            }
            sprite.sortZ = camera.GetSortZ(worldPosition) + sortZOffset;
            sprite.color = color; // new Color(worldPosition.x, worldPosition.y, worldPosition.z);
        }
        else
        {
            spriteLeaser.Erase();
        }
    }
コード例 #5
0
ファイル: LevelBar.cs プロジェクト: tanis2000/Futile
        public LevelBar(int numDashes)
        {
            this.numDashes = numDashes;
            string borderElementName = "UI/Stats/LevelBar_" + numDashes;

            if (numDashes == 5) {
                dashWidth = 19;
            } else if (numDashes == 10) {
                dashWidth = 9;
            } else if (numDashes == 25) {
                dashWidth = 3;
            }

            AddChild (barContainer = new FContainer ());

            barContainer.AddChild (background = new FSprite ("Box")); //black bg
            background.color = Color.black;
            background.SetAnchor (0.0f, 0.0f);

            barContainer.AddChild (borderSprite = new FSprite (borderElementName));//white border
            borderSprite.SetAnchor (0.0f, 0);
            borderSprite.SetPosition (0, 0);

            barContainer.AddChild (dashContainer = new FContainer ());

            dashSpacing = 1;
            totalWidth = 100;
            dashHeight = 3;
            barOffset = new Vector2 (-51, 0);
            dashOffset = new Vector2 (1, 2);
            ApplyConfig ();
        }
コード例 #6
0
                public override void GrafUpdate(float timeStacker)
                {
                    base.GrafUpdate(timeStacker);

                    arrow.SetPosition(DrawPos(timeStacker) + DrawSize(timeStacker) / 2f);
                    arrow.color = buttonBehav.greyedOut ? Color.gray : Color.white;
                }
コード例 #7
0
ファイル: LevelBar.cs プロジェクト: MattRix/BewareWolf
 void ApplyConfig()
 {
     barContainer.SetPosition(barOffset);
     background.SetPosition(1, 1.5f);
     background.height = dashHeight + 1.0f;
     background.width  = totalWidth - 1;
 }
コード例 #8
0
ファイル: InGamePage.cs プロジェクト: philipcass/simple_racer
    override public void Start()
    {
        ListenForUpdate(HandleUpdate);

        st = new SimpleTimer();
        st.Start();

        gameNodes = new FContainer();
        Futile.atlasManager.LoadImage("car");

        WEHTiled hurr = new WEHTiled("track");

        gameNodes.AddChild(hurr.DrawLayer(0));
        FContainer coll = hurr.DrawLayer(1);

        gameNodes.AddChild(coll);

        c          = new Car(Futile.atlasManager.GetElementWithName("car"), coll);
        c.x        = Futile.screen.width;
        c.y        = -Futile.screen.height;
        c.rotation = 90;
        gameNodes.AddChild(c);

        lapCollider        = new FSprite(Futile.whiteElement);
        lapCollider.scaleY = 5;
        lapCollider.SetPosition(1220, -832);
        lapCollider.alpha = 0;
        gameNodes.AddChild(lapCollider);

        RXWatcher.Watch(gameNodes);
        RXWatcher.Watch(lapCollider);

        this.AddChild(gameNodes);
        SetupUI();
    }
コード例 #9
0
        public void SetConstructionGuide(WorldCamera worldCamera, Player player, Vector3 worldPosition, Vector3 hitDirection, bool inRange)
        {
            _previewSprite.SetPosition(worldCamera.GetScreenPosition(worldPosition + hitDirection));
            _previewSprite.sortZ = worldCamera.GetSortZ(worldPosition) + 0.1f;

            _previewSprite.color = inRange ? Color.cyan : Color.red;
            _previewSprite.alpha = Mathf.Sin(menu.time * Mathf.PI) * 0.25f + 0.5f;

            _previewSprite.element = player.pickItemStack.item.element;
        }
コード例 #10
0
ファイル: OpImage.cs プロジェクト: metnias/CompletelyOptional
 public override void OnChange()
 {
     base.OnChange();
     if (!_init) { return; }
     sprite.alpha = _alpha;
     sprite.color = _color;
     sprite.SetPosition(Vector2.zero);
     sprite.scaleX = _scale.x;
     sprite.scaleY = _scale.y;
     _size = new Vector2(sprite.element.sourceSize.x * _scale.x, sprite.element.sourceSize.y * _scale.y);
 }
コード例 #11
0
ファイル: UIMatchPlayer.cs プロジェクト: StaphiX/Tactics
 public override void Update()
 {
     if (m_tAI != null)
     {
         Vector2 tPosition = m_tAI.GetPosition();
         SetParentOffset(tPosition.x, tPosition.y, fW, 0.0f);
         SetPixelOffset(0.0f, 0.0f, 0.0f, GetRect().width);
         tPlayer.SetPosition(GetRect().x, GetRect().y);
         tPlayer.SetDimensions(GetRect().width, GetRect().height);
     }
 }
コード例 #12
0
ファイル: GamePage.cs プロジェクト: riktothepast/LD30
 public GamePage()
 {
     HeadsUpDisplay = new FContainer();
     Debug.Log("In game page");
     FSprite bg = new FSprite("Futile_White");
     bg.color = Color.black;
     bg.width = Futile.screen.width;
     bg.height = Futile.screen.height;
     AddChild(bg);
     bg.SetPosition(new Vector2(Futile.screen.width / 2, Futile.screen.height/2));
 }
コード例 #13
0
    public void SetSpriteByTile(FSprite target, Tile tile, WorldCamera camera, bool optimizeColor = false)
    {
        Vector3 spritePosition = tile.coordination + Vector3.one * 0.5f;

        target.SetPosition(camera.GetScreenPosition(spritePosition));
        target.sortZ = camera.GetSortZ(spritePosition);

        if (optimizeColor)
        {
            target.color = new Color(tile.coordination.x, tile.coordination.y, tile.coordination.z);
        }
    }
コード例 #14
0
            public void Move()
            {
                // Update RT and camera
                int rtW = Mathf.RoundToInt(_rtBounds.width);
                int rtH = Mathf.RoundToInt(_rtBounds.height);

                if (_rt == null)
                {
                    _rt              = new RenderTexture(rtW, rtH, 16);
                    _rt.filterMode   = FilterMode.Point;
                    _rt.generateMips = false;

                    if (displaySprite != null)
                    {
                        Futile.atlasManager.UnloadAtlas("InputDisplay_" + cam.cameraNumber);
                        displaySprite?.RemoveFromContainer();
                    }

                    FAtlasElement element = Futile.atlasManager.LoadAtlasFromTexture("InputDisplay_" + cam.cameraNumber, _rt).elements[0];
                    displaySprite = new FSprite(element)
                    {
                        anchorX = 0f, anchorY = 0f, alpha = alpha
                    };
                    _rtCam.targetTexture = _rt;
                }

                if (_rt.width != rtW || _rt.height != rtH)
                {
                    _rt.width  = rtW;
                    _rt.height = rtH;
                }

                // Update display sprite
                displaySprite.SetPosition(origin + _rtBounds.min - Vector2.one * 0.5f);

                // Update components
                Vector2 drawOrigin = DrawOrigin;

                _lerpBarBack.x = drawOrigin.x;
                _lerpBarBack.y = drawOrigin.y - 8f;
                _lerpBar.x     = drawOrigin.x;
                _lerpBar.y     = drawOrigin.y - 8f;
                foreach (InputButton button in buttons)
                {
                    button.Move(drawOrigin);
                }
                _analogBack.SetPosition(drawOrigin + _analogRelPos);
                _analogFront.x = drawOrigin.x + _analogRelPos.x + 1f;
                _analogFront.y = drawOrigin.y + _analogRelPos.y + 1f;

                _rtCam.transform.position = (Vector3)(drawOrigin + _rtBounds.center) + Vector3.forward * -10f;
                _rtCam.orthographicSize   = _rtBounds.height / 2f;
            }
コード例 #15
0
ファイル: InGamePage.cs プロジェクト: jrendel/LD27
    override public void Start()
    {
        // once play navigates away from home screen, don't play the intro when they return
        Main.instance.playIntro = false;

        Main.instance.crewSaved = 0;

        FSprite background = new FSprite("mainGameViewport");

        background.SetAnchor(0.0f, 0.0f);
        AddChild(background);

        _levelManager = new LevelManager();

        AddChild(_levelManager);

        this.shouldSortByZ = true;

        meltdownBar = new FSprite("meltdown");
        meltdownBar.SetPosition(Futile.screen.halfWidth, 672);
        AddChild(meltdownBar);

        _closeButton = new FButton("button");
        _closeButton.AddLabel("Emulogic", "Quit", Color.black);
        _closeButton.label.scale    = 0.25f;
        _closeButton.sortZ          = 1;
        _closeButton.SignalRelease += HandleCloseButtonRelease;

        _closeButton.x = Futile.screen.width - 125.0f;
        _closeButton.y = Futile.screen.height - 75.0f;

        AddChild(_closeButton);

        Clock clock = new Clock();

        clock.SetPosition(75.0f, Futile.screen.height - 75.0f);
        AddChild(clock);

        crewSavedLabel = new FLabel("Emulogic", "Crew Members Saved: 0");
        crewSavedLabel.SetPosition(Futile.screen.halfWidth, Futile.screen.height - 45.0f);
        crewSavedLabel.scale = 0.25f;
        AddChild(crewSavedLabel);

        selectedInventory           = new FSprite("inventorySelected");
        selectedInventory.isVisible = false;
        AddChild(selectedInventory);

        //spawnInventory();

        spawnCrew(2);

        _lastCycle = Main.GameTime;
    }
コード例 #16
0
    public NewPlayerBox()
    {
        base.Init(Player.NullPlayer);

        contentContainer.AddChild(bodySprite = new FSprite("Icons/NewPlayer_Body"));
        contentSprites.Add(bodySprite);
        bodySprite.color = Color.black;

        contentContainer.AddChild(plusSprite = new FSprite("Icons/NewPlayer_Plus"));
        contentSprites.Add(plusSprite);
        plusSprite.color = Color.black;
        plusSprite.SetPosition(0.0f, 7.0f);
    }
コード例 #17
0
    void UpdateSpin()
    {
        float baseX = -1;
        float baseY = -1;

        float radius1  = 15.0f;
        float radius3  = 17.0f;
        float spinRads = _spin * RXMath.PI + RXMath.HALF_PI;

        sprite1.SetPosition(baseX + Mathf.Cos(spinRads) * radius1, baseY + Mathf.Sin(spinRads) * radius1);
        sprite2.SetPosition(baseX, baseY);
        sprite3.SetPosition(baseX - Mathf.Cos(spinRads) * radius3, baseY - Mathf.Sin(spinRads) * radius3 + (1.0f - _spin));
    }
コード例 #18
0
    public NewPlayerBox()
    {
        base.Init(Player.NullPlayer);

        contentContainer.AddChild(bodySprite = new FSprite("Icons/NewPlayer_Body"));
        contentSprites.Add(bodySprite);
        bodySprite.color = Color.black;

        contentContainer.AddChild(plusSprite = new FSprite("Icons/NewPlayer_Plus"));
        contentSprites.Add(plusSprite);
        plusSprite.color = Color.black;
        plusSprite.SetPosition(0.0f,7.0f);
    }
コード例 #19
0
        public void SetConstructionGuide(WorldCamera worldCamera, Player player, Vector3Int tilePosition, bool inRange, float progress)
        {
            Vector3 worldPosition = tilePosition + Vector3.one * 0.5f;

            _previewSprite.SetPosition(worldCamera.GetScreenPosition(worldPosition));
            _previewSprite.sortZ = worldCamera.GetSortZ(worldPosition) + 0.1f;

            // _previewSprite.color = Color.Lerp(inRange ? Color.cyan : Color.red, Color.black, progress);
            // _previewSprite.alpha = Mathf.Sin(menu.time * Mathf.PI) * 0.25f + 0.5f;

            _previewSprite.alpha   = progress > 0f ? 1f : 0f;
            _previewSprite.element = _destroyElements[Mathf.FloorToInt(Mathf.Clamp01(progress) * 7f)];
        }
コード例 #20
0
ファイル: Chopper.cs プロジェクト: philipcass/chopper
    void HandleUpdate()
    {
        //float vaxis = Input.GetAxis("Vertical");
        //float haxis = Input.GetAxis("Horizontal");

        if (Input.GetKey(KeyCode.UpArrow))
        {
            _upDown++;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            _upDown--;
        }
        else
        {
            _upDown *= .9f;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            _leftRight++;
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            _leftRight--;
        }
        else
        {
            _leftRight *= .9f;
        }

        _upDown    = Mathf.Clamp(_upDown, -50, 500);
        _leftRight = Mathf.Clamp(_leftRight, -50, 500);

        gameObject.GetComponent <Rigidbody>().AddForce(Vector3.left * _leftRight);
        gameObject.GetComponent <Rigidbody>().AddForce(Vector3.up * _upDown);


        if (Input.GetKey(KeyCode.Space))
        {
            this.rigidbody.AddExplosionForce(this.PersonCount * 25, this.transform.position, 1);
        }
        else
        {
            this.rigidbody.velocity = new Vector3(Mathf.Clamp(rigidbody.velocity.x, -1, 1),
                                                  Mathf.Clamp(rigidbody.velocity.y, -1, 1),
                                                  0);
        }

        sprite.SetPosition(GetPos());
    }
コード例 #21
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);
    }
コード例 #22
0
        public void Update(IEnumerable <FTouch> touches, InputDevice device, float updateTime)
        {
            foreach (var touch in touches)
            {
                UpdateWithTouch(touch);
            }

            device.GetControl(xAxis).UpdateWithValue(value.x, updateTime);
            device.GetControl(yAxis).UpdateWithValue(value.y, updateTime);

            alpha = Mathf.MoveTowards(alpha, touchId == -1 ? 0.5f : 1.0f, 1.0f / 15.0f);

            headSprite.SetPosition(delta);
        }
コード例 #23
0
ファイル: OpImage.cs プロジェクト: metnias/PolishedMachine
 internal override void OnChange()
 {
     if (!_init)
     {
         return;
     }
     base.OnChange();
     sprite.alpha = _alpha;
     if (!isTexture)
     {
         sprite.color = _color;
     }
     sprite.SetPosition(Vector2.zero);
 }
コード例 #24
0
    public void Init(Vector2 startPos, InGamePage container)
    {
        gameObject.transform.position = new Vector3(startPos.x * FPhysics.POINTS_TO_METERS, startPos.y * FPhysics.POINTS_TO_METERS, 0);

        sprite = new FSprite(Futile.atlasManager.GetElementWithName("man"));
        sprite.SetPosition(startPos);

        container.persons.AddChild(holder = new FContainer());
        holder.AddChild(sprite);

        InitPhysics();

        holder.ListenForUpdate(HandleUpdate);
    }
コード例 #25
0
ファイル: EnemyClock.cs プロジェクト: maggardJosh/TimeWar
    public EnemyClock()
        : base()
    {
        this.x = 0;

        timeLabel.SetPosition(this.GetPosition());
        clockBackground.SetPosition(GetPosition());
        timeLabel.isVisible = false;

        playerSprite = new FSprite("player_0");
        playerSprite.SetPosition(this.GetPosition());

        label.x    = this.x;
        label.text = "Enemies Left";
    }
コード例 #26
0
    public void Init(Vector2 startPos, FContainer container)
    {
        gameObject.transform.position = new Vector3(startPos.x * FPhysics.POINTS_TO_METERS, startPos.y * FPhysics.POINTS_TO_METERS, 0);

        sprite        = new FSprite(Futile.whiteElement);
        sprite.width  = 100;
        sprite.height = 1000;
        sprite.SetPosition(startPos);

        container.AddChild(holder = new FContainer());
        holder.AddChild(sprite);

        InitPhysics();

        holder.ListenForUpdate(HandleUpdate);
    }
コード例 #27
0
ファイル: ScoreBox.cs プロジェクト: MattRix/ScorekeeperX
    void UpdateShouldRemove()
    {
        if (_shouldRemove)
        {
            AddChild(_skullSprite);
            _skullSprite.SetPosition(_scoreLabel.GetPosition());
            _scoreLabel.RemoveFromContainer();

            FSoundManager.PlaySound("UI/ResetToZero");
        }
        else
        {
            AddChild(_scoreLabel);
            _skullSprite.RemoveFromContainer();
        }
    }
コード例 #28
0
 public Clock()
     : base("clock", true, 0, 1.0f)
 {
     label           = new FLabel("Large", "Time Left");
     timeLabel       = new FLabel("Small", "10");
     timeLabel.color = Color.black;
     x = Futile.screen.halfWidth - width * tickScale / 2 - clockMargin;
     y = Futile.screen.halfHeight - height * tickScale / 2 - clockMargin;
     timeLabel.SetPosition(this.GetPosition());
     this.scale      = normalScale;
     clockBackground = new FSprite("clock");
     clockBackground.SetPosition(GetPosition());
     label.x           = x;
     label.y           = y + height / 3 * tickScale / 2;
     labelShadow       = new FLabel("Large", "Time Left");
     labelShadow.color = new Color(0, 0, 0, .5f);
 }
コード例 #29
0
ファイル: MainScreen.cs プロジェクト: StaphiX/Tactics
    public override void Init()
    {
        SetStage(new FStage("MAIN"));
        SetPixelOffset(0, 0, Futile.screen.width, Futile.screen.height);
        FSprite tIcon = new FSprite("Brazil");

        AddSprite(tIcon);
        tIcon.width  = 128.0f * Futile.displayScale;
        tIcon.height = 128.0f * Futile.displayScale;
        tIcon.SetPosition(64.0f * Futile.displayScale, 64.0f * Futile.displayScale);
        FSprite tIcon2 = new FSprite("England");

        AddSprite(tIcon2);
        tIcon2.width  = 128.0f * Futile.displayScale;
        tIcon2.height = 128.0f * Futile.displayScale;
        tIcon2.SetPosition(-64.0f * Futile.displayScale, -64.0f * Futile.displayScale);
    }
コード例 #30
0
ファイル: LogoEditorScreen.cs プロジェクト: StaphiX/Tactics
    public void AddLogoListToScreen()
    {
        List <LogoPart> tParts = LogoPart.GetPartList(LogoPart.ePartFilter);

        int iCount = Mathf.Min(tParts.Count, iMaxLogos + iPage * iMaxLogos);

        for (int iPart = iPage * iMaxLogos; iPart < iCount; ++iPart)
        {
            Rect    tPartRect = GetLayerPartRect(iPart - iPage * iMaxLogos);
            FSprite tSprite   = new FSprite(tParts[iPart].sImageName);
            tScreen.AddSprite(tSprite);
            tSprite.width  = tPartRect.width;
            tSprite.height = tPartRect.height;
            tSprite.SetPosition(tPartRect.x, tPartRect.y);
            tSprite.color = iCurrentSelection == iPart ? Color.cyan : Color.white;
        }
    }
コード例 #31
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;
        }
    }
コード例 #32
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);
        }
コード例 #33
0
ファイル: UI.cs プロジェクト: maggardJosh/SpiritGuard
    public void AddHealth(int health, Vector2 pos)
    {
        for (int i = this.health; i < health; i++)
        {
            FSprite heart = new FSprite("heart");

            heart.SetPosition(pos);
            Vector2 targetPos = hearts.GetPosition();
            switch (i)
            {
                case 0: targetPos.x -= 10; break;
                case 1: break;
                case 2: targetPos.x += 10; break;
            }

            this.AddChild(heart);
            Go.to(heart, .7f, new TweenConfig().floatProp("x", targetPos.x).floatProp("y", targetPos.y).setEaseType(EaseType.QuadOut).onComplete(() => { setHealthSprite(this.health); heart.RemoveFromContainer(); }));
        }
        this.health = health;
    }
コード例 #34
0
    // Use this for initialization
    public override void Start()
    {
        Background        = new FSprite("Futile_White");
        Background.width  = Futile.screen.width;
        Background.height = Futile.screen.height;

        Background.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(Background);

        TextureA       = new FSprite("Futile_White");
        TextureA.color = Color.yellow;
        TextureA.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(TextureA);

        TextureB       = new FSprite("Futile_White");
        TextureB.color = Color.red;
        TextureB.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(TextureB);

        ListenForUpdate(Update);
    }
コード例 #35
0
ファイル: GamePage.cs プロジェクト: riktothepast/FutileTest
    // Use this for initialization
    public override void Start()
    {
        Background = new FSprite("Futile_White");
        Background.width = Futile.screen.width;
        Background.height = Futile.screen.height;

        Background.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(Background);

        TextureA = new FSprite("Futile_White");
        TextureA.color = Color.yellow;
        TextureA.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(TextureA);

        TextureB = new FSprite("Futile_White");
        TextureB.color = Color.red;
        TextureB.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
        AddChild(TextureB);

        ListenForUpdate(Update);
    }
コード例 #36
0
ファイル: SceneEditor.cs プロジェクト: SlimeCubed/SlugBase
            public void Update(ref Vector2 handlePos, ref Vector2?mousePos, bool dark)
            {
                if (hidden)
                {
                    dragging = false;
                    return;
                }
                handle.alpha     = dark ? 0.4f : 1f;
                name.alpha       = dark ? 0.2f : 1f;
                nameShadow.alpha = dark ? 0.1f : 0.75f;
                if (mousePos.HasValue && Input.GetMouseButton(0))
                {
                    if (dragging)
                    {
                        handlePos = mousePos.Value;
                        mousePos  = null;
                    }
                    else
                    {
                        if (PointOverHandle(mousePos.Value, handlePos) && Input.GetMouseButtonDown(0))
                        {
                            dragging = true;
                            mousePos = null;
                        }
                    }
                }
                else
                {
                    dragging = false;
                }

                Vector2 drawPos = new Vector2(Mathf.Floor(handlePos.x) + 0.1f, Mathf.Floor(handlePos.y) + 0.1f);

                handle.SetPosition(drawPos);
                drawPos.x += 12f;
                name.SetPosition(drawPos);
                drawPos.x += 1f;
                drawPos.y -= 1f;
                nameShadow.SetPosition(drawPos);
            }
コード例 #37
0
ファイル: LogoEditorScreen.cs プロジェクト: StaphiX/Tactics
    public void AddLogoLayerToScreen(int iLayer)
    {
        Rect      tImageRect = GetLayerRect(iLayer, false);
        Rect      tMaskRect  = GetLayerRect(iLayer, true);
        LogoLayer tLayer     = tLogoImage.tLayers[iLayer];
        string    sImageName = tLayer.GetImage();
        string    sMaskName  = tLayer.GetMask();
        Color     tImageCol  = iLayer == iCurrentLayer && !bSelectMask ? Color.cyan : Color.white;
        Color     tMaskCol   = iLayer == iCurrentLayer && bSelectMask ? Color.cyan : Color.white;

        if (sImageName.Length < 1)
        {
            sImageName = "LOGOcircle";
            if (bSelectMask || iCurrentLayer != iLayer)
            {
                tImageCol = Color.black;
            }
        }
        if (sMaskName.Length < 1)
        {
            sMaskName = "LOGOcircle";
            if (!bSelectMask || iCurrentLayer != iLayer)
            {
                tMaskCol = Color.black;
            }
        }
        FSprite tImageSprite = new FSprite(sImageName);
        FSprite tMaskSprite  = new FSprite(sMaskName);

        tScreen.AddSprite(tImageSprite);
        tScreen.AddSprite(tMaskSprite);
        tImageSprite.width  = tImageRect.width;
        tImageSprite.height = tImageRect.height;
        tImageSprite.SetPosition(tImageRect.x, tImageRect.y);
        tImageSprite.color = tImageCol;
        tMaskSprite.width  = tMaskRect.width;
        tMaskSprite.height = tMaskRect.width;
        tMaskSprite.SetPosition(tMaskRect.x, tMaskRect.y);
        tMaskSprite.color = tMaskCol;
    }
コード例 #38
0
ファイル: UI.cs プロジェクト: maggardJosh/OGREAT
    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);
    }
コード例 #39
0
ファイル: Testbed.cs プロジェクト: JustinHoldstock/FAnimation
    // Use this for initialization
    void Start()
    {
        // Set up Futile.
        FutileParams fParams = new FutileParams(true, true, false, false);
        fParams.AddResolutionLevel(1024.0f, 1.0f, 1.0f, "");
        Futile.instance.Init(fParams);

        // Load assets.
        FAnimationManager.Instance.LoadAtlas(MY_ATLAS_PATH);

        FContainer container = new FContainer();

        FSprite sprite = new FSprite(FSPRITE_ID);
        sprite.SetPosition(-100,0);

        //setup the animation sprite
        aSprite = new FAnimSprite(FANIM_ID);
        aSprite.SetPosition(100, 0);

        Futile.stage.AddChild(container);

        container.AddChild(sprite);
        container.AddChild(aSprite);
    }
コード例 #40
0
ファイル: Draw.cs プロジェクト: tanis2000/Futile
        public static void HollowRect(float x, float y, float width, float height, Color color)
        {
            rect.x = (int)x;
            rect.y = (int)y;
            rect.width = (int)width;
            rect.height = 1;

            FSprite sprite = new FSprite(Pixel);
            SpriteBatch.AddChild(sprite);
            sprite.SetAnchor(0, 0);
            sprite.SetPosition(rect.x, rect.y);
            sprite.width = rect.width;
            sprite.height = rect.height;
            sprite.color = color;
            //SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);

            rect.y += (int)height - 1;

            sprite = new FSprite(Pixel);
            SpriteBatch.AddChild(sprite);
            sprite.SetAnchor(0, 0);
            sprite.SetPosition(rect.x, rect.y);
            sprite.width = rect.width;
            sprite.height = rect.height;
            sprite.color = color;
            //SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);

            rect.y -= (int)height - 1;
            rect.width = 1;
            rect.height = (int)height;

            sprite = new FSprite(Pixel);
            SpriteBatch.AddChild(sprite);
            sprite.SetAnchor(0, 0);
            sprite.SetPosition(rect.x, rect.y);
            sprite.width = rect.width;
            sprite.height = rect.height;
            sprite.color = color;
            //SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);

            rect.x += (int)width - 1;

            sprite = new FSprite(Pixel);
            SpriteBatch.AddChild(sprite);
            sprite.SetAnchor(0, 0);
            sprite.SetPosition(rect.x, rect.y);
            sprite.width = rect.width;
            sprite.height = rect.height;
            sprite.color = color;
            //SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);
        }
コード例 #41
0
ファイル: Draw.cs プロジェクト: tanis2000/Futile
 public static void Rect(Rect rect, Color color)
 {
     Draw.rect = rect;
     FSprite sprite = new FSprite(Pixel);
     SpriteBatch.AddChild(sprite);
     sprite.SetAnchor(0, 0);
     sprite.SetPosition(rect.x, rect.y);
     sprite.width = rect.width;
     sprite.height = rect.height;
     sprite.color = color;
     //SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);
 }
コード例 #42
0
ファイル: UI.cs プロジェクト: maggardJosh/SpiritGuard
 public void TakeDamage(int health)
 {
     for (int i = this.health; i > health; i--)
     {
         FSprite heart = new FSprite("heart");
         heart.SetPosition(hearts.GetPosition());
         switch (i)
         {
             case 1: heart.x -= 10; break;
             case 2: break;
             case 3: heart.x += 10; break;
         }
         this.AddChild(heart);
         Go.to(heart, .7f, new TweenConfig().floatProp("y", -15, true).setEaseType(EaseType.BackOut).onComplete(() => { heart.RemoveFromContainer(); }));
     }
     this.health = health;
     setHealthSprite(health);
 }
コード例 #43
0
ファイル: SoulPickup.cs プロジェクト: maggardJosh/SpiritGuard
 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));
                         }));
                     }));
                 }));
             }));
         });
     }
 }
コード例 #44
0
ファイル: TileMap.cs プロジェクト: riktothepast/LD30
    public void LoadTileMap(String mapText)
    {
        Array.Clear(Tiles, 0, Tiles.Length);
        levelData = new LevelData();
        levelData.LevelDataXML(mapText);
        Tiles = new int[(int)levelData.getTileMapSize().x, (int)levelData.getTileMapSize().y];
        Debug.Log(levelData.getTileMapSize().x + " " + levelData.getTileMapSize().y);
        // fill TileMap with zeroes.
        loadTiles();
        TileMap.CurrentMap = this;
        // size of the map
        lengthI = Tiles.GetLength(1);
        lengthJ = Tiles.GetLength(0);

        portals = getLevelData().getPortalSpawns();

        for (int x = portals.Count - 1; x >= 0; x--)
        {
            portals[x].SetPosition(portals[x].getPosition());
            AddChild(portals[x]);
        }

        hazards = getLevelData().getHazardSpawns();

        for (int x = hazards.Count - 1; x >= 0; x--)
        {
            FSprite haz = new FSprite("hazard");
            haz.SetPosition(hazards[x].getPosition());
            AddChild(haz);
        }

        for (int x = getLevelData().getEnemySpawns().Count - 1; x >= 0; x--)
        {

        }
        items = new List<Item>();
        if (getLevelData().getItemSpawns() !=null)
        for (int x = getLevelData().getItemSpawns().Count - 1; x >= 0; x--)
        {
            Item it = new Item(getLevelData().getItemSpawns()[x]);
            it.SetPosition(it.getPosition());
            items.Add(it);
            AddChild(it);
        }
        enemies = new List<Entity>();
        if (getLevelData().getEnemySpawns() != null)
            for (int x = getLevelData().getEnemySpawns().Count - 1; x >= 0; x--)
            {
                EnemyPortal it = new EnemyPortal(getLevelData().getEnemySpawns()[x]);
                it.SetPosition(it.Position);
                enemies.Add(it);
                AddChild(it);
            }
    }
コード例 #45
0
ファイル: TileMap.cs プロジェクト: riktothepast/LD30
    void loadTiles()
    {
        foreach (PlatformData platform in levelData.getPlatformData())
        {
            FSprite plat = new FSprite(platform.image);
            plat.height = 16;
            plat.width = 16;
            tileSize = plat.width;
            Tiles[(int)platform.x, (int)platform.y] = 1;
            // make them overlap a little to avoid those ungly lines in the rendering.
            plat.SetPosition(new Vector2((platform.x * plat.width), (-platform.y * plat.height)));

            AddChild(plat);
        }
        playerBullets = new List<Bullet>();
        hazards = new List<Hazard>();
        particleContainer = new FContainer();
        AddChild(particleContainer);
        enemyContainer = new FContainer();
        AddChild(enemyContainer);
        particles = new FParticleSystem(50);
        particleContainer.AddChild(particles);
        projectileContainer = new FContainer();
        AddChild(projectileContainer);
        entityContainer = new FContainer();
        AddChild(entityContainer);
        frontContainer = new FContainer();
        AddChild(frontContainer);
        this.alpha = 0;

        TweenConfig tw = new TweenConfig();
        tw.floatProp("alpha", 1);
        Go.to(this, 10f, tw);

        stats = new FLabel("font", "Jump Packs: 0; reload times: 0");
        CurrentPage.GetHUD().AddChild(stats);
        stats.scale = 0.9f;
        stats.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.height * 0.9f));
    }
コード例 #46
0
ファイル: TitlePage.cs プロジェクト: jrendel/LD27
    public override void Start()
    {
        Main.instance.crewSaved = 0;
        Main.instance.gameFinished = false;

        FSprite background = new FSprite("viewport");
        background.SetAnchor(0.0f, 0.0f);
        AddChild(background);

        _introLabel = new FLabel("Emulogic", "");
        _introLabel.color = Color.black; //Color.green; // new Color(0.173f, 0.722f, 0.976f, 1.0f);
        _introLabel.scale = 0.2f;
        _introLabel.SetAnchor(0.0f, 1.0f);
        _introLabel.SetPosition(60, Futile.screen.height - 14);

        AddChild(_introLabel);

        _titleLabel = new FLabel("Emulogic", "");
        _titleLabel.color = Color.black;
        _titleLabel.scale = 1.0f;
        _titleLabel.SetAnchor(0.0f, 1.0f);
        _titleLabel.SetPosition(200, 550);

        AddChild(_titleLabel);

        _finalLabel = new FLabel("Emulogic", "");
        _finalLabel.color = Color.black; //Color.green;
        _finalLabel.scale = 0.2f;
        _finalLabel.SetAnchor(0.0f, 1.0f);
        _finalLabel.SetPosition(575, 400);

        AddChild(_finalLabel);

        if (!Main.instance.playIntro){
            _introLabel.text = _introText;
            _titleLabel.text = _titleText;
            _finalLabel.text = _finalText;
        }

        _startButton = new FButton("buttonWide");
        _startButton.AddLabel("Emulogic","Play!",Color.black);  //new Color(0.45f,0.25f,0.0f,1.0f)
        _startButton.label.scale = 0.25f;
        _startButton.SetPosition(Futile.screen.width - 225, 155);
        AddChild(_startButton);

        _startButton.SignalRelease += HandleStartButtonRelease;

        _creditsButton = new FButton("buttonWide");
        _creditsButton.AddLabel("Emulogic","About",Color.black);  //new Color(0.45f,0.25f,0.0f,1.0f)
        _creditsButton.label.scale = 0.25f;
        _creditsButton.SetPosition(Futile.screen.width - 225, 75);
        AddChild(_creditsButton);

        _creditsButton.SignalRelease += HandleCreditsButtonRelease;

        _lastTextUpdate = Main.GameTime;

        FSprite escapePod = new FSprite("escapePod");
        FSprite doors = new FSprite("doorsIcon");
        FSprite crew = new FSprite("floatingCharacter");
        FSprite clock = new FSprite("moveTileIcon");
        //FSprite clock = new FSprite("clock4");

        escapePod.scale = 0.5f;
        doors.scale = 0.5f;

        escapePod.SetPosition(140, 305);
        doors.SetPosition(140, 230);
        crew.SetPosition(140, 155);
        clock.SetPosition(140, 80);

        AddChild(escapePod);
        AddChild(doors);
        AddChild(crew);
        AddChild(clock);

        FLabel escapePodLabel = new FLabel("Emulogic", "Get the crew to \nthe escape pods!");
        escapePodLabel.color = Color.black; //Color.green;
        escapePodLabel.scale = 0.15f;
        escapePodLabel.SetAnchor(0.0f, 0.5f);
        escapePodLabel.SetPosition(200, 305);
        AddChild(escapePodLabel);

        FLabel doorsLabel = new FLabel("Emulogic", "Touch doors to \nopen and close them.");
        doorsLabel.color = Color.black; //Color.green;
        doorsLabel.scale = 0.15f;
        doorsLabel.SetAnchor(0.0f, 0.5f);
        doorsLabel.SetPosition(200, 230);
        AddChild(doorsLabel);

        FLabel crewLabel = new FLabel("Emulogic", "The Crew. They will walk \nthrough open doors, \nbut don't expect much else.");
        crewLabel.color = Color.black; //Color.green;
        crewLabel.scale = 0.15f;
        crewLabel.SetAnchor(0.0f, 0.5f);
        crewLabel.SetPosition(200, 155);
        AddChild(crewLabel);

        FLabel clockLabel = new FLabel("Emulogic", "Place movement tiles \nto redirect the crew.");
        //FLabel clockLabel = new FLabel("Emulogic", "10 Seconds.");
        clockLabel.color = Color.black; //Color.green;
        clockLabel.scale = 0.15f;
        clockLabel.SetAnchor(0.0f, 0.5f);
        clockLabel.SetPosition(200, 80);
        AddChild(clockLabel);
    }
コード例 #47
0
ファイル: Level.cs プロジェクト: jfleschler/Futile_TMX_Demo
    public void BuildTiles()
    {
        int spritenumber, xflip, yflip, rotation = 0;
        float rot = 0;
        int[][][] grid;

        for (int d = 1; d < 10; d++) {
            switch (d)
            {
                case 1: grid = Grid_1; break;
                case 2: grid = Grid_2; break;
                case 3: grid = Grid_3; break;
                case 4: grid = Grid_4; break;
                case 5: grid = Grid_5; break;
                case 6: grid = Grid_6; break;
                case 7: grid = Grid_7; break;
                case 8: grid = Grid_8; break;
                case 9: grid = Grid_9; break;
                default: grid = new int[0][][]; break;
            }

            for (int i = 0; i < grid.Length; i++) {
                for (int j = 0; j < grid[0].Length; j++) {

                    spritenumber = grid[i][j][0];

                    if (spritenumber != 0) {
                        FSprite tile = new FSprite(GetElementWithName("tile_" + spritenumber));

                        rot = 0;
                        xflip = grid[i][j][1];
                        yflip = grid[i][j][2];
                        rotation = grid[i][j][3];

                        if (xflip == 1 && rotation == 1) {
                            rot = 90f;
                        } else if (yflip == 1 && rotation == 1) {
                            rot = -90f;
                        } else {
                            if (xflip == 1) tile.scaleX = -1f;
                            if (yflip == 1) tile.scaleY = -1f;
                        }

                        tile.rotation = rot;

                       	tile.SetPosition(new Vector2(j * tileWidth + tileWidth/2, -i * tileHeight - tileHeight/2));
                        tile.sortZ = d * 10;

                        tiles.Add(tile);
                        AddChild(tile);
                    }
                }
            }
        }
    }
コード例 #48
0
ファイル: InGamePage.cs プロジェクト: jrendel/LD27
    public override void Start()
    {
        // once play navigates away from home screen, don't play the intro when they return
        Main.instance.playIntro = false;

        Main.instance.crewSaved = 0;

        FSprite background = new FSprite("mainGameViewport");
        background.SetAnchor(0.0f, 0.0f);
        AddChild(background);

        _levelManager = new LevelManager();

        AddChild(_levelManager);

        this.shouldSortByZ = true;

        meltdownBar = new FSprite("meltdown");
        meltdownBar.SetPosition(Futile.screen.halfWidth, 672);
        AddChild(meltdownBar);

        _closeButton = new FButton("button");
        _closeButton.AddLabel("Emulogic","Quit",Color.black);
        _closeButton.label.scale = 0.25f;
        _closeButton.sortZ = 1;
        _closeButton.SignalRelease += HandleCloseButtonRelease;

        _closeButton.x = Futile.screen.width - 125.0f;
        _closeButton.y = Futile.screen.height -75.0f;

        AddChild(_closeButton);

        Clock clock = new Clock();
        clock.SetPosition( 75.0f, Futile.screen.height - 75.0f);
        AddChild(clock);

        crewSavedLabel = new FLabel("Emulogic", "Crew Members Saved: 0");
        crewSavedLabel.SetPosition( Futile.screen.halfWidth, Futile.screen.height - 45.0f);
        crewSavedLabel.scale = 0.25f;
        AddChild(crewSavedLabel);

        selectedInventory = new FSprite("inventorySelected");
        selectedInventory.isVisible = false;
        AddChild(selectedInventory);

        //spawnInventory();

        spawnCrew(2);

        _lastCycle = Main.GameTime;
    }
コード例 #49
0
ファイル: World.cs プロジェクト: hassanLastborn/Tether
    void InitBeasts()
    {
        List<Player> players = GameManager.instance.activePlayers;
        float radiansPerPlayer = RXMath.DOUBLE_PI / (float)players.Count;
        float startRadius = 150.0f;

        for (int p = 0; p < players.Count; p++)
        {
            Vector2 startPos = new Vector2();
            startPos.x = Mathf.Cos(p * radiansPerPlayer) * startRadius;
            startPos.y = Mathf.Sin(p * radiansPerPlayer) * startRadius;
            Beast beast = Beast.Create(this);
            beast.Init(players[p], startPos);
            beasts.Add(beast);

            FSprite beastShadow = new FSprite("Evil-Eye_Shadow_1");
            beastShadowHolder.AddChild(beastShadow);

            beastShadow.SetPosition(beast.GetPos());
            beastShadow.rotation = beast.holder.rotation;
            beastShadow.alpha = 0.7f;
            beastShadow.scale = 1.0f;

            beast.shadow = beastShadow;
        }

        for(int t = 0; t<teams.Count; t++)
        {
            Team team = teams[t];

            team.SignalTeamChange += HandleSignalTeamChange;
        }

        int linkCount = 11;

        if (beasts.Count == 2)
        {
            linkCount = 11;
            chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
        }
        else if (beasts.Count == 3)
        {
            chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
            chains.Add(new Chain(this, 11, beasts[1], beasts[2]));
            chains.Add(new Chain(this, 11, beasts[2], beasts[0]));
        }
        else if (beasts.Count == 4)
        {
            linkCount = 13;
            //chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
            //chains.Add(new Chain(this, 11, beasts[1], beasts[2]));
            //chains.Add(new Chain(this, 11, beasts[2], beasts[3]));
            //chains.Add(new Chain(this, 11, beasts[3], beasts[0]));

            chains.Add(new Chain(this, linkCount, beasts[0], beasts[2]));
            chains.Add(new Chain(this, linkCount, beasts[1], beasts[3]));

            Chain ca = chains[0];
            Chain cb = chains[1];

            int middleLink = (linkCount-1)/2;
            ChainLink linkA = ca.links[middleLink];
            ChainLink linkB = cb.links[middleLink];

            linkA.gameObject.transform.position = new Vector2(0,0).ToVector3InMeters();
            linkB.gameObject.transform.position = new Vector2(0,0).ToVector3InMeters();

            HingeJoint hinge = linkA.gameObject.AddComponent<HingeJoint>();

            hinge.connectedBody = linkB.rigidbody;

            JointSpring jspring = hinge.spring;

            jspring.spring = 0.1f;

            hinge.spring = jspring;

            hinge.axis = new Vector3(0.0f, 0.0f, 1.0f);
        }

        for(int b = 0; b<beasts.Count; b++)
        {
            beasts[b].holder.MoveToFront();
        }
    }
コード例 #50
0
ファイル: InGamePage.cs プロジェクト: jrendel/LD27
    protected void HandleUpdate()
    {
        float dt = Time.deltaTime;

        if (Main.GameTime - _lastCycle > 10){
            // spawn some new crew every 10 seconds
            spawnInventory();
            //if(_crewSpawned < 20){
            if (_crewMembers.Count < 10){ // keep spawning crew so long as there arae not more than 10 currently out
                spawnCrew(3);
            }
            _levelManager.scrambleDoors();

            int totalMeltdownSegments = 20;
            //  use 20 for shorter game play (about 3.3 minutes)
            //  use 32 for shorter game play (about 5.3 minutes)
            if (_meltdownSegmentCount < totalMeltdownSegments){

                float segmentWidth = 640 / totalMeltdownSegments;

                // draw another segment on the meltdown timer
                FSprite meltdownSegment = new FSprite("meltdownSegment");
                meltdownSegment.width = segmentWidth;
                // calculate position
                float x = Futile.screen.halfWidth - (meltdownBar.width / 2) + 4 + (segmentWidth / 2); // 4 is to get the spacing right
                x += _meltdownSegmentCount * segmentWidth;
                meltdownSegment.SetPosition(x, 672);
                AddChild(meltdownSegment);
                _meltdownSegmentCount++;
            } else {
                GameOver();
            }

            _lastCycle = Main.GameTime;
        }

        // handle input
        bool invKeyPressed = false;

        if (Input.GetKeyDown(KeyCode.Alpha1)){
            invKeyPressed = true;
            _invNumSelected = 0;
        } else if (Input.GetKeyDown(KeyCode.Alpha2)){
            invKeyPressed = true;
            _invNumSelected = 1;
        } else if (Input.GetKeyDown(KeyCode.Alpha3)){
            invKeyPressed = true;
            _invNumSelected = 2;
        } else if (Input.GetKeyDown(KeyCode.Alpha4)){
            invKeyPressed = true;
            _invNumSelected = 3;
        } else if (Input.GetKeyDown (KeyCode.Escape)){
            invKeyPressed = false;
            _invNumSelected = -1;
            selectedInventory.isVisible = false;
        }

        if (invKeyPressed){
                // so the user selected a valid inventory slot,
                // now make sure there is something in that slot
                if (_inventory[_invNumSelected] != null){
                    selectedInventory.SetPosition(positionForInventory(_invNumSelected));
                    selectedInventory.isVisible = true;
                } else {
                    // they clicked on an empty inventory
                    _invNumSelected = -1;
                }
        }

        // update crew member's movement direction
        //loop backwards so if we remove a crew member from the list, it won't cause problems
        for (int i = _crewMembers.Count-1; i >= 0; i--)
        {
            Crew crewMember = _crewMembers[i];
            VectorDirection currentDirection = crewMember.direction;
            Vector2 newCrewPosition = crewMember.calculateNewPosition(dt);
            if (!_levelManager.crewMemberIsPassingThruDoor(crewMember)){ // passing through a door takes precidence
                if (_levelManager.willObeyFloorTile(crewMember, newCrewPosition)){

                } else if (_levelManager.willDirectCrewToDoor(crewMember)) { // check if crew member is next to an open door, if so they will be directed to it
                    if (crewMember.direction != currentDirection){
                        // direction was updated, don't adjust position
                        newCrewPosition = crewMember.GetPosition();
                    }
                } else if (!_levelManager.checkCrewHeadingOk(crewMember, newCrewPosition)){
                    // crew member heading into a wall, so heading was adjusted, don't update position
                    newCrewPosition = crewMember.GetPosition();
                }
            }
            // update crew member's position (having taken into account all previous checks)
            crewMember.SetPosition(newCrewPosition);

            // check if crew member is in the escape pod room
            int escapePodXMax = (64 * 7) - 32;
            int escapePodYMax = (64 * 3) - 32;
            if (newCrewPosition.x <= escapePodXMax && newCrewPosition.y <= escapePodYMax){
                // you saved this crew member!
                FSoundManager.PlaySound("crewSaved1", 0.5f);
                Main.instance.crewSaved++;
                crewSavedLabel.text = "Crew Members Saved: " + Main.instance.crewSaved;

                _crewMembers.Remove(crewMember);
                crewMember.shouldDestroy = true;
            }
        }
    }
コード例 #51
0
ファイル: UI.cs プロジェクト: maggardJosh/OGREAT
    private void GetHealth(int newHealth)
    {
        for (int i = health; i <= newHealth - 1; i++)
        {
            int index = i;
            Tween lastTween = null;
            FSprite[] pixels = new FSprite[(int)(hearts[i].width * hearts[i].height)];
            for (int x = 0; x < hearts[i].width; x++)
                for (int y = 0; y < hearts[i].height; y++)
                {
                    FSprite pixel = new FSprite(Futile.whiteElement);
                    pixel.width = 1;
                    pixel.height = 1;
                    pixel.SetPosition(hearts[i].GetPosition() + new Vector2(RXRandom.Float() * 50 - 25, RXRandom.Float() * 30 - 80));
                    //pixel.activate(hearts[i].GetPosition() + new Vector2(x - hearts[i].width / 2f, -y + hearts[i].height / 2f - 1f),
                    //    new Vector2(RXRandom.Float() * 20 - 10f, RXRandom.Float() * 15 + 6),
                    //    new Vector2(RXRandom.Float() * 4 - 2, RXRandom.Float() * -10 - 30), 0);
                    //Go.to(pixel, 1.0f, new TweenConfig().floatProp("x", RXRandom.Float() * 10 - 5f, true).floatProp("y", RXRandom.Float() * -10 - 10, true).setEaseType(EaseType.CircIn));
                    Color c = GetHeartColor(x, y);
                    if (c == Color.clear)
                        continue;
                    pixel.color = c;
                    pixel.alpha = 0;
                    Vector2 resultPos = hearts[i].GetPosition() + new Vector2(x - hearts[i].width / 2f, -y + hearts[i].height / 2f - 1f);
                    lastTween = Go.to(pixel, .5f, new TweenConfig().floatProp("x", resultPos.x).floatProp("y", resultPos.y).floatProp("alpha", 1).setDelay(x * .05f).setEaseType(EaseType.QuadOut).onComplete(() => {/* pixel.RemoveFromContainer(); */}));
                    this.AddChild(pixel);
                    pixels[(int)(x + y * hearts[i].width)] = pixel;

                }

            lastTween.setOnCompleteHandler((AbstractTween t) =>
            {
                hearts[index].SetElementByName("heart");
                foreach (FSprite s in pixels)
                    if (s != null)
                        s.RemoveFromContainer();
            });
        }
    }