public void ShootRed() { RaycastHit hit; if (Physics.Raycast(bulletPoint.transform.position, bulletPoint.transform.forward, out hit, range)) //(position of bullet point,forward from bullet point position, shoot, within certain range) { Debug.Log(hit.transform.name); ChangeMaterial changeMaterial = hit.transform.GetComponent <ChangeMaterial>(); if (changeMaterial != null) { changeMaterial.ColourRed(); } } }
private void AutoAttachComponent() { List <MeshRenderer> temp = GetComponentsInChildren <MeshRenderer>().ToList(); ChangeMaterial cm = null; materialChangers = new List <ChangeMaterial>(); for (int i = 0; i < temp.Count; i++) { cm = temp[i].gameObject.GetComponent <ChangeMaterial>(); if (cm == null) { cm = temp[i].gameObject.AddComponent <ChangeMaterial>(); } materialChangers.Add(cm); } }
void CheckRay() { Ray ray = Camera.main.ScreenPointToRay(pos.position); RaycastHit Hit; if (Physics.Raycast(ray, out Hit) && isBeingDragged) { objectHit = Hit.collider.gameObject; script = objectHit.GetComponent<ChangeMaterial>(); if (script != null) { if (isFirstInSequence && !script.isState1Done) script.ChangeToState1(); else if (!isFirstInSequence && script.isState1Done && !script.isState2Done) script.ChangeToState2(); Debug.Log(objectHit.name); } } }
IEnumerator Explode() { GetComponent <TraumaInducer>().Delay = timeToBoom; yield return(new WaitForSeconds(timeToBoom)); foreach (var target in targetsInRadius) { target.TakeDamage(owner); Debug.Log("TAKEN DAMAGE"); } foreach (var obj in inSphere) { ChangeMaterial change = obj.GetComponent <ChangeMaterial>(); change.ChangeToOldMat(); } Destroy(gameObject); }
IEnumerator AIUpdate(float tickSec) { while (true) { GuardController controller = GetComponent <GuardController>(); ChangeMaterial changeMtl = GetComponent <ChangeMaterial>(); if (SearchAroundPlayer() && FarFromSpawnPos() == false) { controller.TrackingMode(player.transform.position); changeMtl.Change(1); } else { controller.PatrolMode(); changeMtl.Change(0); } yield return(new WaitForSeconds(tickSec)); } }
// Start is called before the first frame update void Start() { listAll1 = new List <GameObject>(); listAll1.AddRange(list1); listAll1.AddRange(list2); listAll1.AddRange(list3); listAll2 = new List <GameObject>(); listAll2.AddRange(list4); listAll2.AddRange(list5); listAll2.AddRange(list6); root = GameObject.Find("Root"); changeMatScript = root.GetComponent <ChangeMaterial>(); listOfLists1 = new List <GameObject[]>(); listOfLists1.Add(list1); listOfLists1.Add(list2); listOfLists1.Add(list3); listCustom = new List <GameObject>(); listOfListCustom = new List <List <GameObject> >(); listOfListCustom.Add(listCustom); curList = 0; }
// Update is called once per frame void Update() { if (matchStarted) { CountDown(); } #if UNITY_ANDROID if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Ray ray = cam.ScreenPointToRay(touch.position); RaycastHit hit; if (Physics.Raycast(ray, out hit, 10000f, ~(1 << 2))) { ChangeMaterial change = hit.transform.GetComponent <ChangeMaterial>(); if (change != null) { GameManager.GM.players[0].SetStopPoint(new Vector2(hit.transform.position.x, hit.transform.position.z)); } } } #endif #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 10000f, ~(1 << 2))) { ChangeMaterial change = hit.transform.GetComponent <ChangeMaterial>(); if (change != null) { GameManager.GM.players[0].SetStopPoint(new Vector2(hit.transform.position.x, hit.transform.position.z)); } } } #endif }
public void Paint(Vector2 position, bool isPlayerPainted) { ChangeMaterial change = GameManager.GM.gameField[position].cellObject.GetComponent <ChangeMaterial>(); GameManager.GM.gameField[position].cellObject.transform.GetComponent <MeshRenderer>().enabled = false; if (isPlayerPainted) { if (!change.cellPaintedByPlayer.activeSelf) { countOfPaintedPlayerCells++; change.ChangeToPlayerColor(); } } else { if (!change.cellPaintedByOther.activeSelf) { countOfPaintedOtherCells++; change.ChangeToOtherColor(); } } }
private void Select(GameObject hitObject) //when hit by the raycast change color to blue and play a cord { isSelected = true; changeMaterial = hitObject.GetComponent <ChangeMaterial>(); audioSource = hitObject.GetComponent <AudioSource>(); changeMaterial.ChangeTo("blue"); lastObject = hitObject; myFloat.isFloatingUp = true; myFloat.isFloatingDown = false; Instantiate(ringPrefab, new Vector3(hitObject.transform.localPosition.x, hitObject.transform.localPosition.y, hitObject.transform.localPosition.z), Quaternion.identity); isPlayingCord = true; if (isPlayingCord) { if (!audioSource.isPlaying) { audioSource.Play(); } } }
public void Connect(string strName, out ChangeMaterial item) { ExAddProperty(this.m_pSelf, strName, 4, 0x88b8); item = null; }
/* * / Build selected pipe, returns if successul */ private bool buildPipe() { if (nextPipe.GetComponent <Identifier>().pipeType == Identifier.PipeType.Outlet && !ventGoal.bounds.Contains(nextPipe.transform.position)) { Debug.Log("Not allowed to build here"); return(false); } ChangeMaterial pipeToChange = nextPipe.GetComponentInChildren(typeof(ChangeMaterial)) as ChangeMaterial; pipeToChange.ChangeMat(); GameObject builtPipe = nextPipe; pipeHistory.Add(builtPipe); foreach (GameObject pipe in currentSelection) { if (!pipe.activeSelf) { Destroy(pipe); } } currentSelection.Clear(); PipeSound.Instance.PlayPipeConnectSound(builtPipe.transform); updateCamera(); // Determine jump length based on built pipe type switch (builtPipe.GetComponent <Identifier>().pipeType) { case Identifier.PipeType.Long: jumpLength = -1.25f; break; case Identifier.PipeType.Medium: jumpLength = -0.88f; //Debug.Log("medium"); break; case Identifier.PipeType.Short: jumpLength = -0.50f; //Debug.Log("medium"); break; case Identifier.PipeType.Left: jumpLength = -0.18f; bendDir = 1; //Debug.Log("left"); break; case Identifier.PipeType.Right: jumpLength = -0.18f; bendDir = 2; //Debug.Log("right"); break; case Identifier.PipeType.T: jumpLength = -0.25f; //Debug.Log("t"); break; case Identifier.PipeType.Outlet: jumpLength = -0.30f; if (!ventGoal.getComplete() && ventGoal.bounds.Contains(builtPipe.transform.position)) { ventGoal.setComplete(true); completed = true; showObjs(endUI, true); } break; } return(true); }
public void Connect(string strName, out ChangeMaterial item) { item = RuntimeObject.FromPtr(ExGetProperty(this.m_pSelf, strName, 4, 0x88b8)) as ChangeMaterial; }
// Use this for initialization void Start() { cm = GetComponent <ChangeMaterial>(); }
void Awake() { Instance = this; }
public Cell(GameObject cell, Vector2 myPos) { cellObject = cell; myPosition = myPos; change = cellObject.GetComponent <ChangeMaterial>(); }