protected override void OnSimulateFixedUpdate() { if (countdown > 0) { countdown -= Time.fixedDeltaTime; } if (Key1.IsDown && countdown <= 0) { GameObject Nlock; if (FunnyMode.IsActive) { Nlock = (GameObject)Instantiate(funEnumerator.Current.Value.gameObject, this.transform.position + this.transform.forward, this.transform.rotation); if (!funEnumerator.MoveNext()) { funEnumerator = PrefabMaster.BlockPrefabs.GetEnumerator(); funEnumerator.MoveNext(); } } else { if (blockToSpawn == null) { SpawnChild(); } Nlock = (GameObject)Instantiate(blockToSpawn.gameObject, this.transform.position + this.transform.forward, this.transform.rotation); Nlock.SetActive(true); XDataHolder xDataHolder = new XDataHolder { WasSimulationStarted = true }; blockToSpawn.OnSave(xDataHolder); Nlock.GetComponent <BlockBehaviour>().OnLoad(xDataHolder); } Nlock.transform.localScale *= 生成大小.Value; Nlock.GetComponent <Rigidbody>().isKinematic = false; if (继承速度.IsActive) { Nlock.GetComponent <Rigidbody>().velocity = this.rigidbody.velocity; } Nlock.transform.SetParent(Machine.Active().SimulationMachine); Audio.volume = 0.05f * 10 / Vector3.Distance(this.transform.position, Camera.main.transform.position); Audio.Play(); countdown = 生成间隔.Value; } }
public override void Trigger(AutomatronBlock automatron) { try { valueID = int.Parse(blockID); } catch { valueID = 0; } for (int i = 0; i < 9; i++) { try { fValues[i / 3][i % 3] = float.Parse(sValues[i]); } catch { fValues[i / 3][i % 3] = 0; } } if (valueID == 0) { fValues[(int)value.pos][(int)dim.z] += 0.5f; } GameObject Nlock; if (blockToSpawn == null) { SpawnChild(); } Nlock = (GameObject)GameObject.Instantiate(blockToSpawn.gameObject); var st = Nlock.transform; var at = automatron.transform; st.parent = at; st.localPosition = fValues[(int)value.pos]; st.localRotation = Quaternion.Euler(fValues[(int)value.rot]); st.localScale = fValues[(int)value.scale]; Nlock.SetActive(true); XDataHolder xDataHolder = new XDataHolder { WasSimulationStarted = true }; blockToSpawn.OnSave(xDataHolder); Nlock.GetComponent <BlockBehaviour>().OnLoad(xDataHolder); Nlock.GetComponent <Rigidbody>().isKinematic = false; Nlock.transform.SetParent(Machine.Active().SimulationMachine); }