当前位置: 首页>>代码示例>>C#>>正文


C# Village.getGold方法代码示例

本文整理汇总了C#中Village.getGold方法的典型用法代码示例。如果您正苦于以下问题:C# Village.getGold方法的具体用法?C# Village.getGold怎么用?C# Village.getGold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Village的用法示例。


在下文中一共展示了Village.getGold方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: hireCannon

 public void hireCannon(Village v, GameObject cannonPrefab)
 {
     //		Tile tileAt = v.getLocatedAt ();
     int vGold = v.getGold ();
     int vWood = v.getWood ();
     if (vGold >= 35 && vWood>=12) {
         if(v.getMyType() >= VillageType.Fort)
         {
             unitManager.initializeCannon(v,cannonPrefab);
             // initialize the cannon
     //				cannon.networkView.RPC("initUnitNet", RPCMode.AllBuffered, (int)UnitType.CANNON, tileAt.gameObject.networkView.viewID, v.gameObject.networkView.viewID);
     //				v.gameObject.networkView.RPC("addGoldNet", RPCMode.AllBuffered, -35);
     //				v.gameObject.networkView.RPC("addWoodNet", RPCMode.AllBuffered, -12);
     //				v.gameObject.networkView.RPC("addUnitNet", RPCMode.AllBuffered, cannon.networkView.viewID);
         }
         else
         {
             gameGUI.displayError(@"Please upgrade your village to a Fort first. ¯\(°_o)/¯");
         }
     } else {
         gameGUI.displayError(@"Cannons cost 35 gold and 12 wood");
     }
 }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:23,代码来源:VillageManager.cs

示例2: plunderVillage

    public void plunderVillage(Village pluderingVillage, Village plunderedVillage, Tile dest)
    {
        Debug.Log ("in plunder village");
        //determine amount to steal
        int wood = plunderedVillage.getWood ();
        int gold = plunderedVillage.getGold ();

        // remove from enemy village
        plunderedVillage.gameObject.networkView.RPC ("addGoldNet",RPCMode.AllBuffered,-gold);
        plunderedVillage.gameObject.networkView.RPC ("addWoodNet",RPCMode.AllBuffered,-wood);

        // add to yours
        pluderingVillage.gameObject.networkView.RPC ("addGoldNet",RPCMode.AllBuffered,gold);
        pluderingVillage.gameObject.networkView.RPC ("addWoodNet",RPCMode.AllBuffered,wood);

        //Destroy (dest.prefab); // destroy the village, create a meadow
        GameObject meadow = Network.Instantiate(meadowPrefab, new Vector3 (dest.point.x, 0, dest.point.y), meadowPrefab.transform.rotation,0) as GameObject;
        dest.gameObject.networkView.RPC ("switchTilePrefabNet",RPCMode.AllBuffered,meadow.networkView.viewID);
        // respawn enemy hovel happens during the split
    }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:20,代码来源:VillageManager.cs

