// Use this for initialization void Start() { if((tipo ==TipoEstrutura.CANO_CENTRAL) || (tipo == TipoEstrutura.SLOT)) { sabotado = false; conectado = true; //construido = false; vida = 100; } statusProgressao = StatusProgresso.LIBERADO; nivelEstrutura = 1; if (periferico) rotacaoX = 180; else rotacaoX = 0; if(tipo == TipoEstrutura.CENTRAL_SEGURANCA) setQuantidadeMaximaDrones(); if(tipo == TipoEstrutura.FAZENDA) setQuantidadeMaximaMacacos(); }
void Construir() { GameObject construcaoNova; bool drone = false; string nomeProvisorio =""; if(tipo == TipoEstrutura.SLOT) statusProgressao = StatusProgresso.CONCLUIDO; else statusProgressao = StatusProgresso.LIBERADO; progressoAtual = 0; //construcoes if(objetoAConstruir == TipoEstrutura.FAZENDA) { prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabFazenda; nomeProvisorio = "HydroponicFarm"; } if(objetoAConstruir == TipoEstrutura.FABRICA_DRONES) { prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabFabricaDrones; nomeProvisorio = "DroneFactory"; } if(objetoAConstruir == TipoEstrutura.LABORATORIO) { prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabLaboratorio; nomeProvisorio = "ResearchLab"; } if(objetoAConstruir == TipoEstrutura.CENTRAL_SEGURANCA) { prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabCentralSeguranca; nomeProvisorio = "SecurityCenter"; } //drones if(objetoAConstruir == TipoEstrutura.DRONE_NORMAL){ prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabUnidadeDrone; drone = true; } if(objetoAConstruir == TipoEstrutura.DRONE_SABOTADOR){ prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabUnidadeDroneSabotador; drone = true; } if(objetoAConstruir == TipoEstrutura.DRONE_VIGILANCIA){ prefabConstrucao = GameObject.Find("Codigo").GetComponent<EventosMenu>().prefabUnidadeDroneVigilancia; drone = true; } if(!drone){ construcaoNova = (GameObject)Instantiate(prefabConstrucao,new Vector3(transform.position.x,transform.position.y + 0.7f,transform.position.z),Quaternion.Euler(0,rotacaoX,0)); construcaoNova.name = nomeProvisorio + this.name.Substring(4,1); GameObject.Find("Regiao"+this.name.Substring(4,1)).GetComponent<Regiao>().setor[1] = construcaoNova; GameObject.Find("CommandCenter").GetComponent<GerenciadorSlots>().slots[int.Parse(this.name.Substring(4,1))-1] = construcaoNova; cano = GameObject.Find("CanoCentral"+this.name.Substring(4,1)+"/Mesh/(TO TEX) Tube -- Low (MAP) (ANI F)"); //.renderer.enabled = true; cano.renderer.enabled = true; cano.animation.Play("Tube_Acordeon"); { // Updates the A* graph with the collider of the new built structure Collider col; col = construcaoNova.collider; if(!col) { // DEBUG Debug.LogError(this.transform + " No collider found to building " + construcaoNova); } Bounds newBounds = col.bounds; GraphUpdateObject guo = new GraphUpdateObject(newBounds); AstarPath.active.UpdateGraphs(guo); } } else{ posicao1 = transform.Find("Mesh/Position1").transform.position; Debug.Log(posicao1); //construcaoNova = (GameObject)Instantiate(prefabConstrucao,new Vector3(transform.position.x,transform.position.y+1,transform.position.z),Quaternion.Euler(0,0,0)); construcaoNova = (GameObject)Instantiate(prefabConstrucao,posicao1,Quaternion.Euler(0,0,0)); posicao2 = transform.Find("Mesh/Position2").transform.position; //construcaoNova.GetComponent<CDrone>().WalkTo(posicao1); construcaoNova.GetComponent<CDrone>().WalkTo(posicao2); GameObject.Find("Codigo").GetComponent<EventosMenu>().quantidadeDrones++; } }
void IncrementaNivel() { //GameObject.Find("Player").GetComponent<CPlayer>().SubResourceMetal(custoMetalEvoluirNivel[nivelEstrutura-1]); nivelEstrutura++; statusProgressao = StatusProgresso.LIBERADO; progressoAtual = 0; if(tipo == TipoEstrutura.CENTRAL_SEGURANCA) setQuantidadeMaximaDrones(); if(tipo == TipoEstrutura.FAZENDA) setQuantidadeMaximaMacacos(); }