예제 #1
0
    private void GetAssets()
    {
        gameAssetsList = new List<GameAsset>();

        string[] allDirs = Directory.GetDirectories(Environment.CurrentDirectory);
        foreach (string s in allDirs)
        {
            string[] info = Directory.GetFiles(s, "info.txt");
            if (info.Any())
            {
                Debug.Log("got info");
                GameAsset asset = new GameAsset();

                // get Game
                string text = File.ReadAllText(info[0]);
                Game game = JsonConvert.DeserializeObject<Game>(text);
                asset.GameData = game;

                // get Texture
                string[] textures = Directory.GetFiles(s, "card.png");
                if (textures.Any())
                {
                    WWW www = new WWW("file://" + textures[0]);
                    asset.Card = www.texture;
                    Debug.Log("got texture");
                }

                // get executable path
                asset.ExecutablePath = s + "/" + asset.GameData.Executable;
                Debug.Log("got executable " + asset.ExecutablePath);

                gameAssetsList.Add(asset);
            }
        }
    }
예제 #2
0
 public static void Dispose()
 {
     if (null != _instance)
     {
     }
     _instance = null;
 }
예제 #3
0
    void LoadAllGames()
    {
        GameAsset[] ga = Resources.LoadAll <GameAsset>("Games");
        gameAssets = new GameAsset[ga.Length];
        GameAsset[] nonGames = new GameAsset[3];

        int assetIndex = 0, nonGameIndex = 0;

        for (int i = 0; i < ga.Length; i++)
        {
            GameAsset game = ga[i];
            if (game.isGame)
            {
                gameAssets[game.order] = game;
                assetIndex++;
            }
            else
            {
                nonGames[nonGameIndex] = game;
                nonGameIndex++;
            }
        }

        for (int i = 0; i < nonGames.Length; i++)
        {
            if (nonGames[i] != null)
            {
                gameAssets[assetIndex] = nonGames[i];
                assetIndex++;
            }
        }

        scrollSection.Create(menuItemPrefab, gameAssets, Method);
    }
예제 #4
0
 public void Fill <T>(string labelName, GameAsset asset) where T : AssetSelector
 {
     mAsset              = asset;
     mSelectorType       = typeof(T);
     assetNameLabel.Text = labelName;
     assetRefField.Text  = asset.LinkedProjectAsset.Name != null ? asset.LinkedProjectAsset.Name : asset.LinkedProjectAsset.Guid.ToString();
 }
