public void RemoverDaLista(int pos) { GameObject fluxo = GameObject.Find("Fluxo"); estadoJogo = fluxo.GetComponent <Fluxo>(); GameObject gamem = GameObject.Find("GUIPrincipal"); game = gamem.GetComponent <GameMananger>(); if (!estadoJogo.play && !estadoJogo.fimJogo) { Destroy(Pontos[pos].transform.GetChild(0).gameObject); i--; botoesMenu[usados[pos]].GetComponent <Image>().color = new Color32(255, 255, 255, 255); usados.RemoveAt(pos); game.PlantasUsar.RemoveAt(pos); playAtivo.SetActive(false); for (int j = pos; j < i; j++) { Vector3 scale; GameObject obj = Instantiate(Pontos[j + 1].transform.GetChild(0).gameObject, Pontos[j].transform.position, Quaternion.identity) as GameObject; scale = obj.transform.localScale; obj.transform.SetParent(Pontos[j].transform); obj.transform.localScale = scale; Destroy(Pontos[j + 1].transform.GetChild(0).gameObject); Button botao = obj.GetComponent <Button>(); int u = j; botao.onClick.AddListener(() => RemoverDaLista(u)); botao.onClick.AddListener(() => { game.PlantaUsar = u; }); botao.onClick.AddListener(() => teste(u)); } } }
private void Create() { for (int i = 0; i < _number; i++) { //entity GameObject tmp = EntityActionBuffer.Instance.CreateEntity(_prefab); tmp.transform.position = GameMananger.RandomNavmeshLocation(40f, tmp); //component TargetEdible miam = new TargetEdible(); Score score = new Score(i, 0, false); Vendetta vendetta = new Vendetta(false, null); TrailRenderer trailRenderer = new TrailRenderer(tmp); MeshRenderer meshRenderer = new MeshRenderer(tmp); NavMeshAgent navMeshAgent = new NavMeshAgent(tmp); //merging both EntityActionBuffer.Instance.AddComponent(tmp, miam); EntityActionBuffer.Instance.AddComponent(tmp, score); EntityActionBuffer.Instance.AddComponent(tmp, vendetta); EntityActionBuffer.Instance.AddComponent(tmp, trailRenderer); EntityActionBuffer.Instance.AddComponent(tmp, meshRenderer); EntityActionBuffer.Instance.AddComponent(tmp, navMeshAgent); } }
public override void Update() { new EntityQuery() .With <FollowTarget>() .ForEach(obj => { FollowTarget follow = obj.GetECSComponent <FollowTarget>(); //calming down the enemy if (follow.HasBeenCalmDown) { obj.transform.position = GameMananger.RandomNavmeshLocation(400f, obj); obj.GetECSComponent <TrailRenderer>().UnityComponent.Clear(); follow.HasBeenCalmDown = false; EntityActionBuffer.Instance.ApplyComponentChanges(obj, follow); } //we pick a new target PickNewTarget(obj, follow); //We see if the target is dead or not KillTarget(obj, follow); if (follow.Target != null) { obj.GetECSComponent <NavMeshAgent>().UnityComponent.SetDestination(follow.Target.transform.position); } }); }
private void OnEnable() { if (instance == null) { instance = this; } }
// Start is called before the first frame update void Start() { timer = tempoParaMoverPeca; spawnTetro = FindObjectOfType <SpawnTetro>(); gameManager = FindObjectOfType <GameMananger>(); }
public PlayerData(GameMananger gm) { i = gm.pontos; score[0] = i; Debug.Log("Pontos - player Data" + score[0]); //Array.Reverse(score); }
void Awake() { if (!instance) { instance = this; } else { Destroy(this); } }
private void Awake() { if (Ins != null) { Destroy(gameObject); } else { Ins = this; } }
public int lives; // player lives // Use this for initialization void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); // do not destroy this GameManager in different scenes } else { Destroy(gameObject); } }
private void Create() { for (int i = 0; i < _number; i++) { //component Edible edible = new Edible(); //entity GameObject tmp = EntityActionBuffer.Instance.CreateEntity(_prefab); tmp.transform.position = GameMananger.RandomNavmeshLocation(40, tmp); //merging both EntityActionBuffer.Instance.AddComponent(tmp, edible); } }
private void Death(GameObject obj) { if (obj.GetECSComponent <Score>().IsDead) { obj.transform.position = GameMananger.RandomNavmeshLocation(40f, obj); obj.GetECSComponent <TrailRenderer>().UnityComponent.Clear(); Score score = obj.GetECSComponent <Score>(); MonoBehaviour.print($"pecsman N°{score.Id} with score of {score.Value}"); score.Value = 0; score.IsDead = false; EntityActionBuffer.Instance.ApplyComponentChanges(obj, score); } }
public override void Update() { new EntityQuery() .With <Edible>() .ForEach(obj => { //check if food as been eaten Edible edible = obj.GetECSComponent <Edible>(); if (!edible.Active) { obj.transform.position = GameMananger.RandomNavmeshLocation(40f, obj); edible.Active = true; EntityActionBuffer.Instance.ApplyComponentChanges(obj, edible); } }); }
public static void SaveScore(GameMananger gm) { int[] loadScore = LoadScore(); int[] aux = new int[1] { 0 }; PlayerData data = new PlayerData(gm); aux[0] = data.score[0]; Debug.Log("valor aux: " + aux[0]); Debug.Log("data.score[0]: " + data.score[0]); { for (int i = 0; i < data.score.Length; i++) { data.score[i] = loadScore[i]; //Debug.Log("score posição " + i + ": " + data.score[i]); } data.score[10] = aux[0]; // Sort Array.Sort(data.score); for (int i = 0; i < data.score.Length; i++) { Debug.Log("Depois do sorte, score posição " + i + ": " + data.score[i]); } } BinaryFormatter formatoBinario = new BinaryFormatter(); // Local onde vai ser salvo os dados string path = Application.persistentDataPath + "/player.ane"; // Puxar as infos que serão salvas FileStream fileStream = new FileStream(path, FileMode.Create); // Formata e grava formatoBinario.Serialize(fileStream, data); //Debug.Log("Criado " + data.score); fileStream.Close(); }
void Spawn() // Função para Spawnar os zombies { GameObject car = GameObject.Find("GUIPrincipal"); acesso = car.GetComponent <GameMananger>(); if (acesso.GetComponent <GameMananger>().solTotal < 300) { Instantiate(PrefabZombie[0], transform.position, Quaternion.identity); } else if (acesso.GetComponent <GameMananger>().solTotal < 700) { Instantiate(PrefabZombie[Random.Range(0, PrefabZombie.Length - 1)], transform.position, Quaternion.identity); // Instancia o zombie } else { Instantiate(PrefabZombie[Random.Range(0, PrefabZombie.Length)], transform.position, Quaternion.identity); } }
private void Create() { for (int i = 0; i < _number; i++) { //entity GameObject tmp = EntityActionBuffer.Instance.CreateEntity(_prefab); tmp.transform.position = GameMananger.RandomNavmeshLocation(400, tmp); //component FollowTarget follow = new FollowTarget(null, false); TrailRenderer trailRenderer = new TrailRenderer(tmp); MeshRenderer meshRenderer = new MeshRenderer(tmp); NavMeshAgent navMeshAgent = new NavMeshAgent(tmp); //merging both EntityActionBuffer.Instance.AddComponent(tmp, follow); EntityActionBuffer.Instance.AddComponent(tmp, trailRenderer); EntityActionBuffer.Instance.AddComponent(tmp, meshRenderer); EntityActionBuffer.Instance.AddComponent(tmp, navMeshAgent); } }
// int PlantaUsar = 0; public void EscolherCarta(int idcarta) { GameObject gamem = GameObject.Find("GUIPrincipal"); game = gamem.GetComponent <GameMananger>(); if (!usados.Contains(idcarta) && i < 6) { GameObject g = Instantiate(carta[idcarta], Pontos[i].transform.position, Quaternion.identity) as GameObject; g.transform.SetParent(Pontos[i].transform); g.transform.localScale = Vector3.one; Button botao = g.GetComponent <Button>(); int u = i; botao.onClick.AddListener(() => RemoverDaLista(u)); botao.onClick.AddListener(() => { if (game.cooldownAtual[u] <= 0) { game.PlantaUsar = u; } }); botao.onClick.AddListener(() => teste(u)); game.PlantasUsar.Add(prefabsPlantas[idcarta]); i++; usados.Add(idcarta); botoesMenu[idcarta].GetComponent <Image>().color = new Color32(150, 150, 150, 255); } if (i == 6) { playAtivo.SetActive(true); } }
private void Awake() { Intance = this; }
private void Awake() { gameMananger = GameMananger.instance; baseAudioPitch = Random.Range(0.9f, 1.3f); soundMananger = SoundMananger.instance; }
private void Awake() { gameMananger = GameMananger.instance; rb = GetComponent <Rigidbody2D>(); playerInputBox = GetComponent <PlayerInputBox>(); }