示例3: splitRegion

    private void splitRegion(Tile splitTile, Village villageToSplit)
    {
        List<List<Tile>> lstRegions = new List<List<Tile>>();
        int oldWood = villageToSplit.getWood ();
        int oldGold = villageToSplit.getGold ();
        Tile oldLocation = villageToSplit.getLocatedAt ();
        Player p = villageToSplit.getPlayer();

        // prep for BFS
        foreach (Tile t in villageToSplit.getControlledRegion()) {
            t.setVisited(false);
        }
        // build connected regions
        foreach (Tile t in splitTile.getNeighbours()) {
            if (t.getVillage()==villageToSplit && !t.getVisited()){
                List<Tile> newRegion = new List<Tile>();
                t.setVisited(true);
                newRegion.Add (t);
                splitBFS (t,villageToSplit,newRegion);
                if (newRegion.Count<3){
                    Neutralize (newRegion);
                } else{
                    lstRegions.Add (newRegion);
                }
            }
        }
        print ("after the bfs");

        if (lstRegions.Count <= 0) {
            Debug.Log ("Inside Regions <= 0");
            oldLocation.gameObject.networkView.RPC ("setLandTypeNet",RPCMode.AllBuffered,(int)LandType.Meadow);
            GameObject meadow = Network.Instantiate (meadowPrefab, new Vector3 (oldLocation.point.x, 0, oldLocation.point.y), meadowPrefab.transform.rotation,0) as GameObject;
            villageToSplit.retireAllUnits();
            Debug.Log ("after retire all units");
            p.networkView.RPC ("removeVillageNet",RPCMode.AllBuffered,villageToSplit.networkView.viewID,p.getColor());
            oldLocation.networkView.RPC ("replaceTilePrefabNet",RPCMode.AllBuffered,meadow.networkView.viewID);
            Debug.Log ("after lstRegions <= 0");
            return; //stop here if no region is big enough
        }

        int splitWood = oldWood/lstRegions.Count;
        int splitGold = oldGold/lstRegions.Count;

        //create new villages
        foreach(List<Tile> region in lstRegions)
        {
            print ("creating new village");
            Vector3 hovelLocation;
            Tile tileLocation;

            if (region.Contains (oldLocation)){
                tileLocation = oldLocation;
                hovelLocation = new Vector3(tileLocation.point.x, 0.1f, tileLocation.point.y);
            } else {
                tileLocation = getTileForRespawn(region);
                hovelLocation = new Vector3(tileLocation.point.x, 0.1f, tileLocation.point.y);
            }

            GameObject newTown = Network.Instantiate(hovelPrefab, hovelLocation, hovelPrefab.transform.rotation, 0) as GameObject;
            Village v = newTown.GetComponent<Village>();
            //tileLocation.replace (newTown);
            tileLocation.networkView.RPC ("switchTilePrefabNet",RPCMode.AllBuffered,newTown.networkView.viewID);
            v.addRegion (region); //adds T<>V and any U<>V

        //			v.setLocation (tileLocation);
            v.gameObject.networkView.RPC ("setLocationNet",RPCMode.AllBuffered,tileLocation.networkView.viewID);
        //			p.addVillage(v);
            p.gameObject.networkView.RPC ("addVillageNet",RPCMode.AllBuffered,v.networkView.viewID,p.getColor ());
        //			v.setControlledBy(p);
            GameManager GM = GameObject.Find ("preserveGM").GetComponent<GameManager>();
            int playerIndex = GM.findPlayerIndex(p);
            v.gameObject.networkView.RPC ("setControlledByNet",RPCMode.AllBuffered,playerIndex);

            if (region.Contains (oldLocation)){
                VillageType vType = villageToSplit.getMyType();
                //v.setMyType(vType);
                v.gameObject.networkView.RPC ("setVillageTypeNet",RPCMode.AllBuffered,(int)vType);
                if (vType == VillageType.Hovel)
                {
        //					newTown.transform.FindChild("Hovel").gameObject.SetActive (true);
        //					newTown.transform.FindChild("Town").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Fort").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Castle").gameObject.SetActive (false);
                    newTown.gameObject.networkView.RPC ("switchPrefabNet",RPCMode.AllBuffered,(int)vType);
                }
                else if (vType == VillageType.Town)
                {
        //					newTown.transform.FindChild("Hovel").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Town").gameObject.SetActive (true);
        //					newTown.transform.FindChild("Fort").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Castle").gameObject.SetActive (false);
                    newTown.gameObject.networkView.RPC ("switchPrefabNet",RPCMode.AllBuffered,(int)vType);

                }
                else if (vType == VillageType.Fort)
                {
        //					newTown.transform.FindChild("Hovel").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Town").gameObject.SetActive (false);
        //					newTown.transform.FindChild("Fort").gameObject.SetActive (true);
        //					newTown.transform.FindChild("Castle").gameObject.SetActive (false);
//.........这里部分代码省略.........
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:101,代码来源:VillageManager.cs

示例4: paymentPhase

 public void paymentPhase(Village v)
 {
     int totalWages = v.getTotalWages ();
     int villageGold = v.getGold ();
     if (villageGold >= totalWages) { //means have enough money to pay units
         villageGold = villageGold - totalWages;
         v.gameObject.networkView.RPC ("setGoldNet",RPCMode.AllBuffered,villageGold);
     }
     else {
         v.retireAllUnits();
     }
 }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:12,代码来源:VillageManager.cs

示例5: hireSoldier

    public void hireSoldier(Village v, GameObject unitPrefab)
    {
        //		Tile tileAt = v.getLocatedAt ();
        int villageGold = v.getGold ();
        if (villageGold >= 30) {
            if(v.getMyType() >= VillageType.Town)
            {
                unitManager.initializeUnit(v,unitPrefab,UnitType.SOLDIER);

        //				//Unit p = Unit.CreateComponent (UnitType.SOLDIER, tileAt, v, unitPrefab);
        //				GameObject newSoldier = Network.Instantiate(unitPrefab, new Vector3(tileAt.point.x, 0.15f, tileAt.point.y), tileAt.transform.rotation, 0) as GameObject;
        //				newSoldier.networkView.RPC("initUnitNet", RPCMode.AllBuffered, (int)UnitType.SOLDIER, tileAt.gameObject.networkView.viewID, v.gameObject.networkView.viewID);
        //
        //				//p.gameObject.transform.FindChild("Peasant").gameObject.SetActive (false);
        //				//p.gameObject.transform.FindChild("Infantry").gameObject.SetActive (false);
        //				//p.gameObject.transform.FindChild("Soldier").gameObject.SetActive (true);
        //				//p.gameObject.transform.FindChild("Knight").gameObject.SetActive (false);
        //
        //				newSoldier.networkView.RPC ("setActiveNet", RPCMode.AllBuffered, "Soldier");
        //				//v.setGold (villageGold - THIRTY);
        //				v.gameObject.networkView.RPC("addGoldNet", RPCMode.AllBuffered, -30);
        //				//v.addUnit (p);
        //				v.gameObject.networkView.RPC("addUnitNet", RPCMode.AllBuffered, newSoldier.networkView.viewID);
            }
            else
            {
                gameGUI.displayError(@"Please upgrade your village to a Town first. ¯\(°_o)/¯");
            }
        } else {
            gameGUI.displayError(@"You can't afford a soldier. ¯\(°_o)/¯");
        }
    }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:32,代码来源:VillageManager.cs

示例6: hirePeasant

 public void hirePeasant(Village v,GameObject unitPrefab)
 {
     //		Tile tileAt = v.getLocatedAt ();
     int villageGold = v.getGold ();
     if (villageGold >= 10)
     {
         unitManager.initializeUnit(v,unitPrefab,UnitType.PEASANT);
     }
     else
     {
         gameGUI.displayError (@"Wow you're broke, can't even afford a peasant? ¯\(°_o)/¯");
     }
 }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:13,代码来源:VillageManager.cs

示例7: hireKnight

    public void hireKnight(Village v, GameObject unitPrefab)
    {
        //		Tile tileAt = v.getLocatedAt ();
        int villageGold = v.getGold ();
        if (villageGold >= 40) {
            if(v.getMyType() == VillageType.Fort)
            {
                unitManager.initializeUnit(v,unitPrefab,UnitType.KNIGHT);

        //				//Unit p = Unit.CreateComponent (UnitType.KNIGHT, tileAt, v, unitPrefab);
        //				GameObject newKnight = Network.Instantiate(unitPrefab, new Vector3(tileAt.point.x, 0.15f, tileAt.point.y), tileAt.transform.rotation, 0) as GameObject;
        //				newKnight.networkView.RPC("initUnitNet", RPCMode.AllBuffered, (int)UnitType.KNIGHT, tileAt.gameObject.networkView.viewID, v.gameObject.networkView.viewID);
        //
        //				//p.gameObject.transform.FindChild("Peasant").gameObject.SetActive (false);
        //				//p.gameObject.transform.FindChild("Infantry").gameObject.SetActive (false);
        //				//p.gameObject.transform.FindChild("Soldier").gameObject.SetActive (false);
        //				//p.gameObject.transform.FindChild("Knight").gameObject.SetActive (true);
        //				newKnight.networkView.RPC ("setActiveNet", RPCMode.AllBuffered, "Knight");
        //
        //				//v.setGold (villageGold - FOURTY);
        //				v.gameObject.networkView.RPC("addGoldNet", RPCMode.AllBuffered, -40);
        //
        //				//v.addUnit (p);
        //				v.gameObject.networkView.RPC("addUnitNet", RPCMode.AllBuffered, newKnight.networkView.viewID);
            }
            else
            {
                gameGUI.displayError (@"Please upgrade your village to a Fort first. ¯\(°_o)/¯");
            }
        } else {
            gameGUI.displayError(@"You don't have enough gold for a knight. ¯\(°_o)/¯");
        }
    }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:33,代码来源:VillageManager.cs

示例8: hireInfantry

    public void hireInfantry(Village v,GameObject unitPrefab)
    {
        //		Tile tileAt = v.getLocatedAt ();
        int villageGold = v.getGold ();
        if (villageGold >= 20) {
        //			//Unit p = Unit.CreateComponent (UnitType.INFANTRY, tileAt, v, unitPrefab);
        //			GameObject newInfantry = Network.Instantiate(unitPrefab, new Vector3(tileAt.point.x, 0.15f, tileAt.point.y), tileAt.transform.rotation, 0) as GameObject;
        //			newInfantry.networkView.RPC("initUnitNet", RPCMode.AllBuffered, (int)UnitType.INFANTRY, tileAt.gameObject.networkView.viewID, v.gameObject.networkView.viewID);
            unitManager.initializeUnit(v,unitPrefab,UnitType.INFANTRY);

            //p.gameObject.transform.FindChild("Peasant").gameObject.SetActive (false);
            //p.gameObject.transform.FindChild("Infantry").gameObject.SetActive (true);
            //p.gameObject.transform.FindChild("Soldier").gameObject.SetActive (false);
            //p.gameObject.transform.FindChild("Knight").gameObject.SetActive (false);
        //			newInfantry.networkView.RPC ("setActiveNet", RPCMode.AllBuffered, "Infantry");
        //
        //			//v.setGold (villageGold - TWENTY);
        //			v.gameObject.networkView.RPC("addGoldNet", RPCMode.AllBuffered, -20);
        //
        //			//v.addUnit (p);
        //			v.gameObject.networkView.RPC("addUnitNet", RPCMode.AllBuffered, newInfantry.networkView.viewID);
        } else {
            gameGUI.displayError (@"You do not have enough gold to train infantry. ¯\(°_o)/¯");
        }
    }
开发者ID:hysoftwareeng,项目名称:MedievalWarfare,代码行数:25,代码来源:VillageManager.cs


注:本文中的Village.getGold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。