示例#1
0
文件: City.cs 项目: TuLLVC/perontor
    /*	public void UpdateBuilding()
    {
        UI ui = GameObject.Find("Planet").GetComponent<UI>();
        if (currentyBuilding != ChitTypes.NULL)
        {
            turnsLeftToBuild--;

            if (turnsLeftToBuild < 1)
            {
                // we have build a new unit!
                Debug.Log("creating new unit! - " + currentyBuilding.ToString());
                Chit c = gameObject.GetComponent<Chit>();
                Tile t = c.tile;
                ui.displayNewUnitBuiltWindow = true;
                // create new unit
                t.AttachChit(c.faction, currentyBuilding, "new unit");
                // pre-select new unit for ordering
                t.chitOnTile.canMoveThisTurn = true;
                currentyBuilding = ChitTypes.NULL;
            }
        }
    }

    public void StartBuilding(ChitTypes unitToBuild)
    {
        currentyBuilding = unitToBuild;
        switch (unitToBuild)
        {
        case ChitTypes.SWORD:
            turnsLeftToBuild = turnsToBuildUnit;
            break;
        case ChitTypes.COMMANDER:
            turnsLeftToBuild = turnsToBuildCommander;
            break;
        }
    }*/
    /*	void OnMouseDown()
    {
        if (this.GetComponentInChildren<Chit>().faction == transform.parent.GetComponent<Planet>().playerFaction)
        {
            transform.parent.GetComponent<Planet>().ui.DisplayCityInfo(this);
        }
    }
    */
    public void Enlist()
    {
        if ( pop > enlistCost )
        {
            enlistCount++;
            pop -= enlistCost	;
            chitToEnlisht = ChitTypes.SWORD;
            transform.GetComponent<Chit>().order = new Order();
            transform.GetComponent<Chit>().order.EnlistOrder(this, chitToEnlisht);
        }
    }
示例#2
0
/*	public void UpdateBuilding()
 *      {
 *              UI ui = GameObject.Find("Planet").GetComponent<UI>();
 *              if (currentyBuilding != ChitTypes.NULL)
 *              {
 *                      turnsLeftToBuild--;
 *
 *                      if (turnsLeftToBuild < 1)
 *                      {
 *                              // we have build a new unit!
 *                              Debug.Log("creating new unit! - " + currentyBuilding.ToString());
 *                              Chit c = gameObject.GetComponent<Chit>();
 *                              Tile t = c.tile;
 *                              ui.displayNewUnitBuiltWindow = true;
 *                              // create new unit
 *                              t.AttachChit(c.faction, currentyBuilding, "new unit");
 *                              // pre-select new unit for ordering
 *                              t.chitOnTile.canMoveThisTurn = true;
 *                              currentyBuilding = ChitTypes.NULL;
 *                      }
 *              }
 *      }
 *
 *      public void StartBuilding(ChitTypes unitToBuild)
 *      {
 *              currentyBuilding = unitToBuild;
 *              switch (unitToBuild)
 *              {
 *              case ChitTypes.SWORD:
 *                      turnsLeftToBuild = turnsToBuildUnit;
 *                      break;
 *              case ChitTypes.COMMANDER:
 *                      turnsLeftToBuild = turnsToBuildCommander;
 *                      break;
 *              }
 *      }*/

/*	void OnMouseDown()
 *      {
 *              if (this.GetComponentInChildren<Chit>().faction == transform.parent.GetComponent<Planet>().playerFaction)
 *              {
 *                      transform.parent.GetComponent<Planet>().ui.DisplayCityInfo(this);
 *              }
 *      }
 */
    public void Enlist()
    {
        if (pop > enlistCost)
        {
            enlistCount++;
            pop          -= enlistCost;
            chitToEnlisht = ChitTypes.SWORD;
            transform.GetComponent <Chit>().order = new Order();
            transform.GetComponent <Chit>().order.EnlistOrder(this, chitToEnlisht);
        }
    }
示例#3
0
文件: Tile.cs 项目: Zekodon/perontor
    public void AttachChit(Faction f, ChitTypes cType, string cname)
    {
        planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <Planet>();
        //account for rotation
        Vector3    m = planet.transform.localToWorldMatrix * midpoint;
        GameObject gameObject;

        switch (cType)
        {
        case ChitTypes.COMMANDER:
            gameObject = (GameObject)GameObject.Instantiate(Resources.Load("Commander"), m, Quaternion.LookRotation(midpoint));
            gameObject.GetComponent <Controller>().name    = cname;
            gameObject.GetComponent <Chit>().movementRange = 2;
            break;

        case ChitTypes.CITY:
            gameObject = (GameObject)GameObject.Instantiate(Resources.Load("City"), m, Quaternion.LookRotation(midpoint));
            gameObject.GetComponent <Controller>().name = cname;
            break;

        case ChitTypes.SWORD:
            gameObject = (GameObject)GameObject.Instantiate(Resources.Load("Sword"), m, Quaternion.LookRotation(midpoint));
            gameObject.GetComponent <Chit>().movementRange = 2;
            gameObject.tag = "Chit";
            break;

        case ChitTypes.NECTOWER:
            gameObject = (GameObject)GameObject.Instantiate(Resources.Load("NecTower"), m, Quaternion.LookRotation(midpoint));
            gameObject.GetComponent <Controller>().name = "The Necromancer";
            break;

        default:
            gameObject = new GameObject();
            break;
        }

        gameObject.transform.localScale = new Vector3(chitScalingFactor, chitScalingFactor, chitScalingFactor);
        gameObject.name = cType.ToString();

        chitOnTile                  = gameObject.GetComponent <Chit>();
        chitOnTile.faction          = f;
        chitOnTile.transform.parent = planet.transform;
        chitOnTile.tile             = this;
        chitOnTile.ctype            = cType;
        if (cType != ChitTypes.NECTOWER)
        {
            gameObject.transform.FindChild("BaseChit").renderer.material.color = chitOnTile.faction.fcol;
        }
    }