예제 #5
0
    static int LoadTexture(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                string arg0 = ToLua.CheckString(L, 1);
                System.Action <UnityEngine.Texture> arg1 = (System.Action <UnityEngine.Texture>)ToLua.CheckDelegate <System.Action <UnityEngine.Texture> >(L, 2);
                GameAsset.LoadTexture(arg0, arg1);
                return(0);
            }
            else if (count == 3)
            {
                string arg0 = ToLua.CheckString(L, 1);
                System.Action <UnityEngine.Texture> arg1 = (System.Action <UnityEngine.Texture>)ToLua.CheckDelegate <System.Action <UnityEngine.Texture> >(L, 2);
                bool arg2 = LuaDLL.luaL_checkboolean(L, 3);
                GameAsset.LoadTexture(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: GameAsset.LoadTexture"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #6
0
    public AssetTuple getRandomSufficientAsset(int number)
    {
        AssetTuple randomAsset = new AssetTuple();

        if (Random.Range(0.0f, 1.0f) <= 0.5f)
        {
            int randomResourceIndex;
            do
            {
                randomResourceIndex = Random.Range(0, Enum.GetNames(typeof(ResourceType)).Length - 1);
                randomAsset         = GameAsset.getAssetOfIndex(randomResourceIndex, number);
            } while(!hasAvailableAssets(randomAsset));
        }
        else
        {
            int randomCommodityIndex;
            do
            {
                randomCommodityIndex = Random.Range(0, Enum.GetNames(typeof(CommodityType)).Length - 1) + 5;
                randomAsset          = GameAsset.getAssetOfIndex(randomCommodityIndex, number);
            } while(!hasAvailableAssets(randomAsset));
        }

        return(randomAsset);
    }
        public override bool ShouldDisplay(GameAsset asset)
        {
            if (asset is GameItemAsset gia)
            {
                if (gia.canPlayerEquip)
                {
                    switch (slot)
                    {
                    case Equip_Type.Primary:
                    {
                        if (gia.slot == Equip_Type.Primary || gia.slot == Equip_Type.Secondary || gia.slot == Equip_Type.Any)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    case Equip_Type.Secondary:
                    {
                        if (gia.slot == Equip_Type.Secondary || gia.slot == Equip_Type.Any)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    case Equip_Type.Tertiary:
                    {
                        if (gia.slot == Equip_Type.None || gia.slot == Equip_Type.Tertiary || gia.slot == Equip_Type.Any)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    default:
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
        public void UpdateDisplayName(GameAsset asset)
        {
            TreeViewItem item = FindItem(asset.id, rootItem);

            if (item != null)
            {
                item.displayName = asset.DisplayName;
            }
        }
예제 #9
0
 public override void Initialize(GameAsset parentAsset)
 {
     base.Initialize(parentAsset);
     CustomName = new CustomNameAttribute(AssetID);
     Happiness  = new HappinessAttribute(AssetID);
     Energy     = new EnergyAttribute(AssetID);
     Hunger     = new HungerAttribute(AssetID);
     Thirst     = new ThirstAttribute(AssetID);
 }
예제 #10
0
    void Start()
    {
        gameAsset = GameAsset.Instance;
        levelGird = new LevelGrid(9, 19);
        levelGird.GameSetup(gameAsset.snakePrefab);
        StartCoroutine(GameCondition());
#if UNITY_ANDROID || UNITY_IOS
        AssignMobileController();
#endif
    }
예제 #11
0
    ResourceTuple getResourceForTile(GameTile tile, int numCollected)
    {
        ResourceTuple resourceCollected = new ResourceTuple();
        ResourceType  typeOfResource    = GameAsset.getResourceOfHex(tile.tileType);

        if (typeOfResource != ResourceType.Null)
        {
            resourceCollected.resourceTuple [typeOfResource] = numCollected;
        }

        return(resourceCollected);
    }
예제 #12
0
    CommodityTuple getCommodityForTile(GameTile tile, int numCollected)
    {
        CommodityTuple commodityCollected = new CommodityTuple();
        CommodityType  typeOfCommodity    = GameAsset.getCommodityOfHex(tile.tileType);

        if (typeOfCommodity != CommodityType.Null)
        {
            commodityCollected.commodityTuple [typeOfCommodity] = numCollected;
        }

        return(commodityCollected);
    }
예제 #13
0
 private void OnSelectionChanged(GameAsset selection)
 {
     selectedAsset = selection;
     if (selection != null)
     {
         reflectedSelection = new ReflectedObject(selectedAsset);
     }
     else
     {
         reflectedSelection = null;
     }
 }
예제 #14
0
 static int PrintCacheMap(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         GameAsset.PrintCacheMap();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #15
0
        IEnumerator Start()
        {
            if (!GameConst.DebugMode)
            {
                yield return(res.ReadyLuaFiles());
            }
            yield return(StartGame());

            GameAsset.LoadSceneSingle("Test", () =>
            {
                Debug.Log("GameAsset.LoadSceneSingle");
            });
        }
예제 #16
0
 static int ReleaseSingle(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Object arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
         GameAsset.ReleaseSingle(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #17
0
 static int ReleaseAll(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         GameAsset.ReleaseAll(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #18
0
 static int AddCacheUIModel(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         GameAsset.AddCacheUIModel(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #19
0
 static int GetAssetBytes(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         byte[] o    = GameAsset.GetAssetBytes(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #20
0
            public AITreeItem(GameAsset asset)
            {
                this.id          = asset.id;
                this.displayName = asset.name;

                this.asset = asset;
                if (asset is BehaviorSet)
                {
                    this.itemType = ItemType.BehaviorSet;
                }
                else
                {
                    throw new ArgumentException("Asset must be non null and a known type");
                }
            }
예제 #21
0
 static int LoadObjects(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string[] arg0 = ToLua.CheckStringArray(L, 1);
         System.Action <int, UnityEngine.Object> arg1 = (System.Action <int, UnityEngine.Object>)ToLua.CheckDelegate <System.Action <int, UnityEngine.Object> >(L, 2);
         GameAsset.LoadObjects(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #22
0
 static int Release(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string arg0 = ToLua.CheckString(L, 1);
         int    arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
         GameAsset.Release(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #23
0
 static int LoadSceneAdditive(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string        arg0 = ToLua.CheckString(L, 1);
         System.Action arg1 = (System.Action)ToLua.CheckDelegate <System.Action>(L, 2);
         GameAsset.LoadSceneAdditive(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #24
0
 static int WaitLoadSceneSingle(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string arg0 = ToLua.CheckString(L, 1);
         System.Action <float>          arg1 = (System.Action <float>)ToLua.CheckDelegate <System.Action <float> >(L, 2);
         System.Collections.IEnumerator o    = GameAsset.WaitLoadSceneSingle(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #25
0
 void LoadGame()
 {
     if (!string.IsNullOrEmpty(GlobalSettings.NewGameName))
     {
         print(GlobalSettings.NewGameName);
         GameAsset ga = Resources.Load <GameAsset>("Games/" + GlobalSettings.NewGameName);
         if (ga.gameObject != null)
         {
             GameObject go = Instantiate(ga.gameObject);
             if (ga.isGame)
             {
                 go.GetComponentInChildren <Game>().gameAsset = ga;
                 go.GetComponentInChildren <Game>().debugGame = false;
             }
         }
     }
 }
예제 #26
0
    void SpawnFood()
    {
        if (BoardManager.Instance.gameStop)
        {
            return;
        }

        GameAsset asset = GameAsset.Instance;

        do
        {
            foodPosition = new Vector2Int(Random.Range(-width, width), Random.Range(-height, height));
        }while (Vector2.Distance(foodPosition, snakeHead.GetSnakePosition()) < 1);

        Vector2 applePosition = foodPosition;

        currentFood = Object.Instantiate(asset.applePrefab, applePosition, Quaternion.identity);
    }
예제 #27
0
    /*public void tradeGoldDone(){
     *      Debug.Log ("trade ini");
     *      Debug.Log ("gold cnt: " + CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].getGoldCoinsCnt ());
     *      AssetTuple assetsToReceive = GameAsset.getAssetOfIndex (tradePanel.getGoldChoiceInt(), 1);
     *      if (CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].getGoldCoinsCnt() >= 2) {
     *              EventTransferManager.instance.GoldTrade (PhotonNetwork.player.ID - 1);
     *              EventTransferManager.instance.OnTradeWithBank(CatanManager.instance.currentPlayerTurn, true, assetsToReceive);
     *              tradePanel.hideErrorText ();
     *              tradePanel.gameObject.SetActive (false);
     *              EventTransferManager.instance.OnOperationFailure ();
     *      }
     * }*/
    public void tradeDone()
    {
        int tradeRatio = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].getMinimumTradeValue(tradePanel.getTradeChoiceInt());

        if (tradePanel.getTradeChoiceInt() >= 5 && CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].unlockedTradingHouse())
        {
            tradeRatio = 2;
        }
        if (CatanManager.instance.players [PhotonNetwork.player.ID - 1].playedMerchantFleet && tradePanel.getTradeChoiceInt() == CatanManager.instance.players [PhotonNetwork.player.ID - 1].merchantFleetSelection)
        {
            tradeRatio = 2;
        }
        if (CatanManager.instance.merchantController == PhotonNetwork.player.ID - 1)
        {
            ResourceType typeOfResource = GameAsset.getResourceOfHex(GameObject.FindGameObjectWithTag("Merchant").GetComponent <Merchant> ().occupyingTile.tileType);
            if ((int)typeOfResource == tradePanel.getTradeChoiceInt())
            {
                tradeRatio = 2;
            }
        }
        AssetTuple assetsToSpend   = GameAsset.getAssetOfIndex(tradePanel.getTradeChoiceInt(), tradeRatio);
        AssetTuple assetsToReceive = GameAsset.getAssetOfIndex(tradePanel.getReceiveChoiceInt(), 1);

        if (CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].hasAvailableAssets(assetsToSpend))
        {
            //CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].spendAssets (assetsToSpend);
            //CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].receiveAssets (assetsToReceive);
            EventTransferManager.instance.OnTradeWithBank(CatanManager.instance.currentPlayerTurn, false, assetsToSpend);
            EventTransferManager.instance.OnTradeWithBank(CatanManager.instance.currentPlayerTurn, true, assetsToReceive);

            //print (players [currentPlayerTurn].playerName + " gives 4 " + tradePanel.getTradeChoiceInt ().ToString () + " to the bank and receives 1 " + assetsToReceive.ToString());
            tradePanel.hideErrorText();
            tradePanel.gameObject.SetActive(false);

            EventTransferManager.instance.OnOperationFailure();
        }
        else
        {
            print("Insufficient resources! Please try again...");
            tradePanel.showNotEnoughError(tradePanel.getTradeChoiceInt());
        }
    }
예제 #28
0
    /*void tradeDone() {
     *      bool successful = false;
     *      //int choice = tradePanel.getTradeChoiceInt ();
     *      ResourceTuple resourcesToGiveToBank = new ResourceTuple ();
     *      CommodityTuple commoditiesToGiveToBank = new CommodityTuple ();
     *
     *      Tuple<ResourceType, CommodityType> spending = GameAsset.getProductionAssetsOfIndex (tradePanel.getTradeChoiceInt ());
     *      Tuple<ResourceType, CommodityType> receiving = GameAsset.getProductionAssetsOfIndex (tradePanel.getReceiveChoiceInt ());
     *
     *      if (tradePanel.getTradeChoiceInt() < 5) {
     *              resourcesToGiveToBank.addResourceWithType (spending.first, 4);
     *      } else {
     *              commoditiesToGiveToBank.addCommodityWithType(spending.second, 4);
     *      }
     *
     *      if (players [currentPlayerTurn].hasAvailableResources (resourcesToGiveToBank) && players [currentPlayerTurn].hasAvailableCommodities (commoditiesToGiveToBank)) {
     *              players [currentPlayerTurn].spendResources (resourcesToGiveToBank);
     *              players [currentPlayerTurn].spendCommodities (commoditiesToGiveToBank);
     *
     *              ResourceTuple resourceToReceive = new ResourceTuple ();
     *              CommodityTuple commodityToReceive = new CommodityTuple ();
     *
     *              if (tradePanel.getReceiveChoiceInt () < 5) {
     *                      resourceToReceive.addResourceWithType (receiving.first, 1);
     *              } else {
     *                      commodityToReceive.addCommodityWithType (receiving.second, 1);
     *              }
     *
     *              players [currentPlayerTurn].receiveResources (resourceToReceive);
     *              players [currentPlayerTurn].receiveCommodities (commodityToReceive);
     *
     *              //print (players [currentPlayerTurn].playerName + " gives 4 " + tradePanel.getTradeChoice ().ToString () + " to the bank and receives 1 " + tradePanel.getReceiveChoice ());
     *              print (players [currentPlayerTurn].playerName + " gives 4 " + spending.ToString () + " to the bank and receives 1 " + receiving.ToString());
     *
     *              currentActiveButton = -1;
     *              tradePanel.hideErrorText ();
     *              tradePanel.gameObject.SetActive (false);
     *              waitingForPlayer = false;
     *      } else {
     *              print ("Insufficient resources! Please try again...");
     *              tradePanel.showNotEnoughError (tradePanel.getTradeChoiceInt ());
     *      }
     * }*/

    void tradeDone()
    {
        AssetTuple assetsToSpend   = GameAsset.getAssetOfIndex(tradePanel.getTradeChoiceInt(), 4);
        AssetTuple assetsToReceive = GameAsset.getAssetOfIndex(tradePanel.getReceiveChoiceInt(), 1);

        if (players [currentPlayerTurn].hasAvailableAssets(assetsToSpend))
        {
            players [currentPlayerTurn].spendAssets(assetsToSpend);
            players [currentPlayerTurn].receiveAssets(assetsToReceive);
            //print (players [currentPlayerTurn].playerName + " gives 4 " + tradePanel.getTradeChoiceInt ().ToString () + " to the bank and receives 1 " + assetsToReceive.ToString());

            currentActiveButton = -1;
            tradePanel.hideErrorText();
            tradePanel.gameObject.SetActive(false);
            waitingForPlayer = false;
        }
        else
        {
            print("Insufficient resources! Please try again...");
            tradePanel.showNotEnoughError(tradePanel.getTradeChoiceInt());
        }
    }
예제 #29
0
    void resourceCollectionEvent(int diceOutcome)
    {
        for (int i = 0; i < players.Count; i++)
        {
            if (setupPhase && i != currentPlayerTurn)
            {
                continue;
            }
            else
            {
                List <GameTile> eligibleTilesForPlayer = getTilesWithDiceValue(players [i], diceOutcome, false);

                for (int j = 0; j < eligibleTilesForPlayer.Count; j++)
                {
                    if (eligibleTilesForPlayer [j].canProduce())
                    {
                        print(players [i].playerName + " gets " + "1 " + GameAsset.getResourceOfHex(eligibleTilesForPlayer [j].tileType));
                        giveResourcesToPlayer(players [i], getResourceForTile(eligibleTilesForPlayer [j], 1));
                    }
                }
            }
        }
    }
예제 #30
0
 // Update is called once per frame
 void Update()
 {
     if (CatanManager.instance.players [PhotonNetwork.player.ID - 1].playedMerchantFleet && giveselection == CatanManager.instance.players [PhotonNetwork.player.ID - 1].merchantFleetSelection)
     {
         Text giveText = GetComponentsInChildren <Text> () [0];
         giveText.text = "Give 2: ";
     }
     if (CatanManager.instance.merchantController == PhotonNetwork.player.ID - 1)
     {
         ResourceType typeOfResource = GameAsset.getResourceOfHex(GameObject.FindGameObjectWithTag("Merchant").GetComponent <Merchant> ().occupyingTile.tileType);
         if ((int)typeOfResource == giveselection)
         {
             Text giveText = GetComponentsInChildren <Text> () [0];
             giveText.text = "Give 2: ";
         }
         else
         {
             int tradeRatio = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].getMinimumTradeValue(giveselection);
             if (getTradeChoiceInt() >= 5 && CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].unlockedTradingHouse())
             {
                 tradeRatio = 2;
             }
             Text giveText = GetComponentsInChildren <Text> () [0];
             giveText.text = "Give " + tradeRatio + ":";
         }
     }
     else
     {
         int tradeRatio = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].getMinimumTradeValue(giveselection);
         if (getTradeChoiceInt() >= 5 && CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].unlockedTradingHouse())
         {
             tradeRatio = 2;
         }
         Text giveText = GetComponentsInChildren <Text> () [0];
         giveText.text = "Give " + tradeRatio + ":";
     }
 }
예제 #31
0
        private static GameAsset SerializeGameAsset(string name, GameAsset gameAsset, Type type)
        {
            if (ImGui.BeginCombo(name, gameAsset != null ? gameAsset.Name : "[None]"))
            {
                foreach (GameAsset asset in LeaderEngine.AssetManager.Assets.Values)
                {
                    if (!type.IsAssignableFrom(asset.GetType()))
                    {
                        continue;
                    }

                    ImGui.PushID(asset.GetHashCode());
                    if (ImGui.Selectable(asset.Name, gameAsset == asset))
                    {
                        gameAsset = asset;
                    }
                    ImGui.PopID();
                }

                ImGui.EndCombo();
            }

            return(gameAsset);
        }
예제 #32
0
 public void addFocus(GameAsset newAsset)
 {
     _selectedAssets.Add (newAsset);
 }
예제 #33
0
 public void removeFocus(GameAsset oldAsset)
 {
     _selectedAssets.Remove (oldAsset);
 }