コード例 #1
0
ファイル: GameRenderer.cs プロジェクト: WJLiddy/PizzaJam3
    public void showOptions(TileItem tu)
    {
        if (tu is Storage)
        {
            bItem1.SetActive(true);
            bItem2.SetActive(true);

            int[] costof1 = null;
            switch ((tu as Storage).type)
            {
            case Resource.Type.OIL: costof1 = BALANCE_CONSTANTS.REFINERY_WORKER_COST; break;

            case Resource.Type.WOOD: costof1 = BALANCE_CONSTANTS.SAWMILL_WORKER_COST; break;

            case Resource.Type.ORE: costof1 = BALANCE_CONSTANTS.FOUNDRY_WORKER_COST; break;
            }

            int[] costof2 = null;
            switch ((tu as Storage).type)
            {
            case Resource.Type.OIL: costof2 = BALANCE_CONSTANTS.REFINERY_COLLECTOR_COST; break;

            case Resource.Type.WOOD: costof2 = BALANCE_CONSTANTS.SAWMILL_COLLECTOR_COST; break;

            case Resource.Type.ORE: costof2 = BALANCE_CONSTANTS.FOUNDRY_COLLECTOR_COST; break;
            }

            bItem1.GetComponentInChildren <Text>().text = "Build " + resourceName((tu as Storage).type) + " Harvester\n" + gs.priceRenderNoNewline(costof1);
            bItem2.GetComponentInChildren <Text>().text = "Build " + resourceName((tu as Storage).type) + " Collector\n" + gs.priceRenderNoNewline(costof2);
        }
        else if (tu is GuardTower)
        {
            bItem1.SetActive(gs.player.gun1 != null);
            if (gs.player.gun1 != null)
            {
                bItem1.GetComponentInChildren <Text>().text = "Attach " + gs.player.gun1.getName();
            }

            bItem2.SetActive(gs.player.gun2 != null);
            if (gs.player.gun2 != null)
            {
                bItem2.GetComponentInChildren <Text>().text = "Attach " + gs.player.gun2.getName();
            }

            if ((tu as GuardTower).storedGun != null)
            {
                bItem1.SetActive(false);
                bItem2.SetActive(false);
            }
        }

        else if (tu is GroundGun)
        {
            bItem1.SetActive(true);
            bItem2.SetActive(true);
            GroundGun gg = (tu as GroundGun);
            if (gs.player.gun1 == null)
            {
                bItem1.GetComponentInChildren <Text>().text = "Take " + gg.gun.getName();
            }
            else
            {
                bItem1.GetComponentInChildren <Text>().text = "Swap for " + gg.gun.getName();
            }

            if (gs.player.gun2 == null)
            {
                bItem2.GetComponentInChildren <Text>().text = "Take " + gg.gun.getName();
            }
            else
            {
                bItem2.GetComponentInChildren <Text>().text = "Swap for " + gg.gun.getName();
            }
        }


        else
        {
            hideOptions();
        }
    }
コード例 #2
0
ファイル: GameRenderer.cs プロジェクト: WJLiddy/PizzaJam3
    public void runOption(int opt)
    {
        Player   p = gs.player;
        IntVec2  v = pr.p.getLookAt();
        TileItem t = gs.getItem(v);

        if (t is Storage)
        {
            int[] costof = null;
            if (opt == 1)
            {
                switch ((t as Storage).type)
                {
                case Resource.Type.OIL: costof = BALANCE_CONSTANTS.REFINERY_WORKER_COST; break;

                case Resource.Type.WOOD: costof = BALANCE_CONSTANTS.SAWMILL_WORKER_COST; break;

                case Resource.Type.ORE: costof = BALANCE_CONSTANTS.FOUNDRY_WORKER_COST; break;
                }
                if (gs.tryBuy(costof))
                {
                    gs.placeItemNear(new HarvesterRobot((t as Storage).type), v);
                }
            }

            if (opt == 2)
            {
                switch ((t as Storage).type)
                {
                case Resource.Type.OIL: costof = BALANCE_CONSTANTS.REFINERY_COLLECTOR_COST; break;

                case Resource.Type.WOOD: costof = BALANCE_CONSTANTS.SAWMILL_COLLECTOR_COST; break;

                case Resource.Type.ORE: costof = BALANCE_CONSTANTS.FOUNDRY_COLLECTOR_COST; break;
                }
                if (gs.tryBuy(costof))
                {
                    gs.placeItemNear(new CollectorRobot((t as Storage).type), v);
                }
            }
        }

        if (t is GuardTower)
        {
            GuardTower gt = t as GuardTower;
            if (opt == 1)
            {
                if (gt.storedGun == null && p.gun1 != null)
                {
                    gt.storedGun = p.gun1;
                    p.gun1       = null;
                }
            }

            if (opt == 2)
            {
                if (gt.storedGun == null && p.gun2 != null)
                {
                    gt.storedGun = p.gun2;
                    p.gun2       = null;
                }
            }
        }

        if (t is GroundGun)
        {
            GroundGun gg = (t as GroundGun);
            if (opt == 1 && gs.player.gun1 == null)
            {
                gs.player.gun1      = gg.gun;
                gs.tiles_[v.x, v.y] = null;
            }
            if (opt == 1 && gs.player.gun1 != null)
            {
                Gun g = gg.gun;
                gg.gun         = gs.player.gun1;
                gs.player.gun1 = g;
            }

            if (opt == 2 && gs.player.gun2 == null)
            {
                gs.player.gun2      = gg.gun;
                gs.tiles_[v.x, v.y] = null;
            }
            if (opt == 2 && gs.player.gun2 != null)
            {
                Gun g = gg.gun;
                gg.gun         = gs.player.gun2;
                gs.player.gun2 = g;
            }
        }
    }
コード例 #3
0
    void renderGroundGun(GroundGun g, int x, int y)
    {
        Sprite s = sd[g.gun.getName()];

        tiles[x, y].GetComponent <SpriteRenderer>().sprite = s;
    }