public void GrabWall(float horizontal) { bool?goRight = null; if (horizontal > 0) { goRight = true; } else if (horizontal < 0) { goRight = false; } if (Stamina <= 0 || isGrounded) { wallState = WallState.None; animator.SetBool("Wall", false); } else if (closestWall.HasValue && (goRight == isFacingRight) && rb2D.velocity.y <= 0) { rb2D.velocity = new Vector2(0, -slidingVelocity); wallState = WallState.Slide; Stamina -= wallSlideStatmina * Time.deltaTime; animator.SetBool("Wall", true); } else { wallState = WallState.None; animator.SetBool("Wall", false); animator.SetBool("Wall Jump Ready", false); } }
public CellTemplate(ShipPiece shipPiece, int cellState) { this.shipPiece = shipPiece; this.cellState = cellState; wallState = 0; }
public CellTemplate(ShipPiece shipPiece) { this.shipPiece = shipPiece; cellState = 0; wallState = 0; }
public CellTemplate(ShipPiece shipPiece, int cellState, WallState wallState) { this.shipPiece = shipPiece; this.cellState = cellState; this.wallState = wallState; }
// Start is called before the first frame update void Start() { timeRemaining = totalDurationSecs; maxSliderValue = GetComponent <Slider>().maxValue; wallState = FindObjectOfType <WallState>(); sceneLoader = FindObjectOfType <SceneLoader>(); }
void Awake() { tr = GetComponent <Transform>(); ri = GetComponent <Rigidbody2D>(); state = GetComponent <WallState>(); }
/// 상태에 따라서 벽이 움직이게 하는 함수 private void Act() { switch (_state) { case WallState.Idle: _currentTime += Time.deltaTime; if (_currentTime >= _waitTime) { NextTo(); _index += _indexDir; _trigger = true; _state = WallState.Move; _currentTime = 0f; } break; case WallState.Move: if (_trigger) { StartCoroutine("MoveTo"); _trigger = false; } break; } }
private void Update() { if (cState != CollisionState.WALL) { return; } _curVelocity = rb.velocity; if (Mathf.Abs(_dir.x) > 0f) { wState = UnityEngine.Input.GetKey(KeyCode.LeftShift) ? WallState.GRAB : WallState.SLIDE; } else { wState = WallState.NONE; } OnWall.Raise(wState); switch (wState) { case WallState.NONE: break; case WallState.GRAB: WallGrab(); break; case WallState.SLIDE: WallSlide(); break; } }
/// <summary> /// Apply the border of the given shape (where neighboring entries have opposite values) to the maze. /// The corresponding walls are switched from WS_MAYBE to WS_OUTLINE. /// </summary> private void FixOutline(OutlineShape.InsideShapeDelegate shapeTest, WallState wallState) { for (int x = 0; x < xSize; x++) { for (int y1 = 0, y2 = 1; y2 < ySize; y1++, y2++) { bool b1 = shapeTest(x, y1), b2 = shapeTest(x, y2); bool bothReserved = (this[x, y1].isReserved && this[x, y2].isReserved); if (b1 != b2 && !bothReserved && this[x, y1][WallPosition.WP_S] == WallState.WS_MAYBE) { this[x, y1][WallPosition.WP_S] = wallState; this[x, y2][WallPosition.WP_N] = wallState; } } } for (int y = 0; y < ySize; y++) { for (int x1 = 0, x2 = 1; x2 < xSize; x1++, x2++) { bool b1 = shapeTest(x1, y), b2 = shapeTest(x2, y); bool bothReserved = (this[x1, y].isReserved && this[x2, y].isReserved); if (b1 != b2 && !bothReserved && this[x1, y][WallPosition.WP_E] == WallState.WS_MAYBE) { this[x1, y][WallPosition.WP_E] = wallState; this[x2, y][WallPosition.WP_W] = wallState; } } } }
public void update() { if (wallState == WallState.Activating) { if (indicator.CurrentSpriteSheetFrameX == 29 && indicator.CurrentSpriteSheetFrameY == 1) { // Bumper Texture = activeTexture; wallState = WallState.Active; // Indicator indicator.SetTextureSpriteSheet(activeIndicatorTexture, 24, 198); indicator.SetTextureSpriteAnimationFrames( 0, 0, 17, 1, 3, SpriteSheetAnimationMode.AnimateForward); } } else if (wallState == WallState.Deactivating) { if (indicator.CurrentSpriteSheetFrameX == 13 && indicator.CurrentSpriteSheetFrameY == 0) { Texture = inactiveTexture; wallState = WallState.Inactive; } } }
private void GenerateWall(int x, int y, WallState state, RoomState room, RoomFacing facing, bool isExterior) { room.wallStates[facing] = state; if (state == WallState.None) { return; } var rotation = facing == RoomFacing.East || facing == RoomFacing.West ? Quaternion.Euler(0, 90, 0) : Quaternion.identity; var prefab = state == WallState.Solid ? solidWallPrefab : openWallPrefab; var offset = RoomFacingUtil.GetOffset(facing); var position = new Vector3(x * unitWorldSize, 0, y * unitWorldSize) + (new Vector3(offset.x, 0, offset.y) * (unitWorldSize / 2)); var wall = GameObject.Instantiate(prefab, position, rotation, startingRoomAnchor.transform); var blocker = wall.GetComponent <MotorBlocker>(); if (blocker != null) { motorController.AddBlocker(blocker); } var dimmer = wall.GetComponent <MeshDimmer>(); if (dimmer != null) { dimmer.Init(wallDimSpeed, wallDimLevel, room.neverDim || facing == RoomFacing.East || facing == RoomFacing.West || (isExterior && facing == RoomFacing.North)); } }
internal override bool LeftMouseButtonReleased(IGameViewport viewport, MessageMouseArgs args) { MouseMoved(viewport, args); if (WallState == WallState.StartPoint) { WallState = WallState.EndPoint; Result.flags |= PickerResultFlags.PRF_HAS_LOCATION; } else if (WallState == WallState.EndPoint) { var mouseLoc = GameViews.Primary.ScreenToTile(args.X, args.Y); var mouseLocTrim = GameSystems.Location.TrimToLength(Result.location, mouseLoc, Picker.trimmedRangeInches); _wallEndPoint = mouseLocTrim; return(FinalizePicker()); } else if (WallState == WallState.CenterPoint) { WallState = WallState.Radius; } else if (WallState == WallState.Radius) { return(FinalizePicker()); } return(true); }
public override void OnInspectorGUI() { Wall wall = this.target as Wall; WallState state = wall.state; state = (WallState)EditorGUILayout.EnumPopup("Wall State", state); if (wall.state != state) { wall.Init(); wall.state = state; if (state == WallState.Broken) { wall.Broke(); } if (state == WallState.Normal) { wall.Normal(); } if (state == WallState.Invincible) { wall.UnBroken(); } } }
private bool MakeRoute(MazeNode node, MazeNode destination, WallState comeFrom, ref Stack <MazeNode> route) { var neighbours = MazeGenerator.GetOpenNeighbours(node.NodePosition, _maze, _mazeWidth, _mazeHeight); if (node.NodePosition.X == destination.NodePosition.X && node.NodePosition.Y == destination.NodePosition.Y) { return(true); } if (neighbours.Count() > 1 || neighbours[0].SharedWall != comeFrom) { foreach (var neighbour in neighbours) { if (neighbour.SharedWall != comeFrom) { var nextnode = _maze[neighbour.Position.X, neighbour.Position.Y]; route.Push(nextnode); if (MakeRoute(nextnode, destination, MazeGenerator.GetOppositeWall(neighbour.SharedWall), ref route)) { return(true); } } } } route.Pop(); return(false); }
public void GrabWall(float horizontal) { bool?goRight = null; if (horizontal > 0) { goRight = true; } else if (horizontal < 0) { goRight = false; } if (Stamina <= 0 || (isGrounded && rb2D.velocity.y <= 0)) { wallState = WallState.None; SetBool("Wall", false); } else if (closestWall.HasValue /*&& (goRight == isFacingRight) && rb2D.velocity.y <= 0*/) { //rb2D.velocity = new Vector2(0, -slidingVelocity); if (wallState == WallState.None && rb2D.velocity.y <= 0 && (goRight == isFacingRight)) { isWallRight = goRight; elapsed = 0; rb2D.velocity = new Vector2(0, 0); wallState = WallState.Slide; SetBool("Wall", true); } else if (rb2D.velocity.y > 0 && (goRight == isFacingRight)) { // Debug.Log("goRight: " + goRight + "isFacingRight: " + isFacingRight); isWallRight = goRight; if (wallState == WallState.None) { elapsed = 0; } wallState = WallState.upSlide; } else if (wallState == WallState.upSlide && rb2D.velocity.y <= 0) { SetBool("Wall", true); wallState = WallState.Slide; } if (goRight == null) { elapsed = 0; } // Stamina -= wallSlideStatmina * Time.deltaTime; } else { wallState = WallState.None; SetBool("Wall", false); } }
void Update() { if (Input.GetKeyUp(KeyCode.A)) { WallState = (WallState == WallState.Hide ? WallState.Show : WallState.Hide); } }
public Vector2Int GetRandomNavigateableCellPos(out bool success, WallState requireWalls = WallState.None) { ShipPiece piece = shipPieces[Random.Range(0, shipPieces.Count)]; Vector2Int pos = piece.GetRandomWalkableCellPos(out success, requireWalls); return(pos); }
public Tile(Vector2 location, WallState state, int wall_roation,Texture2D wall) : base(wall, new Vector2(64,64)) { this.state = state; this.location = location; rotation = wall_roation * 90; }
public void Reset() { isInvincible = false; life = totalLife; state = WallState.Normal; UpdateColor(); UpdateIcon(); }
public void Invincible() { isInvincible = true; state = WallState.Invincible; level++; UpdateColor(); UpdateIcon(); }
public Cell(int x, int y) { position = new Vector2Int(x, y); walls = WallState.ALL; IsPath = false; this.isTrace = false; this.isSpecial = false; }
public CellData() { walls = new WallState[(int)Direction.Count]; for (uint i = 0; i < walls.Length; ++i) { walls[i] = WallState.Empty; } }
public void OnWallEvent(WallState state) { if (wState == state) { return; } wState = state; //Debug.Log($"Wall State: {wState}"); }
//****************** transform functions ************************* private void Transform_StandbyToWall(FSMState states, GameObject wall) { states.SetCurState(State.stand_by); Destroy(states.gameObject.GetComponent <StandbyState>()); states.gameObject.AddComponent <WallState>(); WallState wallstate = states.gameObject.GetComponent <WallState>(); wallstate.SetWall(wall); }
/** for Editor**/ public void UnBroken() { state = WallState.Invincible; Color32 defaultRGB = levels[(level + 1) % 5]; render.color = new Color32(defaultRGB.r, defaultRGB.g, defaultRGB.b, 255); if (icon != null) { icon.color = render.color; } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { WallState wall = other.GetComponent <WallState>(); if (wall.getLegs() == other) { wall.SetInWall(true); } } }
protected bool CanDestroyWall(WallState currTile, WallState targetTile) { if (currTile == WallState.None || currTile == WallState.Broken ) { if (targetTile == WallState.Sealed || targetTile == WallState.Breaking) { return true; } } return false; }
public void remove() { wallState = WallState.Dead; Visible = false; RemoveFromAutoDrawSet(); Velocity = Vector2.Zero; indicator.Visible = false; indicator.RemoveFromAutoDrawSet(); indicator.Velocity = Vector2.Zero; }
/** for Editor**/ public void Broke() { life = 0; state = WallState.Broken; Color32 defaultRGB = render.color; render.color = new Color32(defaultRGB.r, defaultRGB.g, defaultRGB.b, 0); if (icon != null) { icon.color = render.color; } }
/** for Editor**/ public void Normal() { life = totalLife; state = WallState.Normal; Color32 defaultRGB = new Color32(255, 255, 255, 255); render.color = new Color32(defaultRGB.r, defaultRGB.g, defaultRGB.b, 255); if (icon != null) { icon.color = render.color; } }
public Tile(int r,int c) { Row = r; Col = c; WallAnimateTime = new float[] { 0 , 0 , 0 , 0 }; UpdateBound(); Texture = GraphicsAssets.Instance.MainSprite; LeftWall = WallState.None; RightWall = WallState.None; UpWall = WallState.None; DownWall = WallState.None; }
public void Init() { Transform[] children = this.GetComponentsInChildren <Transform>(true); foreach (var child in children) { if (child.name.Contains("Icon")) { icon = child.GetComponent <SpriteRenderer>(); } } state = WallState.Normal; render = this.gameObject.GetComponent <SpriteRenderer>(); }
public void OnCollisionEvent(CollisionState state) { if (cState == state) { return; } cState = state; if (cState != CollisionState.LEDGE && cState != CollisionState.WALL) { wState = WallState.NONE; } }
public override bool HitWithExplosion() { if (WallState == WallState.Destroyed) return false; switch(WallState) { case WallState.Whole: WallState = WallState.Demaged; SceneGenerator.DemolitonWall(Row / 2, Column / 2, Row / 2 + Row % 2, Column / 2 + Column % 2, 1); break; case WallState.Demaged: WallState = WallState.Destroyed; SceneGenerator.DemolitonWall(Row / 2, Column / 2, Row / 2 + Row % 2, Column / 2 + Column % 2, 2); break; default: break; } return true; }
public static bool HasWall(WallState state) { if (state == WallState.Sealed || state == WallState.Breaking) { return true; } return false; }
public static void GetBackWallPair(Tile currTile, Tile targetTile, Direction facingDirection, out WallState currWall, out WallState targetWall) { currWall = GetBackWallOf(currTile, facingDirection); targetWall = GetFrontWallOf(targetTile, facingDirection); }
public static bool IsBlocked(WallState[] walls,ObstacleType[] obstacles) { foreach (WallState wall in walls) { if (wall == WallState.Sealed || wall == WallState.Breaking) { return true; } } foreach (ObstacleType obstacle in obstacles) { if (obstacle == ObstacleType.Rock) { return true; } } return false; }
bool WallRun(Vector3 movement,CharacterState state) { if ((!canWallRun||!_canWallRun)&&photonView.isMine) return false; //if (isGrounded) return false; if (lastTimeOnWall + 1.0f > Time.time) { return false; } /*if (_rb.velocity.sqrMagnitude < 0.02f ) { if(characterState == CharacterState.WallRunning){ characterState = CharacterState.Jumping; lastTimeOnWall = Time.time; } return false; }*/ if (_rb.velocity.sqrMagnitude < 0.02f&&characterState == CharacterState.WallRunning) { characterState = CharacterState.Jumping; lastTimeOnWall = Time.time; return false; } if (characterState != CharacterState.DoubleJump&&characterState != CharacterState.Sprinting&&characterState != CharacterState.WallRunning) { return false; } //Debug.Log (characterState); RaycastHit leftH,rightH,frontH; bool leftW = Physics.Raycast (myTransform.position , (-1*myTransform.right).normalized ,out leftH, capsule.radius + 0.3f,wallRunLayers); bool rightW = Physics.Raycast (myTransform.position, (myTransform.right).normalized,out rightH, capsule.radius + 0.3f, wallRunLayers); bool frontW = Physics.Raycast (myTransform.position, myTransform.forward,out frontH, capsule.radius + 0.2f, wallRunLayers); Debug.DrawLine (myTransform.position , myTransform.position +(0.5f*myTransform.forward-myTransform.right).normalized *(capsule.radius + 0.2f)); Debug.DrawLine (myTransform.position, myTransform.position +(0.5f*myTransform.forward+myTransform.right).normalized *(capsule.radius + 0.2f)); //Debug.DrawLine (myTransform.position, // myTransform.forward); Vector3 tangVect = Vector3.zero; if(!animator.animator.IsInTransition(0) && !_rb.isKinematic) { if(leftW) { tangVect = Vector3.Cross(leftH.normal,Vector3.up); //tangVect = Vector3.Project(movement,tangVect).normalized; _rb.velocity = tangVect*wallRunSpeed + myTransform.up*wallRunSpeed/3; if(!(characterState == CharacterState.WallRunning)) { wallState =WallState.WallL; characterState = CharacterState.WallRunning; //animator.SetBool("WallRunL", true); StartCoroutine( WallRunCoolDown(WALL_TIME_SIDE)); // Exclude if not needed } if(state == CharacterState.Jumping) { _rb.velocity = myTransform.up*movement.y +leftH.normal*movement.y; StartCoroutine( WallJump(1f)); // Exclude if not needed } } else if(rightW) { tangVect = -Vector3.Cross(rightH.normal,Vector3.up); //tangVect = Vector3.Project(movement,tangVect).normalized; _rb.velocity = tangVect*wallRunSpeed + myTransform.up*wallRunSpeed/3; if(!(characterState == CharacterState.WallRunning)) { wallState =WallState.WallR; characterState = CharacterState.WallRunning; StartCoroutine( WallRunCoolDown(WALL_TIME_SIDE)); // Exclude if not needed } if(state == CharacterState.Jumping) { _rb.velocity = myTransform.up*movement.y +rightH.normal*movement.y; StartCoroutine( WallJump(1f)); // Exclude if not needed } } else if(frontW) { _rb.velocity = myTransform.up*wallRunSpeed/1.5f; tangVect = frontH.normal*-1; if(!(characterState == CharacterState.WallRunning)) { wallState =WallState.WallF; characterState = CharacterState.WallRunning; StartCoroutine( WallRunCoolDown(WALL_TIME_UP)); // Exclude if not needed } if(state == CharacterState.Jumping) { _rb.velocity =( myTransform.up+myTransform.forward*-1).normalized*movement.y; StartCoroutine( WallJump(1f)); // Exclude if not needed } }else{ if(characterState == CharacterState.WallRunning){ characterState = CharacterState.Jumping; lastTimeOnWall = Time.time; } } forwardRotation = tangVect*5; //Debug.DrawLine(myTransform.position,forwardRotation); //animator.WallAnimation(leftW,rightW,frontW); return leftW||rightW||frontW; } return false; }
public void SendCharacterState(int nextrpcState,int nextwallState) { wallState = (WallState)nextwallState; nextState =(CharacterState) nextrpcState; }
//end Movement Section //NetworkSection public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { // We own this player: send the others our data ServerHolder.WriteVectorToShort(stream,transform.position); stream.SendNext(transform.rotation.eulerAngles.y); ServerHolder.WriteVectorToShort(stream,aimRotation); stream.SendNext(characterState); //stream.SendNext(health); stream.SendNext(wallState); stream.SendNext(health); //stream.SendNext(isActive); //stream.SendNext(netIsGround); //stream.SendNext(animator.GetJump()); } else { // Network player, receive data correctPlayerPos = ServerHolder.ReadVectorFromShort(stream); correctPlayerRot = Quaternion.Euler(0,(float)stream.ReceiveNext(),0); this.aimRotation = ServerHolder.ReadVectorFromShort(stream); //Debug.Log(aimRotation); nextState = (CharacterState) stream.ReceiveNext(); //Debug.Log (characterState); //health=(float) stream.ReceiveNext(); wallState = (WallState) stream.ReceiveNext(); float newHealth =(float)stream.ReceiveNext(); if(!PhotonNetwork.isMasterClient){ health =newHealth; } //bool isActive =(bool)stream.ReceiveNext(); //isGrounded =(bool) stream.ReceiveNext(); //animator.ApllyJump((bool)stream.ReceiveNext()); //Debug.Log (wallState); } }