Ejemplo n.º 1
0
    void Start()
    {
        GlobalMessage = GlobalMessage1;
        if (Spawnpoint == null || Cityprefab1 == null || Playerprefab == null)
        {
            Debug.Log("Error starting Game manager", this); return;
        }

        RaycastHit Hit;

        Physics.Raycast(Spawnpoint.position, Vector3.down, out Hit);
        Spawnpoint.position = Hit.point;
        Instantiate(Playerprefab).transform.position = Spawnpoint.transform.position;
        Spawnscript = GetComponent <Spawn>();

        Cityprefab = Cityprefab1;
        Cities.Add(Instantiate(Cityprefab).GetComponent <Stadt>());
        Cities[0].transform.position = Spawnpoint.transform.position;
        Spawnscript.AddCity(Cities[0].gameObject);
        StartCoroutine(IncreaseMoney());
    }
Ejemplo n.º 2
0
    public static bool BuildCity(Vector3 Pos)
    {
        RaycastHit[] Hits     = Physics.RaycastAll(Pos + Vector3.up * 100, Vector3.down);
        bool         CanBuild = false;

        foreach (RaycastHit hit in Hits)
        {
            if (hit.collider.tag == TerrainTag)
            {
                CanBuild = true;
            }
//            if (hit.collider.tag == Cityprefab.tag)
//            {
//                CanBuild = false;
//                break;
//            }
        }
        if (CanBuild && Kapital >= KostenProStadt * Cities.Count)
        {
            Stadt city = Instantiate(Cityprefab, Pos, Quaternion.identity).GetComponent <Stadt>();
            Cities.Add(city);
            Spawnscript.AddCity(city.gameObject);
            IncreaseKapital(-KostenProStadt * Cities.Count);
            ChatMessage("Tower built!");
        }
        else
        {
            if (CanBuild)
            {
                ChatMessage("Dude, you're boke!");
            }
            else
            {
                ChatMessage("Can't build here.");
            }
        }

        return(CanBuild);
    }