public void SetBuildInfo(BuildInfo info, TrapViewListWnd wnd, TrapState trapState, int ItemType = 1) { myParent = wnd; m_Info = info; m_ItemType = ItemType; m_TrapState = trapState; }
protected void Start() { currentState = TrapState.Active; reset = Instantiate(resetSign, gameObject.transform); reset.transform.position += new Vector3(0, 2, 0); reset.SetActive(false); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); Saw.transform.position = startPosition.transform.position; state = TrapState.Idle; }
public void OnTriggerEnter(Collider other) { if (m_State == TrapState.IDLE) { GameObject gO = other.gameObject; if (gO.CompareTag(ConstValues.PLAYER_TAG)) { //TODO: Kill Player PlayerController playerControl = gO.GetComponent <PlayerController>(); if (playerControl != null) { playerControl.OnDeath(); } m_State = TrapState.TRIGGERED; } else if (gO.CompareTag(ConstValues.AI_RUNNER_TAG)) { //TODO: Kill Runner AIRunnerBehaviour aiBehav = gO.GetComponent <AIRunnerBehaviour>(); if (aiBehav != null) { aiBehav.Kill(); } m_State = TrapState.TRIGGERED; } } }
void checkState() { switch (m_State) { case TrapState.ACTIVE: m_FireParticles.SetActive(true); m_Timer -= Time.deltaTime; if (m_Timer <= 0.0f) { m_FireParticles.SetActive(false); m_State = TrapState.RESETTING; } break; case TrapState.DISABLED: break; case TrapState.IDLE: break; case TrapState.RESETTING: m_Timer = m_ResetTimer; m_State = TrapState.IDLE; m_DetectedTimer = m_ResetTimer; break; case TrapState.TRIGGERED: m_State = TrapState.ACTIVE; break; } }
// Update is called once per frame void Update () { if (trapState == TrapState.Ready) { spring.distance = 0.25f; spring.enabled = true; trapBody.constraints = RigidbodyConstraints2D.FreezeAll; } if (trapState == TrapState.Falling || trapState == TrapState.Down) { spring.enabled = false; trapBody.constraints = RigidbodyConstraints2D.FreezeAll ^ RigidbodyConstraints2D.FreezePositionY; } // if (trapState == TrapState.Falling && trapBody.velocity.magnitude < 1e-2f) { // trapState = TrapState.Down; // } if (trapState == TrapState.Rising) { trapBody.constraints = RigidbodyConstraints2D.FreezeAll ^ RigidbodyConstraints2D.FreezePositionY; spring.distance = 0.25f; spring.enabled = true; if (trapBody.velocity.magnitude < 1e-2f && Vector2.Distance (spring.connectedBody.transform.TransformPoint(spring.connectedAnchor), trapBody.position) < 1f) { trapState = TrapState.Ready; } } }
// Use this for initialization void Start () { trapBody = this.transform.GetComponent<Rigidbody2D> (); trapState = TrapState.Ready; spring = this.transform.GetComponent<SpringJoint2D> (); spring.distance = 0.25f; spring.enabled = true; }
public void SetTrapState(TrapComponent comp, TrapState state) { SmartEntity smartEntity = (SmartEntity)comp.Entity; TrapViewComponent trapViewComp = smartEntity.TrapViewComp; TrapState currentState = comp.CurrentState; if (currentState != state) { comp.CurrentState = state; IState currentState2 = Service.Get <GameStateMachine>().CurrentState; if (TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState2)) { smartEntity.BuildingComp.BuildingTO.CurrentStorage = ((state == TrapState.Armed) ? 1 : 0); } Service.Get <TrapViewController>().UpdateTrapVisibility((SmartEntity)comp.Entity); switch (state) { case TrapState.Spent: Service.Get <EventManager>().SendEvent(EventId.TrapDisarmed, comp); break; case TrapState.Active: Service.Get <EventManager>().SendEvent(EventId.TrapTriggered, comp); break; case TrapState.Destroyed: comp.CurrentState = TrapState.Spent; Service.Get <EventManager>().SendEvent(EventId.TrapDestroyed, comp); break; } } Service.Get <TrapViewController>().SetTrapViewState(trapViewComp, state); }
public void OnTriggerEnter(Collider other) { if (m_State == TrapState.IDLE) { GameObject gO = other.gameObject; if (gO.CompareTag(ConstValues.PLAYER_TAG)) { //TODO: Kill Player PlayerController playerControl = gO.GetComponent<PlayerController>(); if (playerControl != null) { playerControl.OnDeath(); } m_State = TrapState.TRIGGERED; } else if (gO.CompareTag(ConstValues.AI_RUNNER_TAG)) { //TODO: Kill Runner AIRunnerBehaviour aiBehav = gO.GetComponent<AIRunnerBehaviour>(); if (aiBehav != null) { aiBehav.Kill(); } m_State = TrapState.TRIGGERED; } } }
// Update is called once per frame void Update() { if (trapState == TrapState.Ready) { spring.distance = 0.25f; spring.enabled = true; trapBody.constraints = RigidbodyConstraints2D.FreezeAll; } if (trapState == TrapState.Falling || trapState == TrapState.Down) { spring.enabled = false; trapBody.constraints = RigidbodyConstraints2D.FreezeAll ^ RigidbodyConstraints2D.FreezePositionY; } // if (trapState == TrapState.Falling && trapBody.velocity.magnitude < 1e-2f) { // trapState = TrapState.Down; // } if (trapState == TrapState.Rising) { trapBody.constraints = RigidbodyConstraints2D.FreezeAll ^ RigidbodyConstraints2D.FreezePositionY; spring.distance = 0.25f; spring.enabled = true; if (trapBody.velocity.magnitude < 1e-2f && Vector2.Distance(spring.connectedBody.transform.TransformPoint(spring.connectedAnchor), trapBody.position) < 1f) { trapState = TrapState.Ready; } } }
/// <summary> /// Меняет состояние ловушки с временной задержкой /// </summary> /// <returns></returns> IEnumerator ChangeState() { while (true) { if (state == TrapState.down) { state = TrapState.middle; _collider.enabled = false; if (light != null) { light.enabled = false; } } else if (state == TrapState.middle) { state = TrapState.up; _collider.enabled = true; if (light != null) { light.enabled = true; } } else { state = TrapState.down; _collider.enabled = false; if (light != null) { light.enabled = false; } } sr.sprite = sprites[(int)state]; yield return(new WaitForSecondsRealtime(1f)); } }
private void SetTrapState(TrapState value) { switch (value) { case TrapState.Open: trapOpen.SetActive(true); trapClosed.SetActive(false); m_trapCooldown = 0f; openAnimation.enabled = true; break; case TrapState.Closed: trapOpen.SetActive(false); trapClosed.SetActive(true); trapClosed.layer = LayerMask.NameToLayer("Robots"); m_trapCooldown = trapCooldown; closeAnimation.enabled = true; break; case TrapState.ClosedTrapped: trapOpen.SetActive(false); trapClosed.SetActive(true); trapClosed.layer = LayerMask.NameToLayer("Blocker"); closeAnimation.enabled = true; break; default: throw new ArgumentOutOfRangeException("value", value, null); } m_trapState = value; }
private void InitialzeStateManager() { _stateManager = new StateManager(_muffinAnimator); IdleState idle = new IdleState(_stateManager, transform); MoveState move = new MoveState(_stateManager, transform); TrapState trap = new TrapState(_stateManager, transform); DieState die = new DieState(_stateManager, transform); SpinState spin = new SpinState(_stateManager, transform); BlastState blast = new BlastState(_stateManager, transform); ChocoRushState chocoRush = new ChocoRushState(_stateManager, transform); PauseState pause = new PauseState(_stateManager, transform); _stateManager.AddCharacterState(idle); _stateManager.AddCharacterState(move); _stateManager.AddCharacterState(trap); _stateManager.AddCharacterState(die); _stateManager.AddCharacterState(spin); _stateManager.AddCharacterState(blast); _stateManager.AddCharacterState(chocoRush); _stateManager.AddCharacterState(pause); _stateManager.SetDefaultState("Pause"); }
// Use this for initialization void Start() { TriggerRange = transform.parent.GetComponent <GenericTrigger>(); startPosition = this.transform.position; player = GameObject.FindGameObjectWithTag("Player"); state = TrapState.Idle; }
void checkState() { switch (m_State) { case TrapState.ACTIVE: // Make Block Fall / Disappear //Debug.Log("PITFALLLLLL"); m_Parent.GetComponent <MeshRenderer>().enabled = false; m_Parent.GetComponent <BoxCollider>().enabled = false; m_State = TrapState.DISABLED; break; case TrapState.DISABLED: // Pitfall forever break; case TrapState.IDLE: break; case TrapState.RESETTING: m_Parent.GetComponent <MeshRenderer>().enabled = true; m_Parent.GetComponent <BoxCollider>().enabled = true; m_State = TrapState.IDLE; break; case TrapState.TRIGGERED: m_State = TrapState.ACTIVE; break; } }
public bool TriggerTrap(int[] explorerPosition) { if (Position[0] != explorerPosition[0] || Position[1] != explorerPosition[1]) { return(false); } if (PlayScene.Random.Next(1, 3) == 1) { #if DEBUG Main.InsertLog("Explorer: Agrrrr!!!"); #endif SoundController.PlaySound(PlayContentHolder.Instance.SoundRock); rock = new CModel(PlayContentHolder.Instance.ModelRock, new Vector3(Position[1] * 10 + 5, 36, Position[0] * 10 + 5)); _state = TrapState.Rock; _parent.Explorer.Shock(); timeline = 90; } else { #if DEBUG Main.InsertLog("Explorer: Aaaaa...."); #endif SoundController.PlaySound(PlayContentHolder.Instance.SoundPit); _state = TrapState.Hole; _parent.Floor.HideMesh(Position[0] * _parent.MazeSize + Position[1]); _parent.Explorer.Fall(); } return(true); }
public void TriggerTrap() { if (State == TrapState.Armed) { activationTime = Time.time; State = TrapState.Triggered; } }
public void AddTrapComponentsToEntity(Entity buildingEntity, BuildingTypeVO buildingType) { TrapTypeVO type = Service.Get <IDataController>().Get <TrapTypeVO>(buildingType.TrapUid); TrapState currentStorage = (TrapState)buildingEntity.Get <BuildingComponent>().BuildingTO.CurrentStorage; TrapComponent component = new TrapComponent(type, currentStorage); buildingEntity.Add(component); }
void OnCollisionEnter(Collision collision) { Debug.Log("WE HIT LAND!"); if (state == TrapState.Active) { state = TrapState.Reload; } }
public void RaiseTrap() { if (trapState == TrapState.Down) { Debug.Log("Raising trap"); trapState = TrapState.Rising; } }
void Awake() { _collider = GetComponent <BoxCollider2D>(); light = GetComponentInChildren <Light>(); sr = GetComponent <SpriteRenderer>(); state = TrapState.down; StartCoroutine(ChangeState()); }
protected void TryReset() { if (CanReset && ResetRequested && Time.time > activationTime + HoldAnimTime) { activationTime = Time.time; State = TrapState.Resetting; } }
public void DropTrap() { if (trapState == TrapState.Ready) { Debug.Log("Dropping trap"); trapState = TrapState.Falling; } }
private void TryFire() { if (Time.time > activationTime + TriggerDelay) { activationTime = Time.time; State = TrapState.Firing; } }
// Use this for initialization void Start() { trapBody = this.transform.GetComponent <Rigidbody2D> (); trapState = TrapState.Ready; spring = this.transform.GetComponent <SpringJoint2D> (); spring.distance = 0.25f; spring.enabled = true; }
protected override void OnDisable() { base.OnDisable(); state = TrapState.NormalState; enemiesInRange.Clear(); hasWaitedForAttackHitDelay = false; isWaitingForCooldown = false; currentEnemy = null; }
void OnTriggerEnter(Collider other) { Debug.Log("SawBlade Triggered!"); if (other.tag == "Player") { //Player is here, fire the Saw state = TrapState.Active; } }
void SetTrapGrounded() { trapParabola.enabled = false; //slimeAnim.SetBool("IsOnGround", true);//set the animator to do the ground animation slimeRB.velocity = Vector2.zero; //no sliding landed = true; //set the ice cream to armed audioManager.PlaySound(landSound); _stateOfTrap = TrapState.grounded; }
protected void TriggerComplete() { //No longer triggering state = TrapState.Idle; if (autoRearm) { Rearm(); } }
void Idle() { //Is the player nearby? if (TriggerRange.isTouchingPlayer) { //Yes, trigger the trap state = TrapState.Active; this.tag = "HurtBox"; } }
void OnTriggerExit(Collider other) { Debug.Log("SawBlade Exit"); if (other.tag == "Player") { //Player left, reset the trap //Saw.transform.position = startPosition.transform.position; state = TrapState.Reload; } }
/// <summary> /// 创建已召唤炮弹兵 /// </summary> private void CreateTrap(List <BuildInfo> BuildList, TrapState trapState) { if (trapState == TrapState.Exit) { m_canShengji = null; } if (BuildList == null || BuildList.Count == 0) { return; } if (MyHead.Parent == null) { NGUIUtil.DebugLog("ShipCanvasDialogWnd ListParent!!!"); return; } if (trapState == TrapState.CanNotSum) { CreateBanner(); } PdbbbItem pbbItem = null; int count = 0; for (int i = 0; i < BuildList.Count; i++) { if (count % 4 == 0) { pbbItem = null; GameObject go = NDLoad.LoadWndItem("PdbbbItem", MyHead.Parent.transform); pbbItem = go.GetComponent <PdbbbItem>(); } count++; if (pbbItem != null && pbbItem.MyHead.Table != null) { GameObject viewgo = NDLoad.LoadWndItem("TrapViewItem", pbbItem.MyHead.Table.transform); if (viewgo != null) { TrapViewItem item = viewgo.GetComponent <TrapViewItem>(); if (item != null) { item.SetBuildInfo(BuildList[i], this, trapState); if (null == m_canShengji && trapState == TrapState.Exit) { CanLevelResult LevResult = buildingM.GetLevelCanUP(BuildList[i]); if (LevResult == CanLevelResult.CanUp) { m_canShengji = item; } } } } } } }
public void SetTrapViewState(TrapViewComponent view, TrapState state) { if (view != null) { if (view.PendingStates.Count == 0) { view.Anim.SetInteger("trapAnimState", (int)state); } view.PendingStates.Add(state); this.RegisterObservers(); } }
void Reload() { if (transform.position == startPosition) { state = TrapState.Idle; this.tag = "Environment"; } else { transform.position = Vector3.MoveTowards(transform.position, startPosition, reloadSpeed * Time.deltaTime); } }
/// <summary> /// A method to determine what happens to the trap after an actor entered the TrapTile. /// </summary> /// <returns>The damage the trap deals or 0.</returns> public int Trigger() { if (_state == TrapState.On) { if ((_type & TrapType.OnlyOnce) == TrapType.OnlyOnce) { _state = TrapState.Disabled; // Trap was sprung and will be disabled } if ((_type & TrapType.Hidden) == TrapType.Hidden) { _type &= ~TrapType.Hidden; // Trap was hidden and now becomes visible } return _damage; } return 0; }
/// <summary> /// Update method for the trap. /// If the repeatTime passed since the last action the trap can again deal damage. /// </summary> /// <param name="gameTime"></param> public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (((_type & TrapType.Changing) == TrapType.Changing) && (_state != TrapState.Destroyed) && (_state != TrapState.NoDisplay) && (_state != TrapState.Disabled) && ((_type & TrapType.Hidden) != TrapType.Hidden)) { _elapsed += (uint)gameTime.ElapsedGameTime.Milliseconds; if (_elapsed > _repeatTime) { _elapsed = 0; if (_state == TrapState.Off) { _state = TrapState.On; } else _state = TrapState.Off; ((FloorTile)_parent).HandleEvent(false, Backend.Events.TrapActivate, coords); } } }
void checkState() { switch (m_State) { case TrapState.ACTIVE: // raise spikes updateSpikes(true); // timer for raising spikes then lowering spikes m_Timer -= Time.deltaTime; if (m_Timer <= 0.0f) { m_State = TrapState.DISABLED; m_Timer = m_ResetTimer; } break; case TrapState.DISABLED: updateSpikes(false); m_Timer -= Time.deltaTime; if (m_Timer <= 0.0f) { m_State = TrapState.RESETTING; } break; case TrapState.IDLE: // waiting for trigger break; case TrapState.RESETTING: m_Timer = m_ResetTimer; m_State = TrapState.IDLE; break; case TrapState.TRIGGERED: m_State = TrapState.ACTIVE; break; } }
void checkState() { switch (m_State) { case TrapState.ACTIVE: // Make Block Fall / Disappear //Debug.Log("PITFALLLLLL"); m_Parent.GetComponent<MeshRenderer>().enabled = false; m_Parent.GetComponent<BoxCollider>().enabled = false; m_State = TrapState.DISABLED; break; case TrapState.DISABLED: // Pitfall forever break; case TrapState.IDLE: break; case TrapState.RESETTING: m_Parent.GetComponent<MeshRenderer>().enabled = true; m_Parent.GetComponent<BoxCollider>().enabled = true; m_State = TrapState.IDLE; break; case TrapState.TRIGGERED: m_State = TrapState.ACTIVE; break; } }
public void ResetTraps() { m_State = TrapState.RESETTING; }
void OnCollisionEnter2D(Collision2D coll) { if (targets.ContainsKey(coll.gameObject)) { // Collided with target, need to see if target is enclosed EdgeCollider2D myCollider = gameObject.GetComponent<EdgeCollider2D> (); Collider2D otherCollider = coll.collider; if (myCollider.bounds.Contains (otherCollider.bounds.min) && myCollider.bounds.Contains (otherCollider.bounds.max)) { HashSet<System.Func<TrapManager, bool>> toRemove = new HashSet<System.Func<TrapManager, bool>> (); foreach (System.Func<TrapManager, bool> responder in targets[coll.gameObject]) { bool shouldRemove = responder.Invoke (this); if (shouldRemove) { toRemove.Add (responder); } } foreach (System.Func<TrapManager, bool> responder in toRemove) { targets[coll.gameObject].Remove (responder); } if (targets [coll.gameObject].Count == 0) { targets.Remove (coll.gameObject); } } } if (coll.gameObject.tag == "Ground") { if (trapState == TrapState.Falling) { trapState = TrapState.Down; } } }
public void RaiseTrap() { if (trapState == TrapState.Down) { Debug.Log ("Raising trap"); trapState = TrapState.Rising; } }
public void DropTrap () { if (trapState == TrapState.Ready) { Debug.Log ("Dropping trap"); trapState = TrapState.Falling; } }