示例#4
0
文件: Tile.cs 项目: TuLLVC/perontor
    public void AttachChit(Faction f, ChitTypes cType, string cname)
    {
        planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<Planet>();
        //account for rotation
        Vector3 m =  planet.transform.localToWorldMatrix * midpoint;
        GameObject gameObject;
        switch (cType)
        {
            case ChitTypes.COMMANDER:
                gameObject = (GameObject)GameObject.Instantiate(Resources.Load("Commander"), m, Quaternion.LookRotation(midpoint));
                gameObject.GetComponent<Controller>().name = cname;
                gameObject.GetComponent<Chit>().movementRange = 2;
                break;
            case ChitTypes.CITY:
                gameObject = (GameObject)GameObject.Instantiate(Resources.Load("City"), m, Quaternion.LookRotation(midpoint));
                gameObject.GetComponent<Controller>().name = cname;
                break;
            case ChitTypes.SWORD:
                gameObject = (GameObject)GameObject.Instantiate(Resources.Load("Sword"), m, Quaternion.LookRotation(midpoint));
                gameObject.GetComponent<Chit>().movementRange = 2;
                gameObject.tag = "Chit";
                break;
            case ChitTypes.NECTOWER:
                gameObject = (GameObject)GameObject.Instantiate(Resources.Load("NecTower"), m, Quaternion.LookRotation(midpoint));
                gameObject.GetComponent<Controller>().name = "The Necromancer";
                break;
            default:
                gameObject = new GameObject();
                break;
        }

        gameObject.transform.localScale = new Vector3(chitScalingFactor,chitScalingFactor,chitScalingFactor);
        gameObject.name = cType.ToString();

        chitOnTile = gameObject.GetComponent<Chit>();
        chitOnTile.faction = f;
        chitOnTile.transform.parent = planet.transform;
        chitOnTile.tile = this;
        chitOnTile.ctype = cType;
        if (cType!=ChitTypes.NECTOWER)
        {
            gameObject.transform.FindChild("BaseChit").renderer.material.color = chitOnTile.faction.fcol;
        }
    }
示例#5
0
    static public void LoadPlanet2(Planet planet, StreamReader planetFile)
    {
        foreach (GameObject g in (GameObject.FindGameObjectsWithTag("Tile")))
        {
            planet.tiles.Add(g.GetComponent <Tile>());
            g.GetComponent <Tile>().LinkPlanet(planet);
        }

        // load faction info!

        for (int fctr = 0; fctr < planet.numberOfFactions; fctr++)
        {
            Faction faction = new Faction();

            string s = planetFile.ReadLine();
            faction.fname = s;
            s             = planetFile.ReadLine();
            faction.fcol  = ParseColor(s);

            // Read in number of controllers

            s = planetFile.ReadLine();
            s = planetFile.ReadLine();
            int numChars = int.Parse(s);
            // read in Faction step
            s            = planetFile.ReadLine();
            s            = planetFile.ReadLine();
            faction.step = int.Parse(s);

            // read in faction cycle
            s             = planetFile.ReadLine();
            s             = planetFile.ReadLine();
            faction.cycle = int.Parse(s);
            // read in faction char info
            s = planetFile.ReadLine();
            for (int c = 0; c < numChars; c++)
            {
                // get Chit Type
                s = planetFile.ReadLine();
                ChitTypes cType = ChitTypeParse(s);
                // get Controller name

                s = planetFile.ReadLine();
                string charName = s;

                // get current location
                s = planetFile.ReadLine();
                int tileID = int.Parse(s);
                //Debug.Log (faction.fname);
                // spawn controller!
                planet.tiles[tileID].AttachChit(faction, cType, charName);
            }

            planet.factions.Add(faction);
            //faction.UpdateListOfControllers();
        }

        // now add in chits!
        string schit = planetFile.ReadLine();

//		Debug.Log("should say ChitInfo> " + schit);
        schit = planetFile.ReadLine();
        while (schit != null)
        {
            int tID = int.Parse(schit);
            int fID = int.Parse(planetFile.ReadLine());
            // get faction
            Faction faction = planet.factions[fID];

            planet.tiles[tID].AttachChit(faction, ChitTypes.SWORD, "new unit");
            schit = planetFile.ReadLine();
        }
    }