public override void OnTrigger() { if (DurabilityCheck()) { List <RFX4_PhysicsMotion> list = new List <RFX4_PhysicsMotion>(); if (Enhaced) { Instantiate(EnhanceBullet, FollowTransform.GetComponent <PlayerItemHand>().way.position + 1.6f * FollowTransform.GetComponent <PlayerItemHand>().way.transform.forward, FollowTransform.GetComponent <PlayerItemHand>().way.rotation); } else { list.Add(Fire(0)); } if (list.Count > 1) { foreach (RFX4_PhysicsMotion rFX4_Physics in list) { rFX4_Physics.AddIgnore(list); } } if (Durability == 0) { Destroy(this.gameObject); } } else { Destroy(this.gameObject); } base.OnTrigger(); }
public void Init(Entity player, PlayerController controller, LevelCamera levelCam, FollowTransform followCam, EntityHUD hud, SaverOwner gameSaver, EntityObjectAttacher.Attacher attacher, EntityObjectAttacher.AttachTag attachTag, EntityLocalVarOverrider varOverrider, Vector3 P, Vector3 D) { this.ent = player; this.controller = controller; this.RegEvents(player); this.levelCam = levelCam; this.followCam = followCam; this.spawnPos = P; this.roomSpawnPos = P; this.spawnDir = D; this.roomSpawnDir = D; this.hud = hud; this.gameSaver = gameSaver; this.attacher = attacher; this.attachTag = attachTag; this.varOverrider = varOverrider; base.enabled = false; IDataSaver saver = gameSaver.GetSaver("/local/start", true); if (saver != null) { string a = saver.LoadData("level"); Vector3 vector; Vector3 vector2; if (a == Utility.GetCurrentSceneName() && SceneDoor.GetSpawnPoint(saver.LoadData("door"), out vector, out vector2)) { this.spawnPos = vector; this.spawnDir = vector2; } } }
private void OnEnable() { m_collider = GetComponent <Collider2D>(); m_renderer = GetComponent <SpriteRenderer>(); collectFX = GetComponent <ParticleSystem>(); followTransform = GetComponent <FollowTransform>(); }
private IEnumerator StartleTime() { m_animator.SetTrigger("Startle"); m_rigidbody.velocity = Vector2.zero; Transform t = PlayerPhaseManager.instance.GetTarget(); targetAim.transform.parent = null; targetAim.transform.position = t.position; targetAim.SetActive(true); FollowTransform followTransform = targetAim.GetComponent <FollowTransform>(); followTransform.Follow(t); yield return(new WaitForSeconds(.8f)); targetAim.GetComponent <AudioSource>().Stop(); followTransform.enabled = false; m_animator.SetTrigger("PreAttack"); m_rigidbody.velocity = (facingRight ? Vector2.right : Vector2.left) * .2f; yield return(new WaitForSeconds(.4f)); chargeSFX.Play(); SetAttack(); }
private void OnEnable() { m_collider = GetComponent <Collider2D>(); m_renderer = GetComponent <SpriteRenderer>(); collectSFX = GetComponent <AudioSource>(); followTransform = GetComponent <FollowTransform>(); }
void Start() { //Cursor.visible = false; //Cursor.lockState = CursorLockMode.Locked; Initialize(); followAttractor = GetComponent <FollowTransform>(); }
private FollowTransform getScreen() { if (screen == null) { screen = (FollowTransform)FindObjectOfType(typeof(FollowTransform)); } return(screen); }
public void RefreshGlowRawImage() { if (!_glowRawImage) { Debug.LogError("此时glowRawImage不存在,不应该调用Refresh方法。"); return; } if (_rt) { _rt.Release(); } //开始创造RT ILayoutElement l = graphic as ILayoutElement; //多出20像素。 float rawImageWidth = l.preferredWidth + WidthMargin; _rt = UIGlowEffectCamera.Instance.CreateGlowRenderTexture( _mesh, graphic.mainTexture, rawImageWidth, DownSample, BlurIterations, Strength ); //设置图片 _glowRawImage.texture = _rt; _glowRawImage.color = GlowColor; float rtAspect = 1f * _rt.width / _rt.height; //设置raw image的大小。 _glowRawImage.rectTransform.sizeDelta = new Vector2(rawImageWidth, rawImageWidth / rtAspect); //如果这个是text,pivot不同,导致中心点不同,这里要加上mesh的bounds做一下偏移。 //UpOffset也要在这里应用。 _glowRawImage.rectTransform.position = graphic.rectTransform.position + _mesh.bounds.center + new Vector3(Offset.x, Offset.y, 0); if (!_glowRawImage.gameObject.activeSelf) { _glowRawImage.gameObject.SetActive(true); } //每次刷新glow image之后,重新设置follow组件,保证glow image的相对位置是正确的。 FollowTransform ct = _glowRawImage.gameObject.GetComponent <FollowTransform>(); if (!ct) { ct = _glowRawImage.gameObject.AddComponent <FollowTransform>(); } ct.SetFollowTarget(transform); ct.FollowPosition = true; ct.FollowRotation = true; ct.FollowLocalScale = true; }
public void Explode() { StartCoroutine(ExplodeAction()); if (screen == null) { screen = (FollowTransform) FindObjectOfType(typeof(FollowTransform)); } screen.ShakeTime(0.5f); }
private IEnumerator InitializedDelayed() { yield return(0); txt = GetComponent <Text>(); DroneGenerator dg = FindObjectOfType <DroneGenerator>(); drones = DroneGenerator.COLUMS * DroneGenerator.ROWS; followAttractor = FindObjectOfType <FollowTransform>(); }
public void Explode() { StartCoroutine(ExplodeAction()); if (screen == null) { screen = (FollowTransform)FindObjectOfType(typeof(FollowTransform)); } screen.ShakeTime(0.5f); }
public virtual void Initialize() { RefreshPosition(); if (!(this is Player)) { _hp_indicator = Instantiate(GM.indicator_prefab); FollowTransform ft = _hp_indicator.GetComponent <FollowTransform>(); ft.to_follow = transform; ft.offset = Vector2.down * 2.2f; } hp_indicator.SetNumber(hp); }
Basic_Bullet Fire(float angle) { GameObject b = Instantiate(bullet, FollowTransform.GetComponent <PlayerItemHand>().way.position + 1.2f * FollowTransform.GetComponent <PlayerItemHand>().way.transform.forward, FollowTransform.GetComponent <PlayerItemHand>().way.rotation); b.transform.eulerAngles += new Vector3(0, angle, 0); Destroy(b, DestroyTime); if (b.GetComponent <Basic_Bullet>() != null) { b.GetComponent <Basic_Bullet>().PlayerID = PlayerID; return(b.GetComponent <Basic_Bullet>()); } return(null); }
public Letter this[char c] { get { FollowTransform ft = transform.Find(c.ToString()).GetComponent <FollowTransform>(); Letter ret = ft.GetComponent <Letter>(); if (ret == null) { ret = ft.gameObject.AddComponent <Letter>(); } return(ret); } }
ItemBomb Fire(float angle) { GameObject b = Instantiate(bomb, FollowTransform.GetComponent <PlayerItemHand>().way.position + 1.2f * FollowTransform.GetComponent <PlayerItemHand>().way.transform.forward, FollowTransform.GetComponent <PlayerItemHand>().way.rotation); b.transform.eulerAngles += new Vector3(0, angle, 0); b.transform.localScale = transform.lossyScale; Rigidbody rb = b.GetComponent <Rigidbody>(); rb.isKinematic = false; rb.useGravity = true; rb.AddForce(600 * (FollowTransform.GetComponent <PlayerItemHand>().way.forward)); // Need fix if (b.GetComponent <ItemBomb>() != null) { b.GetComponent <ItemBomb>().PlayerID = PlayerID; b.GetComponent <ItemBomb>().OnUse(); return(b.GetComponent <ItemBomb>()); } return(null); }
void DoSpawn(Vector3 P, Vector3 dir) { Vector3 vector; if (this._spawnOnFloor && PhysicsUtility.GetFloorPoint(P, 20f, 50f, this._floorLayer, out vector)) { P.y = vector.y; } Vector3 vector2 = P + this._playerEnt.transform.localPosition; GameObject gameObject = Object.Instantiate <GameObject>(this._playerCamera, vector2 + this._playerCamera.transform.localPosition, this._playerCamera.transform.localRotation); gameObject.transform.localScale = this._playerCamera.transform.localScale; gameObject.name = this._playerCamera.name; CameraContainer component = gameObject.GetComponent <CameraContainer>(); component.Init(this._playerCamera); Entity entity = Object.Instantiate <Entity>(this._playerEnt, vector2, base.transform.rotation); entity.name = this._playerEnt.name; if (component != null) { RoomSwitchable componentInChildren = entity.GetComponentInChildren <RoomSwitchable>(); if (componentInChildren != null) { componentInChildren.SetLevelCamera(component); } } if (this._playerGraphics != null) { GameObject gameObject2 = Object.Instantiate <GameObject>(this._playerGraphics, entity.transform.position + this._playerGraphics.transform.localPosition, this._playerGraphics.transform.localRotation); gameObject2.transform.parent = entity.transform; gameObject2.transform.localScale = this._playerGraphics.transform.localScale; gameObject2.name = this._playerGraphics.name; } entity.Init(); entity.TurnTo(dir, 0f); FollowTransform componentInChildren2 = gameObject.GetComponentInChildren <FollowTransform>(); if (componentInChildren2 != null) { componentInChildren2.SetTarget(entity.transform); } LevelCamera componentInChildren3 = gameObject.GetComponentInChildren <LevelCamera>(); if (componentInChildren3 != null) { LevelRoom roomForPosition = LevelRoom.GetRoomForPosition(entity.WorldTracePosition, null); if (roomForPosition != null) { componentInChildren3.SetRoom(roomForPosition); roomForPosition.SetImportantPoint(vector2); LevelRoom.SetCurrentActiveRoom(roomForPosition, false); } } PlayerController controller = ControllerFactory.Instance.GetController <PlayerController>(this._controller); controller.ControlEntity(entity); controller.name = this._controller.name; entity.Activate(); if (this._varOverrider != null) { this._varOverrider.Apply(entity); } EntityHUD componentInChildren4 = gameObject.GetComponentInChildren <EntityHUD>(); if (componentInChildren4 != null) { componentInChildren4.Observe(entity, controller); } EntityObjectAttacher.Attacher attacher = null; EntityObjectAttacher component2 = base.GetComponent <EntityObjectAttacher>(); if (component2 != null) { attacher = component2.GetAttacher(); } EntityObjectAttacher.AttachTag attachTag = null; if (attacher != null) { attachTag = attacher.Attach(entity); } PlayerRespawner playerRespawner; if (this._respawner != null) { playerRespawner = Object.Instantiate <PlayerRespawner>(this._respawner); playerRespawner.name = this._respawner.name; } else { GameObject gameObject3 = new GameObject("PlayerRespawer"); playerRespawner = gameObject3.AddComponent <PlayerRespawner>(); } playerRespawner.Init(entity, controller, componentInChildren3, componentInChildren2, componentInChildren4, this._gameSaver, attacher, attachTag, this._varOverrider, P, dir); VarHelper.PlayerObj = entity.gameObject; // Store reference to player obj PlayerSpawner.OnSpawnedFunc onSpawnedFunc = PlayerSpawner.onSpawned; PlayerSpawner.onSpawned = null; if (onSpawnedFunc != null) { onSpawnedFunc(entity, gameObject, controller); } EventListener.PlayerSpawn(false); // Invoke custom event Object.Destroy(base.gameObject); }
private void Start() { ft = triggerItem.GetComponent <FollowTransform>(); prevAngle = transform.rotation.z; }
private FollowTransform getScreen() { if (screen == null) { screen = (FollowTransform) FindObjectOfType(typeof(FollowTransform)); } return screen; }