private static void Create() { // 生成 MaterialChanger window = GetWindow <MaterialChanger>("MaterialChanger"); window.maxSize = window.minSize = new Vector2(400, 150); }
// Start is called before the first frame update void Awake() { if (TryGetComponent(out Tower tower)) { this.tower = tower; } if (TryGetComponent(out MaterialChanger materialChanger)) { this.materialChanger = materialChanger; } if (TryGetComponent(out ColliderChecker colliderChecker)) { this.colliderChecker = colliderChecker; } if (TryGetComponent(out TowerBuildingController towerBuildingController)) { this.towerBuildingController = towerBuildingController; } if (TryGetComponent(out TowerPlacingController towerPlacingController)) { this.towerPlacingController = towerPlacingController; } materialChanger.IgnoredMeshes.Add(towerPlacingController.attackRangePreview.GetComponent <MeshRenderer>()); }
// Start is called before the first frame update void Awake() { if (TryGetComponent(out Tower tower)) { this.tower = tower; } if (TryGetComponent(out MaterialChanger materialChanger)) { this.materialChanger = materialChanger; } if (TryGetComponent(out ColliderChanger colliderChanger)) { this.colliderChanger = colliderChanger; } if (PlaceableMaterial == null) { Debug.LogError("No placeable material!", this); } if (NotPlaceableMaterial == null) { Debug.LogError("No not placeable material!", this); } if (attackRangePreview == null) { Debug.LogError("No gameobject to reference range", this); } enabled = false; }
/// <summary>Sync the values of the Item and Original Object if they have the Material & Mesh Changer </summary> protected virtual void Sync_Material_ActiveMeshes() { if (Last_SpawnedItem) { MaterialChanger OriginalMC = Last_SpawnedItem.GetComponent <MaterialChanger>(); MaterialChanger ItemSelMC = ItemSelected.GetComponent <MaterialChanger>(); if (OriginalMC && ItemSelMC) { for (int i = 0; i < ItemSelMC.materialList.Count; i++) { OriginalMC.SetMaterial(i, ItemSelMC.CurrentMaterialIndex(i)); //Set the Materials from the Item to the Original } } ActiveMeshes OriginalAM = Last_SpawnedItem.GetComponent <ActiveMeshes>(); ActiveMeshes ItemSelAM = ItemSelected.GetComponent <ActiveMeshes>(); if (OriginalAM && ItemSelAM) { for (int i = 0; i < ItemSelAM.Count; i++) { OriginalAM.ChangeMesh(i, ItemSelAM.GetActiveMesh(i).Current); //Set the Meshes from the Item to the Original } } } }
// Use this for initialization void Start() { buildingOnBoardingC = GlobalManagement.BuildingView.GetComponent <BuildingOnboardingController>()._onboardingC; highlightMat = (Material)Resources.Load("Highlight", typeof(Material)); overrideMat = (Material)Resources.Load("Ghost", typeof(Material)); if (gameObject.transform.GetChild(0).FindChild("cast")) { gameObject.transform.GetChild(0).FindChild("cast").gameObject.tag = "CastModel"; } hotspots = GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in hotspots) { ParticleSystem.EmissionModule em = p.GetComponentInChildren <ParticleSystem>().emission; em.enabled = true; } // Debug.Log(gameObject.transform.FindChild("BuildingModel").gameObject.transform.parent.FindChild("Ground")); Debug.Log(gameObject.transform.FindChild("BuildingModel").gameObject); Debug.Log("apply mat changer"); Debug.Log(overrideMat); Debug.Log(highlightMat); matChanger = new MaterialChanger(gameObject.transform.FindChild("BuildingModel").gameObject, overrideMat, highlightMat); }
public void SetSelectedMap(TMP_Dropdown dropdown) { // Gets the name from the dropdown String name = dropdown.captionText.text; // if selected map is the currently loaded map if (IsSelectedMapLoaded() && selectedMap == name) { return; } // if selected map is not the currently loaded map if (IsSelectedMapLoaded() && selectedMap != name) { if (RoundManager.singleton.IsOnWarmup || RoundManager.singleton.IsRoundStarted) { startRoundButton.interactable = true; startRoundButtonText.text = "start round"; startRoundImage.color = MaterialChanger.GetColor(MaterialChanger.Palette01.green); RoundManager.singleton.EndRound(); } UnloadSelectedMap(); } loadSceneButtonText.text = "load map"; foreach (String map in maps) { if (map == name) { CmdSetSelectedMap(map); } } }
public void SpawnButtons(MaterialChanger obj) { for (int i = 0; i < obj.materials.Length; i++) { MaterialChangerButton newButton = Instantiate(buttonPrefab) as MaterialChangerButton; newButton.transform.SetParent(transform.GetChild(0)); newButton.transform.localScale = Vector3.one; newButton.transform.rotation = transform.rotation; newButtonRect = newButton.gameObject.GetComponent <RectTransform>(); newButtonRect.sizeDelta = new Vector2(buttonSize, buttonSize); newButton.title = obj.materials[i].title; newButton.material = obj.materials[i].material; newButton.obj = obj; float theta = 0; if (autoSpaceButtons == true) { theta = (2 * Mathf.PI / obj.materials.Length) * i; } else { theta = (2 * Mathf.PI / numberOfButtons) * i; } float xPos = Mathf.Sin(theta); float yPos = Mathf.Cos(theta); newButton.transform.localPosition = new Vector3(xPos, yPos, 0f) * distanceFromCenter; } }
public override void SuccessfullyClick() { if (rb != null && gameObject != null) { if (!pointsEarned && PowerUpButton.activePowerUps.Count > 0 && Random.Range(0, Random.Range(85, 95)) < 2) { PowerUp powerUp = PowerUpButton.DeterminePowerUp(); ClickForPoints2D spawn = ObjectSpawner.GetSpawn(powerUp); spawn = Instantiate(spawn, null); spawn.Reposition(transform.position); spawn.transform.parent = null; spawn.gameObject.SetActive(true); } rb.isKinematic = false; rb.AddForce(Vector3.down * 200f, ForceMode.Acceleration); base.SuccessfullyClick(); MaterialChanger m = GetComponentInChildren <MaterialChanger>(); if (m != null) { m.enabled = true; } Collider c = GetComponent <Collider>(); if (c != null) { Destroy(c); } } }
/// <summary> ///Checks the tag of a given object and grabs the correct MaterialObjects. ///if there is a material option with the given tag, it will get the stats of the object. (The ObjStats) ///It will then create buttons with all of the material options /// </summary> /// <param name="_obj"> What object to check</param> public void GetMaterialObjects(GameObject _obj) { //clear all buttons //foreach (Transform child in GUIPanel.transform) //{ // Destroy(child.gameObject); //} CurrentStats = null; SelectedObject = null; AllObjectStats.Clear(); if (_obj.GetComponent <MaterialChanger>()) { ObjCenter = _obj.GetComponent <Collider>().bounds.center; SelectionIndicator.transform.position = Camera.main.WorldToScreenPoint(ObjCenter); SelectionIndicator.SetActive(true); CurrentStats = _obj.GetComponent <MaterialChanger>(); if (CurrentStats.ChangeByTag) { AllObjectStats = CurrentStats.TaggedStats(GameObject.FindGameObjectsWithTag(_obj.tag)); } else { AllObjectStats.Add(CurrentStats.Stats); } SelectedObject = _obj; ButtonCreator(); } }
protected override void Awake() { base.Awake(); MaterialChanger.SetAllChildrenHeighlightButton(gameObject, m_grabButton); afterGrabberGrabbed += () => m_afterGrabbed.Invoke(this); beforeGrabberReleased += () => m_beforeRelease.Invoke(this); onGrabberDrop += () => m_onDrop.Invoke(this); }
private void Start() { btnAdd.onClick.AddListener(delegate() { BtnClick(btnAdd); }); btnDelete.onClick.AddListener(delegate() { BtnClick(btnDelete); }); btnGo.onClick.AddListener(delegate() { BtnClick(btnGo); }); GameObject playerObj = GameObject.FindGameObjectWithTag("Player").transform.root.gameObject; mesh = GameObject.FindGameObjectWithTag("Player").GetComponent <ActiveMeshes>(); material = GameObject.FindGameObjectWithTag("Player").GetComponent <MaterialChanger>(); }
void Start() { rotationSelection = mainframe.GetComponent <RotationSelection>(); GameObject MainframeController = GameObject.FindWithTag("MainframeController"); mainframeController = MainframeController.GetComponent <MainframeController>(); mainframeActionSelection = MainframeController.GetComponent <MainframeActionSelection>(); positionOperator = mainframeBody.GetComponent <PositionOperator>(); materialChanger = GetComponent <MaterialChanger>(); guiManager = guiManagerObject.GetComponent <GUIManager>(); PreparationOfTheFirstGame(); }
// 初期化 void Start() { pause = GameObject.Find("Pause"); pauseScript = pause.GetComponent<Pause>(); Ivy_one = Ivychild_one.GetComponent<MaterialChanger>(); Ivy_two = Ivychild_two.GetComponent<MaterialChanger>(); gimmickFlag = false; // ギミックが有効か判断するフラグに偽を保存 startActionTurn = 4; // ギミックを動かし始めるターン数を1に gimmickCount = 0; // ギミックが有効になってからのターン数を0に growCount = 0; // 初期の成長段階 movePossibleFlag = true; // 移動可能フラグを真に moveCount = 0; }
/// <summary> /// Creates a list of 'ObjectStats' based on the [] of GameObjects passed /// </summary> /// <param name="otherObjects"> Array of GameObjects to be Changed to List<ObjectStats> </param> /// <returns></returns> public List <ObjectStats> TaggedStats(GameObject[] otherObjects) { List <ObjectStats> StatsList = new List <ObjectStats>(); foreach (GameObject obj in otherObjects) { MaterialChanger objstat = obj.GetComponent <MaterialChanger>(); if (objstat) { StatsList.Add(objstat.Stats); } } return(StatsList); }
public void Start() { changer1 = ball.GetComponent <MaterialChanger>(); changer2 = thread.GetComponent <MaterialChanger>(); changer3 = column.GetComponent <MaterialChanger>(); changer4 = scale.GetComponent <MaterialChanger>(); changer5 = plastine.GetComponent <MaterialChanger>(); changer6 = screen.GetComponent <MaterialChanger>(); ballButton = button1.GetComponent <BallButtonScript>(); threadButton = button2.GetComponent <ThreadButtonScript>(); columnButton = button3.GetComponent <ColumnButtonScript>(); scaleButton = button4.GetComponent <ScaleButtonScript>(); plastineButton = button5.GetComponent <PlastineButtonScript>(); counterButton = button6.GetComponent <CounterButtonScript>(); }
private void Init(object param) { cellIndex = (int)param; index = 0; btnUp.gameObject.SetActive(false); btnNext.gameObject.SetActive(true); btnFinish.gameObject.SetActive(false); windows[0].SetActive(true); for (int i = 1; i < 5; i++) { windows[i].SetActive(false); } deer = GameObject.FindGameObjectWithTag("Player"); mesh = deer.GetComponent <ActiveMeshes>(); material = deer.GetComponent <MaterialChanger>(); }
// public void HandleRoundButton() { RoundManager roundManager = RoundManager.singleton; if (roundManager.IsOnWarmup || roundManager.IsRoundStarted) { startRoundButtonText.text = "start round"; startRoundImage.color = MaterialChanger.GetColor(MaterialChanger.Palette01.green); roundManager.EndRound(); } else if (!roundManager.IsRoundStarted || !roundManager.IsOnWarmup) { startRoundButtonText.text = "stop round"; startRoundImage.color = MaterialChanger.GetColor(MaterialChanger.Palette01.red); roundManager.StartWarmup(); } }
private void Awake() { if (singleton != null && singleton != this) { Destroy(gameObject); } else { singleton = this; } // perish RoundManager.ServerRoundEnded += delegate { startRoundButtonText.text = "start round"; startRoundImage.color = MaterialChanger.GetColor(MaterialChanger.Palette01.green); }; startRoundButton.onClick.AddListener(delegate { HandleRoundButton(); }); }
public void StartPlacing(BuildingGrid grid, int price) { _player.ObjectSelector.Deselect(); _player.CursorState = CursorStates.Placing; grid.transform.position = new Vector3(0.0f, -10000f, 0.0f);//установка созданного объекта в позицию, невидимую для игроков. PlaceableObjectGrid = grid; PlaceableObjectPrice = price; PlaceableObjectGrid.collider.isTrigger = true;//отключаем влиения объекта на физику в игре //Отключение AI, если есть var objectAI = PlaceableObjectGrid.GetComponent <BaseObjectAI>(); if (objectAI != null) { objectAI.enabled = false; } _materialChanger = PlaceableObjectGrid.GetComponent <MaterialChanger>(); if (_materialChanger != null) { _materialChanger.SetTransparent(0.6f); } //добавляем Rigidbody для работы с методами OnTrigger, OnCollision в BuildingGrid var objectRigidbody = PlaceableObjectGrid.GetComponent <Rigidbody>(); if (objectRigidbody == null) { _hasDefaultRigidbody = false; objectRigidbody = grid.gameObject.AddComponent <Rigidbody>(); objectRigidbody.isKinematic = true; } else { _hasDefaultRigidbody = true; } _placingMode = true; }
// Start is called before the first frame update void Awake() { materialChanger = GetComponent <MaterialChanger>(); if (TryGetComponent(out Tower tower)) { this.tower = tower; } if (progressionSlider == null) { Debug.LogError("No progession slider found!", this); } if (BuildingMaterial == null) { Debug.LogError("No Material Set", this); } enabled = false; }
private void Awake() { bank = FindObjectOfType <Bank>(); materialChanger = GetComponentInChildren <MaterialChanger>(); }
public void AddComponentsToSceneObject(AreaSceneObjectData jsonData, GameObject so) { if (jsonData.soData.Count > 0) { SceneObjectDataGeneric data = jsonData.soData [0]; SceneObjectData sceneObjectData = so.GetComponent <SceneObjectData> (); Bumper bumper = so.GetComponent <Bumper> (); if (data.bumperForce > 0) { if (bumper == null) { bumper = so.gameObject.AddComponent <Bumper> (); } bumper.force = data.bumperForce; } if (data.size != Vector3.zero) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.size = data.size; } if (data.random_pos_x != 0) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.random_pos_x = data.random_pos_x; } if (data.minPayers != 0) { if (sceneObjectData == null) { sceneObjectData = so.gameObject.AddComponent <SceneObjectData> (); } sceneObjectData.minPayers = data.minPayers; } } MaterialSwapper mat = so.GetComponent <MaterialSwapper>(); if (mat != null && jsonData.mat.Count > 0) { MaterialChanger data = jsonData.mat[0]; //if (mat == null) // mat = so.gameObject.AddComponent<MaterialSwapper>(); mat.Init(data.name); } FullRotation fullRotation = so.GetComponent <FullRotation> (); if (jsonData.fullRotationData.Count > 0) { FullRotationData data = jsonData.fullRotationData [0]; if (fullRotation == null) { fullRotation = so.gameObject.AddComponent <FullRotation> (); } fullRotation.rotateX = data.rotateX; fullRotation.rotateY = data.rotateY; fullRotation.rotateZ = data.rotateZ; fullRotation.speed = data.speed; fullRotation.randomRotation = data.random; } else if (fullRotation != null) { fullRotation.OnComponentDisposed(); } TimelineAnimation timelineAnimation = so.GetComponent <TimelineAnimation> (); if (jsonData.timelineAnimation.Count > 0) { TimelineAnimationData data = jsonData.timelineAnimation [0]; if (timelineAnimation == null) { timelineAnimation = so.gameObject.AddComponent <TimelineAnimation> (); } timelineAnimation.timeLineData = data.timeLineData; } else if (timelineAnimation != null) { timelineAnimation.OnComponentDisposed(); } if (jsonData.bossSettings.Count > 0) { BossSettingsData data = jsonData.bossSettings [0]; BossSettings newcomponent = so.GetComponent <BossSettings> (); if (newcomponent == null) { newcomponent = so.gameObject.AddComponent <BossSettings> (); } newcomponent.bossModule = data.bossModule; newcomponent.time_to_init_enemies = data.time_to_init_enemies; newcomponent.asset = data.asset; newcomponent.time_to_kill = data.time_to_kill; newcomponent.distance_from_avatars = data.distance_from_avatars; newcomponent.bundle = data.bundle; } if (jsonData.moveForward.Count > 0) { MoveForwardData data = jsonData.moveForward [0]; MoveForward newcomponent = so.GetComponent <MoveForward> (); if (newcomponent == null) { newcomponent = so.gameObject.AddComponent <MoveForward> (); } newcomponent.speed = data.speed; newcomponent.randomSpeedDiff = data.randomSpeedDiff; newcomponent.moveBackIn = data.moveBackIn; } }
public void AddComponentsToJson(AreaSceneObjectData newSOdata, GameObject go) { FullRotation fullRotation = go.GetComponent <FullRotation> (); MaterialSwapper mat = go.GetComponent <MaterialSwapper>(); TimelineAnimation timelineAnimation = go.GetComponent <TimelineAnimation> (); BossSettings bossSettings = go.GetComponent <BossSettings> (); MoveForward moveForward = go.GetComponent <MoveForward> (); Bumper bumper = go.GetComponent <Bumper> (); SceneObjectData soData = go.GetComponent <SceneObjectData> (); if (newSOdata.name == "wallSmall") { newSOdata.mat = new List <MaterialChanger>(); MaterialChanger mc = new MaterialChanger(); mc.name = go.GetComponent <MeshRenderer>().sharedMaterial.ToString().Split(" "[0])[0]; newSOdata.mat.Add(mc); } if (soData != null) { newSOdata.soData = new List <SceneObjectDataGeneric> (); SceneObjectDataGeneric data = new SceneObjectDataGeneric(); data.size = soData.size; data.random_pos_x = soData.random_pos_x; data.minPayers = soData.minPayers; data.minPayers = soData.minPayers; newSOdata.soData.Add(data); } if (bumper != null) { newSOdata.soData = new List <SceneObjectDataGeneric> (); SceneObjectDataGeneric data = new SceneObjectDataGeneric(); data.bumperForce = bumper.force; newSOdata.soData.Add(data); } if (fullRotation != null) { newSOdata.fullRotationData = new List <FullRotationData> (); FullRotationData data = new FullRotationData(); data.rotateX = fullRotation.rotateX; data.rotateY = fullRotation.rotateY; data.rotateZ = fullRotation.rotateZ; data.speed = fullRotation.speed; data.random = fullRotation.randomRotation; newSOdata.fullRotationData.Add(data); } if (timelineAnimation != null) { newSOdata.timelineAnimation = new List <TimelineAnimationData> (); TimelineAnimationData data = new TimelineAnimationData(); data.timeLineData = timelineAnimation.timeLineData; newSOdata.timelineAnimation.Add(data); } if (bossSettings != null) { newSOdata.bossSettings = new List <BossSettingsData> (); BossSettingsData data = new BossSettingsData(); data.bossModule = bossSettings.bossModule; data.asset = bossSettings.asset; data.time_to_init_enemies = bossSettings.time_to_init_enemies; data.time_to_kill = bossSettings.time_to_kill; data.distance_from_avatars = bossSettings.distance_from_avatars; data.bundle = bossSettings.bundle; newSOdata.bossSettings.Add(data); } if (moveForward != null) { newSOdata.moveForward = new List <MoveForwardData> (); MoveForwardData data = new MoveForwardData(); data.speed = moveForward.speed; data.randomSpeedDiff = moveForward.randomSpeedDiff; data.moveBackIn = moveForward.moveBackIn; newSOdata.moveForward.Add(data); } }
private void Start() { Changer = FindObjectOfType <MaterialChanger>(); }
public bool Stuck => welded || bolted || disabled || !powered; // TODO: add electrical.off here void Start() { changer = gameObject.AddComponent(typeof(MaterialChanger)) as MaterialChanger; LightsSetState(); }
protected virtual void OnValidate() { MaterialChanger.SetAllChildrenHeighlightButton(gameObject, m_grabButton); }
private void Start() { changer = obj.GetComponent <MaterialChanger>(); }
// private Text text; void Start() { //text = GetComponentInChildren<Text>(); joinObject = GetComponent <MaterialChanger>(); }