protected void Start() { TurnOrder.RegisterUnit(this); m_Projectile = GetComponent <UnitProjectile>(); float rotation = transform.rotation.eulerAngles.y; while (rotation < 0) { rotation += 360; } while (rotation > 360) { rotation -= 360; } if ((rotation <= 45 && rotation >= 0) || (rotation <= 360 && rotation > 315)) { m_MovingDirection = E_Direction.North; } else if ((rotation > 45 && rotation <= 135)) { m_MovingDirection = E_Direction.East; } else if ((rotation > 135 && rotation <= 225)) { m_MovingDirection = E_Direction.South; } else { m_MovingDirection = E_Direction.West; } }
public void MoveHorizontal(bool isGoingRight) { if (m_animator.GetBool("Dash") && !canMove) { return; } m_animator.SetBool("Move", true); if (!isGoingRight) { if (m_previousDirection != E_Direction.LEFT) { m_previousDirection = E_Direction.LEFT; transform.Rotate(0, 180, 0); } if (canGoForward) { m_direction.x = m_speed; } } else if (isGoingRight) { if (m_previousDirection != E_Direction.RIGHT) { m_previousDirection = E_Direction.RIGHT; transform.Rotate(0, 180, 0); } if (canGoForward) { m_direction.x = m_speed; } } transform.Translate(m_direction * Time.deltaTime); }
void RandomlyCreateWall(int x, int z, Transform[] tilePrefab, E_Direction wallDir, List <Transform> targetList) { Transform wall = RandomlyCreateTile(x, z, tilePrefab); switch (wallDir) { case E_Direction.Down: wall.Rotate(new Vector3(0, 270f, 0)); break; case E_Direction.Left: break; case E_Direction.Right: wall.Rotate(new Vector3(0, 180f, 0)); break; case E_Direction.Up: wall.Rotate(new Vector3(0, 90f, 0)); break; default: break; } targetList.Add(wall); }
public Agent GetNearestAliveEnemy(Agent agent, E_Direction direction, float maxRadius) { Vector3 dir; if (direction == E_Direction.Forward) { dir = agent.Forward; } else if (direction == E_Direction.Backward) { dir = -agent.Forward; } else if (direction == E_Direction.Right) { dir = agent.Right; } else if (direction == E_Direction.Left) { dir = -agent.Right; } else { return(null); } return(GetNearestAliveEnemy(agent.Position + dir, agent.Position + dir * 3, maxRadius, agent)); }
public void StartInputMode(UnitPlayer _Player) { m_MovingDirection = E_Direction.None; m_DirectionBuffer = E_Direction.None; m_SwipeStartPosition = new Vector2(); m_HasStartedSwipe = false; }
public I_Tile GetNeighbour(E_Direction _Direction) { I_Tile tile; m_Neighbours.TryGetValue(_Direction, out tile); return(tile); }
private void SetImagesRotations(E_Direction _Direction) { int defenseFillOrigin = 0; int weaknessFillOrigin = 0; if (_Direction == E_Direction.North) { defenseFillOrigin = 0; weaknessFillOrigin = 2; } else if (_Direction == E_Direction.South) { defenseFillOrigin = 2; weaknessFillOrigin = 0; } else if (_Direction == E_Direction.East) { defenseFillOrigin = 3; weaknessFillOrigin = 1; } else if (_Direction == E_Direction.West) { defenseFillOrigin = 1; weaknessFillOrigin = 3; } m_DefenseCircleUp.fillOrigin = defenseFillOrigin; m_DefenseCircleDown.fillOrigin = defenseFillOrigin; m_WeaknessCircleUp.fillOrigin = weaknessFillOrigin; m_WeaknessCircleDown.fillOrigin = weaknessFillOrigin; }
public S_Snake(E_Direction a_start_direction, params S_Location[] a_start_locations) { // В начале игры змейка выстраивается в линию // На данный момент решено что число начальных блоков строго равно четырем, поэтому этот код не обрабатывается через цикл, а кол-во не вынесено константным значением m_head = new S_Head(a_start_locations[0], a_start_direction); S_Body_Block BB1 = new S_Body_Block(a_start_locations[1], a_start_direction, m_head); S_Body_Block BB2 = new S_Body_Block(a_start_locations[2], a_start_direction, BB1); m_tail = new S_Tail(a_start_locations[3], a_start_direction, BB2); }
public void SetWeakness(E_Direction _Direction, float _WeaknessValue, float _WeaknessSpeed, float _TimeAfterWhichWeaknessDecrease) { SetImagesRotations(_Direction); SetImagesFillPercent(_WeaknessValue); m_WeaknessValue = _WeaknessValue; m_WeaknessSpeed = _WeaknessSpeed; m_TimeAfterWhichWeaknessDecrease = _TimeAfterWhichWeaknessDecrease; m_HasShownWeakness = true; m_WeaknessDirection = _Direction; }
private void VerticalAxisMove(float yAxis) { if (m_enableMoving) { Vector3 pos = transform.position; if (yAxis < 0) { m_verticalDir = E_Direction.UP; } else if (yAxis > 0) { m_verticalDir = E_Direction.DOWN; } } }
public E_TileAction Move(E_Direction _Direction) { E_TileAction action = E_TileAction.None; I_Tile tile = m_Tile.GetNeighbour(_Direction); if (tile != null) { m_IsMoving = true; OnTileExit(m_Tile); m_Tile = tile; OnTileEnter(m_Tile); m_Tile.OnUnitEnter(this); } return(action); }
protected void Roll(E_Direction direction, uLink.NetworkMessageInfo info) { #if !DEADZONE_CLIENT if (Owner.IsServer) { ServerAnticheat.ReportRoll(Owner.NetworkView.owner, direction, info); Owner.NetworkView.RPC("Roll", uLink.RPCMode.OthersExceptOwner, direction); } #endif AgentActionRoll a = AgentActionFactory.Create(AgentActionFactory.E_Type.Roll) as AgentActionRoll; a.Direction = direction; Owner.BlackBoard.ActionAdd(a); }
private bool if_Normal_Moving(S_Location a_location, E_Direction a_direction) { bool f_result = true; // Сперва, проверяем не уткнулась ли она в стены switch (a_direction) { case E_Direction.Left: if (a_location.X < m_Board.Left_Bound) { f_result = false; } break; case E_Direction.Right: if (a_location.X > m_Board.Right_Bound) { f_result = false; } break; case E_Direction.Up: if (a_location.Y < m_Board.Up_bound) { f_result = false; } break; case E_Direction.Down: if (a_location.Y > m_Board.Low_bound) { f_result = false; } break; } if (!f_result) { return(f_result); } // Проверим не уткнулась ли она в себя или в свои отходы if (m_Board.Return_Point(a_location).Is_Free == false) { f_result = false; } return(f_result); } //Проверка, не наткнулась ли змея на препятствия
public override string GetRollAnim(E_Direction moveType) { switch (moveType) { case E_Direction.Forward: return("RollF"); case E_Direction.Backward: return("RollB"); case E_Direction.Left: return("RollL"); case E_Direction.Right: return("RollR"); } return("Idle"); }
// Update is called once per frame void Update() { if (myPlayerController.currentSpeed.magnitude > 1) { frameCounter += Mathf.RoundToInt(myPlayerController.currentSpeed.magnitude); } else { frameCounter = 0; } playerDirection = Utility.DetermineDirection(myPlayerController.DirectionVector); if (playerDirection != E_Direction.Undetermined) { mySpriteRenderer.sprite = playerSprites[(int)playerDirection][(frameCounter / 50) % 4]; } }
public void TurnToward(E_Direction _Direction) { if (_Direction == E_Direction.North) { transform.forward = Vector3.forward; } else if (_Direction == E_Direction.South) { transform.forward = -Vector3.forward; } else if (_Direction == E_Direction.East) { transform.forward = Vector3.right; } else if (_Direction == E_Direction.West) { transform.forward = -Vector3.right; } }
private void Move(float xAxis) { Rotate(xAxis); if (m_enableMoving) { Vector3 pos = transform.position; if (xAxis > 0) { pos.x += 1 * m_character.Speed * Time.deltaTime; m_horizontalDir = E_Direction.RIGHT; } else { pos.x += -1 * m_character.Speed * Time.deltaTime; m_horizontalDir = E_Direction.LEFT; } transform.position = pos; } }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { m_Direction = E_Direction.None; if (Input.GetKey(KeyCode.Z)) { m_Direction = E_Direction.North; } if (Input.GetKey(KeyCode.S)) { m_Direction = E_Direction.South; } if (Input.GetKey(KeyCode.D)) { m_Direction = E_Direction.East; } if (Input.GetKey(KeyCode.Q)) { m_Direction = E_Direction.West; } if (_Player.CanMove()) { if (m_Direction != E_Direction.None) { I_Unit unitOnTile = _Player.GetTile().GetNeighbour(m_Direction).GetUnit(); if (_Player.CanMoveTo(m_Direction)) { _Player.Move(m_Direction); TurnOrder.StartAllUnitsTurn(); } else if (unitOnTile is UnitEnemy) { _Player.SetAttackingEnemy(unitOnTile as UnitEnemy); } else { _Player.TurnToward(m_Direction); } } } _Controller.SetAnimatorBool("IsMoving", _Player.IsMoving()); }
void TurnAirplane(E_Direction dir) { switch (dir) { case E_Direction.DIR_LEFT: airplaneRenderer.sprite = airplaneSprites[(int)E_Direction.DIR_LEFT]; PlayerController.DoTurn(true); break; case E_Direction.DIR_DOWN: airplaneRenderer.sprite = airplaneSprites[(int)E_Direction.DIR_DOWN]; PlayerController.DoDown(); break; default: // DIR_RIGHT airplaneRenderer.sprite = airplaneSprites[(int)E_Direction.DIR_RIGHT]; PlayerController.DoTurn(false); break; } }
// Устанавливает новое направление голове public void Set_New_Direction(E_Direction a_direction) { bool if_conceded_direction = false; switch (a_direction) { case E_Direction.Left: if (Direction != E_Direction.Right) { if_conceded_direction = true; } break; case E_Direction.Right: if (Direction != E_Direction.Left) { if_conceded_direction = true; } break; case E_Direction.Up: if (Direction != E_Direction.Down) { if_conceded_direction = true; } break; case E_Direction.Down: if (Direction != E_Direction.Up) { if_conceded_direction = true; } break; } if (if_conceded_direction) { Direction = a_direction; } }
public void Reset() { MoveDirection = Vector3.zero; FireDirection = Vector3.zero; WalkOnly = false; Sprint = false; MoveSpeedModifier = 1; CoverSelected = null; CoverPosition = E_CoverDirection.Unknown; CoverNear.Reset(); InteractionObject = null; Animation = null; Weapon = E_WeaponID.None; Gadget = E_ItemID.None; WeaponTriggerOn = false; WeaponTriggerUp = false; WeaponTriggerUpDisabled = true; MeleeTarget = null; MeleeTriggerOn = false; RollDirection = E_Direction.None; }
// Задать новое направление движения голове змеи public void Set_New_Direction(E_Direction a_direction) { m_Snake.Set_New_Direction(a_direction); m_f_is_Delay_Over = false; m_Timer_for_Delay.Start(); }
// Задать новое направление голове public void Set_New_Direction(E_Direction a_direction) { m_head.Set_New_Direction(a_direction); }
private bool if_Normal_Moving(S_Location a_location, E_Direction a_direction) { bool f_result = true; // Сперва, проверяем не уткнулась ли она в стены switch (a_direction) { case E_Direction.Left: if (a_location.X < m_Board.Left_Bound) f_result = false; break; case E_Direction.Right: if (a_location.X > m_Board.Right_Bound) f_result = false; break; case E_Direction.Up: if (a_location.Y < m_Board.Up_bound) f_result = false; break; case E_Direction.Down: if (a_location.Y > m_Board.Low_bound) f_result = false; break; } if (!f_result) return f_result; // Проверим не уткнулась ли она в себя или в свои отходы if (m_Board.Return_Point(a_location).Is_Free == false) f_result = false; return f_result; }
public S_Tail(S_Location a_Location, E_Direction a_Direction, S_Body_Block a_Next_Body_Block = null) : base(a_Location, a_Direction, a_Next_Body_Block) { }
public S_Body_Block(S_Location a_Location, E_Direction a_Direction, S_Body_Block a_Next_Body_Block = null) : base(a_Location) { m_Direction = a_Direction; m_Next_Block = a_Next_Body_Block; }
public static void ReportRoll(uLink.NetworkPlayer player, E_Direction direction, uLink.NetworkMessageInfo info) { }
public S_Head(S_Location a_Location, E_Direction a_Direction) : base(a_Location, a_Direction) { }
// Устанавливает новое направление голове public void Set_New_Direction(E_Direction a_direction) { bool if_conceded_direction = false; switch (a_direction) { case E_Direction.Left: if (Direction != E_Direction.Right) if_conceded_direction = true; break; case E_Direction.Right: if (Direction != E_Direction.Left) if_conceded_direction = true; break; case E_Direction.Up: if (Direction != E_Direction.Down) if_conceded_direction = true; break; case E_Direction.Down: if (Direction != E_Direction.Up) if_conceded_direction = true; break; } if (if_conceded_direction) Direction = a_direction; }
//create a corridor from a startpoint and dir bool CreateCorridor(int corridorStartX, int corridorStartZ, int corridorLength, E_Direction corridorDir, E_TileMaterialType tileMaterialType) { int corridorDirDeltaX, corridorDirDeltaZ; if (corridorDir == E_Direction.Unset) { return(false); } switch (corridorDir) { case E_Direction.Up: corridorDirDeltaX = 0; corridorDirDeltaZ = 1; break; case E_Direction.Down: corridorDirDeltaX = 0; corridorDirDeltaZ = -1; break; case E_Direction.Left: corridorDirDeltaX = -1; corridorDirDeltaZ = 0; break; case E_Direction.Right: corridorDirDeltaX = 1; corridorDirDeltaZ = 0; break; default: corridorDirDeltaX = 0; corridorDirDeltaZ = 0; return(false); } for (int i = 0; i < corridorLength + 1; i++) { //check for enough space switch (corridorDir) { case E_Direction.Up: if (corridorStartX - 1 < 0 || corridorStartX + 1 > layerTile.GetLength(0) - 1 || corridorStartZ + i < 0 || corridorStartZ + i > layerTile.GetLength(1) - 1) { return(false); } if (layerTile[corridorStartX, corridorStartZ + i] != E_TileType.empty || layerTile[corridorStartX + 1, corridorStartZ + i] != E_TileType.empty || layerTile[corridorStartX - 1, corridorStartZ + i] != E_TileType.empty) { return(false); } break; case E_Direction.Down: if (corridorStartX - 1 < 0 || corridorStartX + 1 > layerTile.GetLength(0) - 1 || corridorStartZ - i < 0 || corridorStartZ - i > layerTile.GetLength(1) - 1) { return(false); } if (layerTile[corridorStartX, corridorStartZ - i] != E_TileType.empty || layerTile[corridorStartX + 1, corridorStartZ - i] != E_TileType.empty || layerTile[corridorStartX - 1, corridorStartZ - i] != E_TileType.empty) { return(false); } break; case E_Direction.Left: if (corridorStartX - i < 0 || corridorStartX - i > layerTile.GetLength(0) - 1 || corridorStartZ - 1 < 0 || corridorStartZ + 1 > layerTile.GetLength(1) - 1) { return(false); } if (layerTile[corridorStartX - i, corridorStartZ] != E_TileType.empty || layerTile[corridorStartX - i, corridorStartZ + 1] != E_TileType.empty || layerTile[corridorStartX - i, corridorStartZ - 1] != E_TileType.empty) { return(false); } break; case E_Direction.Right: if (corridorStartX + i < 0 || corridorStartX + i > layerTile.GetLength(0) - 1 || corridorStartZ - 1 < 0 || corridorStartZ + 1 > layerTile.GetLength(1) - 1) { return(false); } if (layerTile[corridorStartX + i, corridorStartZ] != E_TileType.empty || layerTile[corridorStartX + i, corridorStartZ + 1] != E_TileType.empty || layerTile[corridorStartX + i, corridorStartZ - 1] != E_TileType.empty) { return(false); } break; default: break; } } //material type Transform[] floorTiles, wallTiles; SetTileMaterial(tileMaterialType, out floorTiles, out wallTiles); //generate corridor root MapElement currentCorridorScript = GenerateElementRoot(E_MapElementType.Corridor, corridorStartX, corridorStartZ); currentCorridorScript.startX = corridorStartX; currentCorridorScript.startZ = corridorStartZ; currentCorridorScript.dirX = corridorDirDeltaX; currentCorridorScript.dirZ = corridorDirDeltaZ; //generate tiles currentCorridorScript.tileSingle = new Transform[corridorLength]; currentCorridorScript.walls = new List <Transform> (); for (int i = 0; i < corridorLength; i++) { currentCorridorScript.tileSingle[i] = RandomlyCreateTile(corridorDirDeltaX * i, corridorDirDeltaZ * i, floorTiles); if (corridorDirDeltaX == 0) { layerTile[corridorStartX, corridorStartZ + corridorDirDeltaZ * i] = E_TileType.corridor_Vertical; RandomlyCreateWall(corridorDirDeltaX * i, corridorDirDeltaZ * i, wallTiles, E_Direction.Left, currentCorridorScript.walls); RandomlyCreateWall(corridorDirDeltaX * i, corridorDirDeltaZ * i, wallTiles, E_Direction.Right, currentCorridorScript.walls); } else { layerTile[corridorStartX + corridorDirDeltaX * i, corridorStartZ] = E_TileType.corridor_Horizontal; RandomlyCreateWall(corridorDirDeltaX * i, corridorDirDeltaZ * i, wallTiles, E_Direction.Up, currentCorridorScript.walls); RandomlyCreateWall(corridorDirDeltaX * i, corridorDirDeltaZ * i, wallTiles, E_Direction.Down, currentCorridorScript.walls); } //corridor end wall if (i == corridorLength - 1) { RandomlyCreateWall(corridorDirDeltaX * i, corridorDirDeltaZ * i, wallTiles, corridorDir, currentCorridorScript.walls); } } //corridor is created with a exit (beginning) currentCorridorScript.exitCount = 1; return(true); }
bool CreateCorridorFromMapElement(Transform mapElem, E_TileMaterialType tileMaterialType, int index = -1) { List <Transform> chosenWalls = mapElem.GetComponent <MapElement> ().walls; Transform testedWall; if (index == -1) { testedWall = chosenWalls[Random.Range(0, chosenWalls.Count - 1)]; } else { testedWall = chosenWalls[index]; } int wallX = Mathf.RoundToInt(testedWall.position.x) / tileWidth; int wallZ = Mathf.RoundToInt(testedWall.position.z) / tileWidth; int corridorStartX, corridorStartZ; //如果处于房间拐角则不能创建 if (layerTile[wallX, wallZ] == E_TileType.corner_LeftDown || layerTile[wallX, wallZ] == E_TileType.corner_LeftUp || layerTile[wallX, wallZ] == E_TileType.corner_RightDown || layerTile[wallX, wallZ] == E_TileType.corner_RightUp) { return(false); } E_Direction WallDir = CheckWallDirection(testedWall); //corridor direction if (WallDir == E_Direction.Unset) { return(false); } switch (WallDir) { case E_Direction.Up: corridorStartX = wallX; corridorStartZ = wallZ + 1; break; case E_Direction.Down: corridorStartX = wallX; corridorStartZ = wallZ - 1; break; case E_Direction.Left: corridorStartX = wallX - 1; corridorStartZ = wallZ; break; case E_Direction.Right: corridorStartX = wallX + 1; corridorStartZ = wallZ; break; default: corridorStartX = wallX; corridorStartZ = wallZ; return(false); } //random corridor length int corridorLength = Random.Range(minCorridorLength, maxCorridorLength); if (CreateCorridor(corridorStartX, corridorStartZ, corridorLength, WallDir, tileMaterialType)) { mapElem.GetComponent <MapElement>().exitCount++; chosenWalls.Remove(testedWall); //新建立的corridor将保存被隐藏的wall layerCorridors[layerCorridors.Count - 1].GetComponent <MapElement>().removedWall = testedWall; testedWall.gameObject.SetActive(false); return(true); } else { return(false); } }
public abstract string GetRollAnim(E_Direction direction);