protected override void OnInit(EventArgs e) { ModuleInstanceCollection input = new ModuleInstanceCollection(); input.LoadByParentModuleInstanceID(base.CurrentModule.ModuleInstanceID, (base.CurrentPerson != null) ? base.CurrentPerson.PersonID : -1); foreach (ModuleInstance instance in input) { if (instance.Permissions.Allowed(OperationType.View, base.CurrentUser)) { PropertyInfo property = base.GetType().GetProperty(instance.TemplateFrameName); if (property == null) { throw new ApplicationException(string.Format("Could not find frame named '{0}' in {1}", instance.TemplateFrameName, base.GetType().Name)); } Control control = (Control)property.GetValue(this, null); if (control == null) { throw new ApplicationException(string.Format("Could not load frame named '{0}'", instance.TemplateFrameName)); } PortalControl portalControl = this.LoadModule(instance); if (portalControl != null) { control.Controls.Add(portalControl); } } } }
void OnTriggerExit(Collider other) { if (other.tag == "Portal") { PortalControl portal = other.GetComponent <PortalControl>(); portal.In = false; } }
void Awake() { //check is there a GameControl Object! if (control == null) { DontDestroyOnLoad(gameObject); control = this; } else if (control != this) { Destroy(gameObject); } }
void Start() { animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); afterimage = Instantiate(afterimagePrefab, transform.position, Quaternion.identity); afterimage.GetComponent <Animator>().runtimeAnimatorController = GetComponent <Animator>().runtimeAnimatorController; feetPos = transform.Find("Feet"); pivot = transform.Find("Pivot"); portal = GameObject.Find("Portal").GetComponent <PortalControl>(); audioManager = GameObject.Find("Audio Manager").GetComponent <AudioManager>(); audioManager.Find("Orb").source.pitch = 1f; hc = GameObject.Find("HUD").GetComponent <HUDControl>(); }
//碰撞事件 private void OnTriggerEnter(Collider other) { //確認碰撞對象的tag是否為Finish if (other.tag == "Finish" && GameManager.Instance.CheckPickUp()) { isFinish = true; clearP = other.transform.GetChild(0).position; transform.position = clearP; rb.isKinematic = true; SoundManager.Instance.PlaySceneEffect("Win"); } //確認碰撞對象的tag是否為Pickup if (other.tag == "Pickup") { GameManager.Instance.Pickup++; TextUI.Instance.Pickup(); //隱藏物件hide pick other.gameObject.SetActive(false); SoundManager.Instance.PlaySceneEffect("PickUp"); } if (other.tag == "Portal") { PortalControl portal = other.GetComponent <PortalControl>(); if (!portal.In) { // RandomPortal(other); next = portal.next; next.GetComponent <PortalControl>().In = true; Invoke("SetPosition", 0.3f); portal.In = true; } } if (other.tag == "Dead") { isDead = true; rb.useGravity = false; rb.isKinematic = true; RelifeButton.SetActive(true); jumpButton.SetActive(false); SoundManager.Instance.PlaySceneEffect("Lose"); } }