private EnemyType type; //定义敌人的类型 #endregion Fields #region Constructors public Enemy(EnemyType type, int x, int y, DIRECTION direct) : base(x, y, GetLife(type), GetSpeed(type), GetPower(type), direct) { this.type = type; this.Width = 60; this.Height = 60; }
IEnumerator MoveNextStage(DIRECTION direction) { yield return new WaitForFixedUpdate (); //Define a posiçao no centro da proxima tela e move a camera Vector3 newPos = new Vector3 ((this.WorldPos.x * this.currentStage) + (this.WorldPos.x * (int)direction) , this.camera.transform.position.y, this.camera.transform.position.z); this.camera.transform.position = Vector3.MoveTowards (this.camera.transform.position, newPos, this.speedCamera * Time.deltaTime); //Confere a distancia para parar o movimento da camera. float currentDistance = Vector3.Distance (this.camera.transform.position, newPos); if (currentDistance > this.totalDistance/100) { StartCoroutine (MoveNextStage (direction)); } else { this.cameraMoving = false; this.ResetWorldPos(); this.currentStage += (int)direction; this.lightManager.SetCurrentStage(this.currentStage); // StopCoroutine(this.MoveNextStage(direction)); } }
public void setRotationTargets(DIRECTION[] targets) { mRotationAngles = new float[targets.Length + 1]; mRotationAngles[0] = transform.eulerAngles.z; mRotationRadius = Vector3.Distance(mRotationPoint, transform.position); for (int i = 0; i < targets.Length; i++) { switch (targets[i]) { case DIRECTION.EAST: mRotationAngles[i + 1] = 0.0f; break; case DIRECTION.NORTH: mRotationAngles[i + 1] = 90.0f; break; case DIRECTION.WEST: mRotationAngles[i + 1] = 180.0f; break; case DIRECTION.SOUTH: mRotationAngles[i + 1] = 270.0f; break; } } }
public Boss(int x, int y, int life, int speed, int power, DIRECTION direct) : base(x, y, life, speed, power, direct) { this.Width = 60;//坦克图的大小 this.Height = 60; }
void makeMove(float xToPlayer, float yToPlayer) { if (Mathf.Abs(xToPlayer) > Mathf.Abs(yToPlayer)) { if (xToPlayer > 0) { face = DIRECTION.RIGHT; moveRight(); } if (xToPlayer < 0) { face = DIRECTION.LEFT; moveLeft(); } } else { if (yToPlayer > 0) { face = DIRECTION.UP; moveUp(); } if (yToPlayer < 0) { face = DIRECTION.DOWN; moveDown(); } } }
// Executes the user action by updating the board representation public void SendUserAction(DIRECTION direction) { if (direction == DIRECTION.DOWN) { DownPressed(); } if (direction == DIRECTION.UP) { UpPressed(); } if (direction == DIRECTION.LEFT) { LeftPressed(); } if (direction == DIRECTION.RIGHT) { RightPressed(); } Reset(); if (BoardHelper.IsGameOver(board)) { showGameOver = true; } // only show AI help if AI is not playing else if(!AIplaying) { RunAIhelper(); } }
/// <summary> /// This methods adds an animation to the animation list. /// Animations are stored in a dual value map where the first /// key represents the direction the animation is going and /// the second is the name of ID of the animation. /// </summary> /// <param name="dir"></param> /// <param name="animID"></param> /// <param name="anim"></param> public void AddAnimation(DIRECTION dir, String animID, Animation anim) { if (anim == null) return; if (m_Animations == null) m_Animations = new Dictionary<DIRECTION, Dictionary<string, Animation>>(); //if (m_currentAnimation == null) // return; // Get the animation list for this direction. Dictionary<String, Animation> animsDict = null; if (m_Animations.ContainsKey(dir)) animsDict = m_Animations[dir]; if (animsDict == null) animsDict = new Dictionary<string, Animation>(); if (!animsDict.ContainsKey(animID)) { // If there is no animation for that key, then add it. animsDict.Add(animID, anim); } else { // Replace the animation at that id with the new animation. animsDict[animID] = anim; } if (m_Animations.ContainsKey(dir)) m_Animations[dir] = animsDict; else m_Animations.Add(dir, animsDict); }
public List<Vector3> GetPos(DIRECTION direction) { if (this._direction.ContainsKey (direction) == true) { return this._direction [direction]; } return new List<Vector3> (); }
public Pacman() { velocity = RADIUS; X = 7; Y = 5; Direction = DIRECTION.RIGHT; brush = new SolidBrush(Color.Yellow); }
// Use this for initialization void Start () { base.Start(); speed = 0.25f; player = GameObject.Find("Player").GetComponent<Player>(); face = DIRECTION.RIGHT; minDistance = 1f; touching = false; }
private void SetTotalDistance(DIRECTION direction) { Vector3 newPos = new Vector3 ((this.WorldPos.x * this.currentStage) + (this.WorldPos.x * (int)direction) , this.camera.transform.position.y, this.camera.transform.position.z); this.totalDistance = Vector3.Distance(this.camera.transform.position, newPos); this.cameraMoving = true; }
/** * Constructor creates a LatLongPoint with latitude and longitude in degrees (ONLY, must convert minutes) * relative to either N/S and E/W. The point is converted to Cartesian (x,y,z) 3d coordinates */ public LatLongPoint(double latitude, DIRECTION lat_dir, double longitude, DIRECTION lon_dir) { this.latitude = latitude; this.longitude = longitude; this.latitude_direction = lat_dir; this.longitude_direction = lon_dir; CalculatePhiAndTheta(); CalculateXYZ(); // convert lat/long to Cartesian (x, y, z) spherical coordinates }
public Member(int x, int y, int life, int speed,int power,DIRECTION direction) : base(x, y) { this.X = x; this.Y = y; this.direct = direction; this.speed = speed; this.power = power; this.life = life; }
private void _ConveyCommand(LinkedListNode<SnakeBody> last, DIRECTION direction) { var current = last; while (current.Previous != null) { var prev = current.Previous.Value; current.Value.Direction = prev.Direction; current = current.Previous; } }
/// <summary> /// Base constructor. Create the list of textures and add it to the list. Create the vector position and size. /// </summary> /// <param name="name">The name</param> /// <param name="texture">The first texture</param> public AnimateObject(string name, Texture2D texture) { this.name = name; this.size = new Vector2(); this.position = new Vector2(0.0f, 0.0f); this.textures = new List<Texture2D>(); this.textures.Add(texture); this.direction = DIRECTION.NONE; this.actualTexture = texture; }
private void UpdateDirection() { if (Input.GetKey(KeyCode.W)) { direction = DIRECTION.NORTH; } else if (Input.GetKey(KeyCode.D)) { direction = DIRECTION.EAST; } else if (Input.GetKey(KeyCode.S)) { direction = DIRECTION.SOUTH; } else if (Input.GetKey(KeyCode.A)) { direction = DIRECTION.WEST; } }
public MOVEOBSTACLETYPE checkNeighbor(Location location, DIRECTION direction) { MOVEOBSTACLETYPE moveTarget=MOVEOBSTACLETYPE.WALL; Location neighborLocation = getNeighborLocation(location,direction); if ((neighborLocation!=null) && (isSpace(neighborLocation))) { if (neighborLocation.getOccupants().Count==0) { moveTarget=MOVEOBSTACLETYPE.NONE; } else moveTarget=MOVEOBSTACLETYPE.AGENT; } return moveTarget; }
private static int getWrapAroundIndex(int idx, DIRECTION direction, int maxIndex) { if ( idx == 0 && direction == DIRECTION.BACK ) { return maxIndex; } else if ( idx == maxIndex && direction == DIRECTION.FORWARD ) { return 0; } else { return idx + (int)direction; } }
public static void Propagation(WaveField1D _wf1, ref WaveField1D _wf2, MODE _MODE = MODE.CPU, DIRECTION _DIRECTION = DIRECTION.FORWARD) { switch(_MODE) { case MODE.CPU: ClsNac.WaveOpticsCLR.Prop1D( _wf1.lambda, (int)_DIRECTION, _wf1.x, _wf1.y, _wf1.u, _wf2.x, _wf2.y, _wf2.u); break; case MODE.CUDA: PropFw1dCuda(_wf1, ref _wf2); break; } }
void Start() { this.posX = this.name.Substring (this.name.Length - 4, 2); this.posY = this.name.Substring (this.name.Length - 2, 2); int index_X = int.Parse (posX); int index_Y = int.Parse (posY); string addZeroX = (index_X <= 9) ? "0" : ""; string addZeroY = (index_Y <= 9) ? "0" : ""; GameObject upTile = GameObject.Find ("Ground_" + ((index_X + 1 <= 9) ? "0" : "") + (index_X + 1) + addZeroY + index_Y ); GameObject downTile = GameObject.Find ("Ground_" + addZeroX + ((index_X) - 1) + "" + addZeroY + index_Y ); GameObject rightTile = GameObject.Find ("Ground_" + addZeroX + index_X + ((index_Y + 1 <= 9) ? "0" : "") + (index_Y + 1)); GameObject leftTile = GameObject.Find ("Ground_" + addZeroX + index_X + addZeroY + (index_Y - 1)); bool goDirection1Seted = false; if (upTile.tag.Equals (Tags.ground)) { goDirection1 = DIRECTION.UP; goDirection1Seted = true; } if (rightTile.tag.Equals (Tags.ground)) { if(goDirection1Seted) goDirection2 = DIRECTION.RIGHT; else { goDirection1 = DIRECTION.RIGHT; goDirection1Seted = true; } } if (downTile.tag.Equals (Tags.ground)) { if(goDirection1Seted) goDirection2 = DIRECTION.DOWN; else { goDirection1 = DIRECTION.DOWN; goDirection1Seted = true; } } if (leftTile.tag.Equals (Tags.ground)) { goDirection2 = DIRECTION.LEFT; } }
public List<Vector3> GetPosList(Vector3 position, DIRECTION direction) { List<Vector3> calcList = new List<Vector3> (); List<Vector3> posList = this._data.GetPos (direction); for (int i = 0; i < posList.Count; i++) { if (i < this._tileList.Count) { if (this._tileList[i] != null) { calcList.Add (position + posList [i]); } } } return calcList; }
public bool SideCaseIsNotWall(DIRECTION dir, AnimateObject obj) { switch(dir) { case DIRECTION.DOWN: if (obj.GetCaseYSup(map.Tile_size) != -1) { if (map.Grid[obj.GetCaseYSup(map.Tile_size)][obj.GetAcutalCaseX(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.UP: if (obj.GetCaseYInf(map.Tile_size) != -1) { if (map.Grid[obj.GetCaseYInf(map.Tile_size) - 1][obj.GetAcutalCaseX(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.LEFT: if (obj.GetCaseXInf(map.Tile_size) != -1) { if (map.Grid[obj.GetAcutalCaseY(map.Tile_size)][obj.GetCaseXInf(map.Tile_size) - 1].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.RIGHT: if (obj.GetCaseXSup(map.Tile_size) != -1) { if (map.Grid[obj.GetAcutalCaseY(map.Tile_size)][obj.GetCaseXSup(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; } return true; }
public void scroll(DIRECTION dir) { switch (dir) { case DIRECTION.LEFT: { for (int i = 0; i < Constants.mMainGameScreen.DrawableEntities.Count;++i ) Constants.mMainGameScreen.DrawableEntities[i].mPosition = new Vector2(Constants.mMainGameScreen.DrawableEntities[i].mPosition.X+scrollSpeed, Constants.mMainGameScreen.DrawableEntities[i].mPosition.Y); } break; case DIRECTION.DOWN: { for (int i = 0; i < Constants.mMainGameScreen.DrawableEntities.Count; ++i) Constants.mMainGameScreen.DrawableEntities[i].mPosition = new Vector2(Constants.mMainGameScreen.DrawableEntities[i].mPosition.X, Constants.mMainGameScreen.DrawableEntities[i].mPosition.Y - scrollSpeed); } break; case DIRECTION.RIGHT: { for (int i = 0; i < Constants.mMainGameScreen.DrawableEntities.Count; ++i) Constants.mMainGameScreen.DrawableEntities[i].mPosition = new Vector2(Constants.mMainGameScreen.DrawableEntities[i].mPosition.X - scrollSpeed, Constants.mMainGameScreen.DrawableEntities[i].mPosition.Y); } break; case DIRECTION.UP: { for (int i = 0; i < Constants.mMainGameScreen.DrawableEntities.Count; ++i) Constants.mMainGameScreen.DrawableEntities[i].mPosition = new Vector2(Constants.mMainGameScreen.DrawableEntities[i].mPosition.X, Constants.mMainGameScreen.DrawableEntities[i].mPosition.Y + scrollSpeed); } break; default: { //do nothing } break; } }
/// <summary> /// Used to moove the object. It makes it moove in the actual direction, with the actual speed. /// </summary> public void MooveObject(Collision c) { if (!c.SideCaseIsNotWall(this.direction, this)) { this.direction = DIRECTION.NONE; } switch(this.direction) { case DIRECTION.DOWN: this.position.Y += this.speed; break; case DIRECTION.UP: this.position.Y -= this.speed; break; case DIRECTION.LEFT: this.position.X -= this.speed; break; case DIRECTION.RIGHT: this.position.X += this.speed; break; } }
public static GameObject CreateChild(GameObject _ObjectToSpawn, Transform _Parent, Vector3 _Location, DIRECTION _FacingDirection) { GameObject TempChildSpawner = Instantiate(_ObjectToSpawn, _Location, Quaternion.identity); TempChildSpawner.transform.position = _Location; print(TempChildSpawner.name + " Location: " + TempChildSpawner.transform.position); TempChildSpawner.transform.GetChild(0).GetComponent <SpawnChild>().SetDirection(_FacingDirection); return(TempChildSpawner); }
public void processAttack(DIRECTION direction) { Location playerLocation = Agents[Agents.Count-1].getLocation(); Location targetLocation = getNeighborLocation(playerLocation,direction); Agent target=targetLocation.getOccupants()[0]; targetLocation.removeOccupant(target); Agents.Remove(target); DisplayCode.destroyDisplayObject(target); userInterfaceHolder.GetComponent<UserInterfaceCode>().setMessageLine("You killed the "+target.getName()+"!"); //Debug.Log("player at "+playerLocation.getCoords()+" is attacking monster at "+targetLocation.getCoords()); }
IEnumerator KnockDownSequence(GameObject inflictor) { enemyState = PLAYERSTATE.KNOCKDOWN; yield return(new WaitForFixedUpdate()); //朝着即将来临攻击的方向 int dir = 1; if (inflictor != null) { dir = inflictor.transform.position.x > transform.position.x ? 1 : -1; } currentDirection = (DIRECTION)dir; playerAnimator.SetDirection(currentDirection); TurnToDir(currentDirection); //增加击退力 playerAnimator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } playerAnimator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //击中地面 playerAnimator.SetAnimatorTrigger("KnockDown_End"); GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); playerAnimator.SetAnimatorFloat("MovementSpeed", 0f); playerAnimator.ShowDustEffectLand(); enemyState = PLAYERSTATE.KNOCKDOWNGROUNDED; Move(Vector3.zero, 0f); //相机抖动 CameraShake camShake = Camera.main.GetComponent <CameraShake>(); if (camShake != null) { camShake.Shake(.3f); } //播放倒地扬起尘埃的特效 playerAnimator.ShowDustEffectLand(); //停止滑动 float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(new WaitForFixedUpdate()); } //倒地时间 Move(Vector3.zero, 0f); yield return(new WaitForSeconds(KnockdownTimeout)); //站立起来 enemyState = PLAYERSTATE.STANDUP; playerAnimator.SetAnimatorTrigger("StandUp"); Invoke("Ready", standUpTime); }
public static List <Tuple <PieceData, long> > GuestimateMatchingPiece(PieceData given, List <PieceData> possible, DIRECTION dir) { // no elements were passed if ((given == null) || (possible.Count == 0)) { Console.WriteLine("Problem while finding pieces!"); return(new List <Tuple <PieceData, long> >()); } // exactly one element left if (possible.Count == 1) { return(new List <Tuple <PieceData, long> >(new Tuple <PieceData, long>[] { new Tuple <PieceData, long>(possible[0], 0) })); } // more than one element left List <Tuple <PieceData, long> > differences = new List <Tuple <PieceData, long> >(); foreach (PieceData piece in possible) { long diff = 0; switch (dir) { case DIRECTION.NORTH: for (int x = 2; x < DATA_WIDTH - 2; x++) { for (int givenY = 0; givenY <= 4; givenY++) { if (given.GetImagePixel(x, givenY).Sum != 765) { for (int pieceY = 0; pieceY <= 4; pieceY++) { if (piece.GetImagePixel(x, DATA_HEIGHT - pieceY - 1).Sum != 765) { diff += ColorTupleRGB.GetQuadraticDifference(given.GetImagePixel(x, givenY), piece.GetImagePixel(x, DATA_HEIGHT - pieceY - 1)); break; } } break; } } } break; case DIRECTION.SOUTH: for (int x = 2; x < DATA_WIDTH - 2; x++) { for (int givenY = 0; givenY <= 4; givenY++) { if (given.GetImagePixel(x, DATA_HEIGHT - givenY - 1).Sum != 765) { for (int pieceY = 0; pieceY <= 4; pieceY++) { if (piece.GetImagePixel(x, pieceY).Sum != 765) { diff += ColorTupleRGB.GetQuadraticDifference(given.GetImagePixel(x, DATA_HEIGHT - givenY - 1), piece.GetImagePixel(x, pieceY)); break; } } break; } } } break; case DIRECTION.EAST: for (int y = 2; y < DATA_HEIGHT - 2; y++) { for (int givenX = 0; givenX <= 4; givenX++) { if (given.GetImagePixel(DATA_WIDTH - givenX - 1, y).Sum != 765) { for (int pieceX = 0; pieceX <= 4; pieceX++) { if (piece.GetImagePixel(pieceX, y).Sum != 765) { diff += ColorTupleRGB.GetQuadraticDifference(given.GetImagePixel(DATA_HEIGHT - givenX - 1, y), piece.GetImagePixel(pieceX, y)); break; } } break; } } } break; case DIRECTION.WEST: for (int y = 2; y < DATA_HEIGHT - 2; y++) { for (int givenX = 0; givenX <= 4; givenX++) { if (given.GetImagePixel(givenX, y).Sum != 765) { for (int pieceX = 0; pieceX <= 4; pieceX++) { if (piece.GetImagePixel(DATA_WIDTH - pieceX - 1, y).Sum != 765) { diff += ColorTupleRGB.GetQuadraticDifference(given.GetImagePixel(givenX, y), piece.GetImagePixel(DATA_HEIGHT - pieceX - 1, y)); break; } } break; } } } break; } differences.Add(new Tuple <PieceData, long>(piece, diff)); } Console.WriteLine("Guestimate from " + possible.Count + " items: " + string.Join(" , ", differences.Select(x => x.Item2 + ":" + x.Item1.Filename))); return(differences); }
public Location getNeighborLocation(Location startingLocation, DIRECTION direction) { int deltaX=0; int deltaY=0; Location requestedLocation=null; switch (direction) { case DIRECTION.UPLEFT : deltaX=-1; deltaY=1; //requestedLocation=Locations[(int)startingLocation.getCoords().x-1,(int)startingLocation.getCoords().y+1]; break; case DIRECTION.UP : deltaX=0; deltaY=1; //requestedLocation=Locations[(int)startingLocation.getCoords().x,(int)startingLocation.getCoords().y+1]; break; case DIRECTION.UPRIGHT : deltaX=1; deltaY=0; //requestedLocation=Locations[(int)startingLocation.getCoords().x+1,(int)startingLocation.getCoords().y]; break; case DIRECTION.DOWNLEFT : deltaX=-1; deltaY=0; //requestedLocation=Locations[(int)startingLocation.getCoords().x-1,(int)startingLocation.getCoords().y]; break; case DIRECTION.DOWN : deltaX=0; deltaY=-1; //requestedLocation=Locations[(int)startingLocation.getCoords().x,(int)startingLocation.getCoords().y-1]; break; case DIRECTION.DOWNRIGHT : deltaX=1; deltaY=-1; //requestedLocation=Locations[(int)startingLocation.getCoords().x+1,(int)startingLocation.getCoords().y-1]; break; } //checks to see if the neighbor location is out of range if ((startingLocation.getCoords().x+deltaX<levelSizeX && startingLocation.getCoords().x+deltaX>-1) && (startingLocation.getCoords().y+deltaY<levelSizeY) && (startingLocation.getCoords().y+deltaY>-1)) { requestedLocation=Locations[(int)startingLocation.getCoords().x+deltaX,(int)startingLocation.getCoords().y+deltaY]; } return requestedLocation; }
/// <summary> /// 朝向指定的方向 /// </summary> /// <param name="dir">指定的方向</param> public void TurnToDir(DIRECTION dir) { transform.rotation = Quaternion.LookRotation(Vector3.forward * -(int)dir); }
//init the map public void Init() { biggestX = biggestY = smallestY = smallestX = 0; numOfOpenedDoors = 0; generatedBossRoom = false; roomList = new List <GameObject>(); roomMap = new Dictionary <int, Dictionary <int, GameObject> >(); currID = 0; Global.Instance.bossIsDead = false; //if (!Global.Instance.player.GetComponent<NetworkIdentity>().isServer) //{ // Debug.Log("u not the host"); // return; //} if (!GenerateOnStart) { return; } //Debug.Log("RoomGenerator Start()"); //spawn at 0,0, so generate one at 0,0 GameObject room = Instantiate(defaultRoom, new Vector3(0, 0, zOffset), Quaternion.identity); room.transform.localScale.Set(scaleX, scaleY, 1); RoomScript roomScript = room.GetComponent <RoomScript>(); Dictionary <DIRECTION, bool> boolArray = new Dictionary <DIRECTION, bool>(); float incChance = 0.0f; for (DIRECTION i = DIRECTION.LEFT; i < DIRECTION.LEFT + 4; ++i) { boolArray[i] = false; if (!boolArray[i]) { boolArray[i] = UnityEngine.Random.value < (0.5f + incChance); if (boolArray[i]) { ++numOfOpenedDoors; incChance -= 0.2f; } else { incChance += 0.25f; } } } //Debug.Log("B4_CurrID: " + currID); roomScript.Set(currID, 0, 0, boolArray[DIRECTION.LEFT], boolArray[DIRECTION.RIGHT], boolArray[DIRECTION.UP], boolArray[DIRECTION.DOWN]); StoreRoom(currID, 0, 0, room); //Debug.Log("After_CurrID: " + currID); //Debug.Log("roomID" + room.GetComponent<RoomScript>().GetRoomID()); //NETWORK asdasd //RoomStruct temp = new RoomStruct(); //temp.room = room; //syncListRooomStruct.Add(temp); //NetworkServer.Spawn(room); PopulateRoomListMessage popRoomMsg = new PopulateRoomListMessage(); popRoomMsg.roomID = room.GetComponent <RoomScript>().GetRoomID(); popRoomMsg.gridX = 0; popRoomMsg.gridY = 0; popRoomMsg.roomPos = new Vector3(0, 0, zOffset); popRoomMsg.roomScale = room.transform.localScale; popRoomMsg.roomType = -1; popRoomMsg.isLeft = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.LEFT); popRoomMsg.isRight = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.RIGHT); popRoomMsg.isUp = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.UP); popRoomMsg.isDown = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.DOWN); popRoomMsg.isActive = true; popRoomMsg.isCompleted = false; roomDataList.Add(popRoomMsg); while (numOfOpenedDoors > 0) { DIRECTION[] dirList = new DIRECTION[4]; //check which door open for (int i = 0; i < roomList.Count; ++i) { GameObject daroom = roomList[i]; RoomScript daroomscript = daroom.GetComponent <RoomScript>(); for (DIRECTION j = DIRECTION.LEFT; j < DIRECTION.LEFT + 4; ++j) { if (daroomscript.GetHasTriggerBox(j) && !daroomscript.GetIsLocked(j)) { //open tat door GenerateRoom(i, j); } } } } Debug.Log("number of rooms: " + roomList.Count); //Increase the number of times entered game PlayerPrefs.SetInt(PREFTYPE.NUM_OF_ENTERGAME.ToString(), PlayerPrefs.GetInt(PREFTYPE.NUM_OF_ENTERGAME.ToString(), 0) + 1); //Debug.Log("LEFT: " + room.GetComponent<RoomScript>().GetIsLocked(DIRECTION.LEFT)); //Debug.Log("UP: " + room.GetComponent<RoomScript>().GetIsLocked(DIRECTION.UP)); //Debug.Log("RIGHT: " + room.GetComponent<RoomScript>().GetIsLocked(DIRECTION.RIGHT)); //Debug.Log("DOWN: " + room.GetComponent<RoomScript>().GetIsLocked(DIRECTION.DOWN)); }
public void CarStart(DIRECTION direction1, DIRECTION direction2) { StartCoroutine(CarMove(direction1, direction2)); }
public Tile GetTile(DIRECTION _tileDirection) { return(m_Tiles[_tileDirection]); }
public Scissor(GameObject gameObject) : base(gameObject) { animator = (Animator)gameObject.GetComponent("Animator"); _direction = DIRECTION.Left; speed = 10; }
//set a direction public void SetDirection(DIRECTION dir) { currentDirection = dir; }
public OffsetCoord GetNeighbor(DIRECTION direct) { return(CoordConvert.AxialToOffset(CoordConvert.OffsetToAxial(this).GetNeighbor((int)direct))); }
public List <KeyValuePair <int, int> > GetAttackPattern(DIRECTION _attackDirection) { return(m_Weapon.GetAttackDictionary()[_attackDirection]); }
public void GenerateRoom(int currRoomID, DIRECTION side) { if (DEBUG_ROOMGEN) { Debug.Log("Generating Room for " + side + " at " + currRoomID + " roomListSize: " + roomList.Count); } GameObject currentRoom = roomList[currRoomID]; Vector3 currPos = currentRoom.transform.position; RoomScript currRoomScript = currentRoom.GetComponent <RoomScript>(); DIRECTION forceTrueDir = this.GetOppositeDir(side); int newGridX = currRoomScript.GetGridX() + (side == DIRECTION.LEFT ? -1 : (side == DIRECTION.RIGHT ? 1 : 0)); int newGridY = currRoomScript.GetGridY() + (side == DIRECTION.DOWN ? -1 : (side == DIRECTION.UP ? 1 : 0)); if (roomMap.ContainsKey(newGridY)) { if (roomMap[newGridY].ContainsKey(newGridX)) { return; } } Dictionary <DIRECTION, RANDACTION> boolArray = new Dictionary <DIRECTION, RANDACTION>();//= GetDoorOpenBooleans(forceTrueDir, true); int numOfPotentialOpen = 0; boolArray[DIRECTION.NONE] = 0; boolArray[DIRECTION.LEFT] = IsNeighbourHaveUnlockedDoor(newGridX, newGridY, DIRECTION.LEFT); boolArray[DIRECTION.RIGHT] = IsNeighbourHaveUnlockedDoor(newGridX, newGridY, DIRECTION.RIGHT); boolArray[DIRECTION.UP] = IsNeighbourHaveUnlockedDoor(newGridX, newGridY, DIRECTION.UP); boolArray[DIRECTION.DOWN] = IsNeighbourHaveUnlockedDoor(newGridX, newGridY, DIRECTION.DOWN); List <DIRECTION> dirToOffTrigger = new List <DIRECTION>(); List <DIRECTION> openDoors = new List <DIRECTION>(); //pre calculate the chances to spawn doors foreach (KeyValuePair <DIRECTION, RANDACTION> pair in boolArray) { if (pair.Key == DIRECTION.NONE) { continue; } if (pair.Value == RANDACTION.MUSTOPEN) { //This side of the new room MUST open --numOfOpenedDoors; //connect the doors dirToOffTrigger.Add(pair.Key); openDoors.Add(pair.Key); } else if (pair.Value == RANDACTION.CANCHOOSE) { //THIS Side of the new room will undergo calculation ++numOfPotentialOpen; } else { if (DEBUG_ROOMGEN) { //lock this door Debug.Log("MustLock activated"); } } } //calculate the opened door chances based on current situation foreach (KeyValuePair <DIRECTION, RANDACTION> pair in boolArray) { if (pair.Value == RANDACTION.CANCHOOSE) { bool openDaDoor = UnityEngine.Random.value < (0.5f * Mathf.Log(1 + estTotalRooms - currID, estTotalRooms) + (1.0f / Mathf.Max(10.0f * (currID / (float)estTotalRooms), numOfOpenedDoors + numOfPotentialOpen))); if (openDaDoor) { openDoors.Add(pair.Key); ++numOfOpenedDoors; } } } GameObject room; float offsetX = (side == DIRECTION.LEFT ? -scaleX : (side == DIRECTION.RIGHT ? scaleX : 0)); float offsetY = (side == DIRECTION.DOWN ? -scaleY : (side == DIRECTION.UP ? scaleY : 0)); Vector3 tempRoomPos; int randIndex = -1; if (!generatedBossRoom) { //attempt to generate bossroom if (numOfOpenedDoors == 0 || 0.25f * ((currID + 1) / estTotalRooms) > UnityEngine.Random.value) { tempRoomPos = new Vector3(currPos.x + offsetX, currPos.y + offsetY, zOffset); room = Instantiate(bossRoom, tempRoomPos, Quaternion.identity); generatedBossRoom = true; //NetworkServer.Spawn(room); } else { randIndex = UnityEngine.Random.Range(0, randomRooms.Count - 1); tempRoomPos = new Vector3(currPos.x + offsetX, currPos.y + offsetY, zOffset); room = Instantiate(randomRooms[randIndex], tempRoomPos, Quaternion.identity); //here is network spawn the room for sync //NetworkServer.Spawn(room); } } else { tempRoomPos = new Vector3(currPos.x + offsetX, currPos.y + offsetY, zOffset); room = Instantiate(defaultRoom, tempRoomPos, Quaternion.identity); //NetworkServer.Spawn(room); } room.transform.localScale.Set(scaleX, scaleY, 1); RoomScript roomScript = room.GetComponent <RoomScript>(); roomScript.Set(currID, newGridX, newGridY, openDoors.Contains(DIRECTION.LEFT), openDoors.Contains(DIRECTION.RIGHT), openDoors.Contains(DIRECTION.UP), openDoors.Contains(DIRECTION.DOWN)); //here is network spawn the room for sync //foreach (DIRECTION dir in dirToOffTrigger) //{ // roomScript.OffTriggerBox(dir); // RoomScript neighbourRS = GetNeighbourRoomScript(newGridX, newGridY, dir); // DIRECTION oppoSide = GetOppositeDir(dir); // neighbourRS.OffTriggerBox(oppoSide); //} //StoreRoom(currID, newGridX, newGridY, room); //foreach (DIRECTION dir in dirToOffTrigger) //{ // roomScript.OffTriggerBox(dir); // RoomScript neighbourRS = GetNeighbourRoomScript(newGridX, newGridY, dir); // DIRECTION oppoSide = GetOppositeDir(dir); // neighbourRS.OffTriggerBox(oppoSide); //} StoreRoom(currID, newGridX, newGridY, room); room.SetActive(false); //RoomStruct temp = new RoomStruct(); //temp.room = room; //syncListRooomStruct.Add(temp); //NETWORK //NetworkServer.Spawn(room); PopulateRoomListMessage popRoomMsg = new PopulateRoomListMessage(); //Debug.Log(currID); popRoomMsg.roomID = room.GetComponent <RoomScript>().GetRoomID(); popRoomMsg.gridX = newGridX; popRoomMsg.gridY = newGridY; popRoomMsg.roomPos = tempRoomPos; popRoomMsg.roomScale = room.transform.localScale; popRoomMsg.roomType = randIndex; popRoomMsg.isLeft = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.LEFT); popRoomMsg.isRight = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.RIGHT); popRoomMsg.isUp = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.UP); popRoomMsg.isDown = room.GetComponent <RoomScript>().GetIsLocked(DIRECTION.DOWN); popRoomMsg.isActive = false; popRoomMsg.isCompleted = false; roomDataList.Add(popRoomMsg); }
//override useSkill protected override void UseSkill( ) { switch (state) { case GOD_HAND_STATE.UNUSE: //if player use skill enable hand object and reset timer and direction then set state to using if (Input.GetButtonDown(Parent.NumPlayer + buttonString) && Parent.IsPlayerOnGround) { state = GOD_HAND_STATE.USING; handObject.transform.position = transform.position; handObject.transform.parent = null; handObject.SetActive(true); actionTimer = 0.0f; direction = DIRECTION.NONE; } break; case GOD_HAND_STATE.USING: Parent.State = "SKILL_START"; //set direction first time if (direction == DIRECTION.NONE) { direction = Parent.IsPlayerFacingRight ? DIRECTION.RIGHT : DIRECTION.LEFT; } //disable player move Parent.SetMovement(false); //keep accumulation timer actionTimer += Time.deltaTime; //move the hand object rb.MovePosition(rb.position + (int)direction * velocity * Time.deltaTime); //if actionTimer>= action time set State to end and set direction if (actionTimer >= actionTime) { state = GOD_HAND_STATE.END; direction = (DIRECTION)((int)(direction) * -1); } break; //this state will switch by hand object if it grab an player case GOD_HAND_STATE.GRAB: Parent.State = "SKILL_TOUCH"; if (target != null) { //move hand object and target until it reach the position then set state to end rb.MovePosition(rb.position + velocity * (int)direction * Time.deltaTime); target.transform.position = rb.position; if (Parent.Rigidbody2D.Distance(target).distance <= minmusDistance) { state = GOD_HAND_STATE.END; } } break; case GOD_HAND_STATE.END: Parent.State = "SKILL_TOUCH"; rb.MovePosition(rb.position + velocity * (int)direction * Time.deltaTime); //if hand object back enter this if statement if (Parent.Rigidbody2D.Distance(col).distance <= minmusDistance) { Parent.State = "SKILL_END"; //make player move again Parent.SetMovement(true); //set state to unuse state = GOD_HAND_STATE.UNUSE; //reset direction direction = DIRECTION.NONE; //reset handobject parent and disable it handObject.transform.parent = this.transform; handObject.SetActive(false); //make skill enter cd ResetCoolDown( ); } break; } }
public void SetTile(DIRECTION _tileDirection, Tile _tile) { m_Tiles[_tileDirection] = _tile; }
IEnumerator updateGesture() { for (; ;) { // If the user is not touching the screen, do nothing if (!isReceivingUserTouchInput) { yield return(new WaitForSeconds(maxDelay)); continue; } // Calculate the current touch position in screen space Vector2 inputPos = new Vector2(); Vector2 screenPos = new Vector2(); Vector2 centerPos = new Vector2(); inputPos.x = Input.mousePosition.x; inputPos.y = Camera.main.pixelHeight - Input.mousePosition.y; screenPos = Camera.main.ScreenToWorldPoint(new Vector3(inputPos.x, inputPos.y, Camera.main.nearClipPlane)); // Debug.Log ("screen pos: " + screenPos); // We need the previous screen touch position and the current one prevPos = currPos; currPos = screenPos; // Get the vectors from the center of the screen var v1 = currPos - centerPos; var v2 = prevPos - centerPos; // Debug.Log ("v1: [" + v1 + "] && v2: [" + v2 + "]"); // Calculate sign (Cross product) and the dot product var sign = 0.0f; var dot = 0.0f; // If this was the first run, prevPos would be zero and it would give incorrect calculations, // just set the direction to CW and the dot to greater than one just to pass the first run // Debug.Log("prevPos: " + prevPos); // Debug.Log("currPos: " + currPos); if (prevPos == Vector2.zero) { sign = -1; dot = 1; } else { sign = Mathf.Sign(v1.x * v2.y - v1.y * v2.x); dot = Vector2.Dot(v1, v2); } // Debug.Log("dot product: " + dot + " | sign: " + sign); //Assign direction switch (currentDirection) { case DIRECTION.NULL: break; case DIRECTION.CW: // If this was still CW, the user is still gesturing in the correct direction. // Else, the user must've broken the gesture if (sign > 0) { Debug.Log("Breaking gesture 1"); breakGesture(); yield return(new WaitForSeconds(maxDelay)); continue; } break; case DIRECTION.CCW: // If this was still CCW, the user is still gesturing in the correct direction. // Else, the user must've broken the gesture if (sign < 0) { Debug.Log("Breaking gesture 2"); breakGesture(); yield return(new WaitForSeconds(maxDelay)); continue; } break; } // So far, the gesture is still moving in a proper direction, check the dot product for a break in gesture if (dot < 0.0f || dot > this.gestureRadius) { Debug.Log("Breaking gesture 3"); breakGesture(); yield return(new WaitForSeconds(maxDelay)); continue; } // If we reached here, its confirmed that we are moving with no breaks currentDirection = sign < 0 ? DIRECTION.CW : DIRECTION.CCW; _gestureState = GESTURE_STATE.STATE_MOVING; if (!didFireStartGestureAction) { startGesture(); } // Debug.Log("currentDirection: [" + currentDirection.ToString() + "] && gestureState: [" + gestureState.ToString() + "]"); yield return(new WaitForSeconds(maxDelay)); } }
public void Move(DIRECTION direction) { Move(this._position, direction); }
/// <summary> /// 被击倒 /// </summary> /// <param name="inflictor"></param> /// <returns></returns> public IEnumerator KnockDownSequence(GameObject inflictor) { playerState.SetState(PLAYERSTATE.KNOCKDOWN); playerAnimator.StopAllCoroutines(); yield return(new WaitForFixedUpdate()); //倒地方向朝攻击来源方向 int dir = inflictor.transform.position.x > transform.position.x ? 1 : -1; currentDirection = (DIRECTION)dir; TurnToDir(currentDirection); //更新玩家移动 PlayerMovement playerMovement = GetComponent <PlayerMovement>(); if (playerMovement != null) { playerMovement.CancelJump(); playerMovement.SetDirection(currentDirection); } //击倒的力 playerAnimator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } //往上 while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } //往下 playerAnimator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //击中地面 playerAnimator.SetAnimatorTrigger("KnockDown_End"); CameraShake camShake = Camera.main.GetComponent <CameraShake>(); if (camShake != null) { camShake.Shake(.3f); } playerAnimator.ShowDustEffectLand(); //播放音效 GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); //地面滑动 float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(null); } //倒地时间 SetVelocity(Vector3.zero); yield return(new WaitForSeconds(KnockdownTimeout)); //倒地站起来 playerAnimator.SetAnimatorTrigger("StandUp"); playerState.currentState = PLAYERSTATE.STANDUP; yield return(new WaitForSeconds(KnockdownStandUpTime)); playerState.currentState = PLAYERSTATE.IDLE; }
IEnumerator CarMove(DIRECTION direction1, DIRECTION direction2) { for (int i = 0; i < car.Length; i++) { car[i].SetActive(false); } string carPath1 = ""; string carPath2 = ""; switch (direction1) { case DIRECTION.DIRECTION_NORTH: carPath1 = "NorthPath"; itemBoxNorth.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_EAST: carPath1 = "EastPath"; itemBoxEast.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_SOUTH: carPath1 = "SouthPath"; itemBoxSouth.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_WEST: carPath1 = "WestPath"; itemBoxWest.GetComponent <BS_ItemBox>().MakeItemBox(); break; } switch (direction2) { case DIRECTION.DIRECTION_NORTH: carPath2 = "NorthPath"; itemBoxNorth.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_EAST: carPath2 = "EastPath"; itemBoxEast.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_SOUTH: carPath2 = "SouthPath"; itemBoxSouth.GetComponent <BS_ItemBox>().MakeItemBox(); break; case DIRECTION.DIRECTION_WEST: carPath2 = "WestPath"; itemBoxWest.GetComponent <BS_ItemBox>().MakeItemBox(); break; } car[(int)direction1].SetActive(true); car[(int)direction2].SetActive(true); car[(int)direction1].GetComponent <BS_Car>().MoveCar(moveTime, carPath1); car[(int)direction2].GetComponent <BS_Car>().MoveCar(moveTime, carPath2); StartCoroutine(ClacsonSound()); yield return(new WaitForSeconds(moveTime)); for (int i = 0; i < car.Length; i++) { car[i].transform.position = carStartPos[i]; car[i].SetActive(false); } }
public BlockPart(int row, int col, DIRECTION wallDirection) { WallDirection = wallDirection; Row = row; Col = col; }
private void walkAndAttackWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Random rnd = new Random(); while (true) { direction = (DIRECTION)(rnd.Next() % 4); int isNeedShot = rnd.Next() % 3000; if (isNeedShot < 1000) { TanksGame.ShootKeyDown(Keys.B); } switch (direction) { case DIRECTION.U: BackgroundImage = Properties.Resources.light_ctank_u; Point newUpLoc = new Point(Location.X, Location.Y - step); if (newUpLoc.Y <= 0) { break; } Location = newUpLoc; break; case DIRECTION.D: BackgroundImage = Properties.Resources.light_ctank_d; Point newDownLoc = new Point(Location.X, Location.Y + step); if (newDownLoc.Y >= 600) { break; } Location = newDownLoc; break; case DIRECTION.L: BackgroundImage = Properties.Resources.light_ctank_l; Point newLeftLoc = new Point(Location.X - step, Location.Y); if (newLeftLoc.X <= 0) { break; } Location = newLeftLoc; break; case DIRECTION.R: BackgroundImage = Properties.Resources.light_ctank_r; Point newRightLoc = new Point(Location.X + step, Location.Y); if (newRightLoc.X >= 1200) { break; } Location = newRightLoc; break; } Thread.Sleep(stepTimer); } }
public void SetPosition(Vector2 pos, DIRECTION direct) { _plTr.position = pos; _nowDirection = direct; DirectionUpdate(_nowDirection); }
// MoveEmission(Time.deltaTime); // emitSecondsElapsed += Time.deltaTime; // if (emitSecondsElapsed > emitSeconds) { // emitSecondsElapsed -= emitSeconds; // Emit(); // } public void Update(Pipe[][] pipes) { if (shouldDestroy) { // do nothing return; } var pos = coreObject.transform.position; float moveDistance = Time.deltaTime * emissionMoveSpeed; // Vector2 gridPos = Utilities.getGridLocation(pos + new Vector3(Utilities.tileSize/2, Utilities.tileSize/2)); Vector2 gridPos = Utilities.getGridLocation(pos); // Move forward switch (currentDirection) { case DIRECTION.LEFT: coreObject.transform.position = new Vector3(pos.x - moveDistance, Utilities.getLocationVector(gridPos, 0).y, pos.z); break; case DIRECTION.RIGHT: coreObject.transform.position = new Vector3(pos.x + moveDistance, Utilities.getLocationVector(gridPos, 0).y, pos.z); break; case DIRECTION.UP: coreObject.transform.position = new Vector3(Utilities.getLocationVector(gridPos, 0).x, pos.y + moveDistance, pos.z); break; case DIRECTION.DOWN: coreObject.transform.position = new Vector3(Utilities.getLocationVector(gridPos, 0).x, pos.y - moveDistance, pos.z); break; } // Check if out of bounds if (gridPos.y > limit.y - 1 || gridPos.y < 0 || gridPos.x > limit.x - 1 || gridPos.x < 0) { shouldDestroy = true; return; } TILE_TYPE currentTileType = Utilities.getGridType(gridPos, pipes); // Recenter and change direction if needed Vector3 centerOfGrid = Utilities.getLocationVector(gridPos, 0); bool isInCenterOfGrid = Utilities.pointIsInsideSphere(coreObject.transform.position, centerOfGrid, radiusDetectionSize); // dTxt.text = ":" + Mathf.Floor(coreObject.transform.position.x) + "," + Mathf.Floor(coreObject.transform.position.y) + ":" + Mathf.Floor(centerOfGrid.x) + "," + Mathf.Floor(centerOfGrid.y) + ":"; // dTxt.text = ":" + gridPos.x + "," + gridPos.y + ":" + isInCenterOfGrid; if (isInCenterOfGrid) { bool isMovingVertically = currentDirection == DIRECTION.UP || currentDirection == DIRECTION.DOWN; bool willMoveHorizontally = currentTileType == TILE_TYPE.LEFT_ARROW || currentTileType == TILE_TYPE.LEFT_ELBOW_LEFT || currentTileType == TILE_TYPE.RIGHT_ELBOW_LEFT || currentTileType == TILE_TYPE.RIGHT_ARROW || currentTileType == TILE_TYPE.LEFT_ELBOW_RIGHT || currentTileType == TILE_TYPE.RIGHT_ELBOW_RIGHT; bool willMoveVertically = currentTileType == TILE_TYPE.UP_ARROW || currentTileType == TILE_TYPE.LEFT_ELBOW_UP || currentTileType == TILE_TYPE.RIGHT_ELBOW_UP || currentTileType == TILE_TYPE.DOWN_ARROW || currentTileType == TILE_TYPE.LEFT_ELBOW_DOWN || currentTileType == TILE_TYPE.RIGHT_ELBOW_DOWN; if (isMovingVertically && willMoveHorizontally) { // Readjust y position // coreObject.transform.position = new Vector3(coreObject.transform.position.x, centerOfGrid.y, coreObject.transform.position.z); } if (!isMovingVertically && willMoveVertically) { // Readjust x position // coreObject.transform.position = new Vector3(centerOfGrid.x, coreObject.transform.position.y, coreObject.transform.position.z); } // Set Direction switch (currentTileType) { case TILE_TYPE.LEFT_ARROW: case TILE_TYPE.LEFT_ELBOW_LEFT: case TILE_TYPE.RIGHT_ELBOW_LEFT: currentDirection = DIRECTION.LEFT; break; case TILE_TYPE.RIGHT_ARROW: case TILE_TYPE.LEFT_ELBOW_RIGHT: case TILE_TYPE.RIGHT_ELBOW_RIGHT: currentDirection = DIRECTION.RIGHT; break; case TILE_TYPE.UP_ARROW: case TILE_TYPE.LEFT_ELBOW_UP: case TILE_TYPE.RIGHT_ELBOW_UP: currentDirection = DIRECTION.UP; break; case TILE_TYPE.DOWN_ARROW: case TILE_TYPE.LEFT_ELBOW_DOWN: case TILE_TYPE.RIGHT_ELBOW_DOWN: currentDirection = DIRECTION.DOWN; break; default: //shouldDestroy = true; break; } } }
//knockDown sequence public IEnumerator KnockDownSequence(GameObject inflictor) { playerState.SetState(UNITSTATE.KNOCKDOWN); animator.StopAllCoroutines(); yield return(new WaitForFixedUpdate()); //look towards the direction of the incoming attack int dir = inflictor.transform.position.x > transform.position.x ? 1 : -1; currentDirection = (DIRECTION)dir; TurnToDir(currentDirection); //update playermovement var pm = GetComponent <PlayerMovement>(); if (pm != null) { pm.CancelJump(); pm.SetDirection(currentDirection); } //add knockback force animator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } //going up... while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } //going down animator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //hit ground animator.SetAnimatorTrigger("KnockDown_End"); CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.3f); } animator.ShowDustEffectLand(); //sfx GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); //ground slide float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(null); } //knockDown Timeout SetVelocity(Vector3.zero); yield return(new WaitForSeconds(KnockdownTimeout)); //stand up animator.SetAnimatorTrigger("StandUp"); playerState.currentState = UNITSTATE.STANDUP; yield return(new WaitForSeconds(KnockdownStandUpTime)); playerState.currentState = UNITSTATE.IDLE; }
public void MoveCursor(DIRECTION direction) { }
public P1Player(int x, int y, int life, int speed, int power, DIRECTION direct) : base(x, y, life, speed, power, direct) { this.Width = 60; this.Height = 60; }
//knockDown sequence IEnumerator KnockDownSequence(GameObject inflictor) { enemyState = UNITSTATE.KNOCKDOWN; yield return(new WaitForFixedUpdate()); //look towards the direction of the incoming attack int dir = 1; if (inflictor != null) { dir = inflictor.transform.position.x > transform.position.x? 1 : -1; } currentDirection = (DIRECTION)dir; animator.SetDirection(currentDirection); TurnToDir(currentDirection); //add knockback force animator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } //going up... while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } //going down animator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //hit ground animator.SetAnimatorTrigger("KnockDown_End"); GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); animator.SetAnimatorFloat("MovementSpeed", 0f); animator.ShowDustEffectLand(); enemyState = UNITSTATE.KNOCKDOWNGROUNDED; Move(Vector3.zero, 0f); //cam shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.3f); } //dust effect animator.ShowDustEffectLand(); //stop sliding float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(new WaitForFixedUpdate()); } //knockDown Timeout Move(Vector3.zero, 0f); yield return(new WaitForSeconds(KnockdownTimeout)); //stand up enemyState = UNITSTATE.STANDUP; animator.SetAnimatorTrigger("StandUp"); Invoke("Ready", standUpTime); }
public void Move(Vector3 position, DIRECTION direction) { this._position = position; this._direction = direction; Vector3 pos = Vector3.zero; List<Vector3> blockList = this._data.GetPos (direction); for (int i = 0; i < blockList.Count; i++) { if (i < this._tileList.Count) { if (this._tileList[i] != null) { pos = position + blockList [i]; this._tileList [i].SetPosition (pos); } } } }
public abstract void DoScroll(DIRECTION direction);
public void Initialize(BlockData data, Color color) { Initialize(); this._data = data; CreateTile(color); this._position = GameObjectManager.Instance.GetStartPosition(); this._direction = DIRECTION.UP; Move(this._position, this._direction); }
public void ChangeDirection(DIRECTION direction) { d = direction; }
public void moveActiveAgent(DIRECTION direction) { Agent activeAgent = Agents[Agents.Count-1]; activeAgent.MoveTo(getNeighborLocation(activeAgent.getLocation(), direction)); }
public void SetDirection(DIRECTION _direction) { //transform.LookAt(transform.position + FacingDirection(_direction)); Dir = _direction; }
public void Execute(ref DIRECTION currentDirection) { // animator.PlayAnimation("Idle"+ currentDirection); }
public void changeDirection(DIRECTION direction) { gameObject.transform.Rotate(new Vector3(0, ((int)direction - 1) * 90, 0)); }