public void CheckAttack() { if (m_isMoving || m_ani.GetBool("climb")) { return; } //stand on the wall and target must be wall CELL_TYPE underType = (CELL_TYPE)m_mapCtr.GetMapCell(m_row - 1, m_col).CellData.cellType; if (underType == CELL_TYPE.WALL || underType == CELL_TYPE.STONE) { Debug.Log("under type ok"); int look = 1; // if (m_isLookLeft) // look = -1; MapCellCtr target = m_mapCtr.GetMapCell(m_row, m_col + look); if ((CELL_TYPE)target.CellData.cellType == CELL_TYPE.NONE) { Debug.Log("dir ok"); MapCellCtr targetDown = m_mapCtr.GetMapCell(m_row - 1, m_col + look); if ((CELL_TYPE)targetDown.CellData.cellType == CELL_TYPE.WALL) { Debug.Log("dir down ok"); m_isAttack = true; m_ani.SetBool("run", false); m_ani.SetBool("attack", m_isAttack); State = PlayerState.ATTACK; targetDown.ChangeToNone(true); } } } }
void MoveUp() { CELL_TYPE type = (CELL_TYPE)m_mapCtr.GetMapCell(m_row + 1, m_col).CellData.cellType; if (type != CELL_TYPE.STONE && type != CELL_TYPE.WALL && (CELL_TYPE)m_curCell.CellData.cellType == CELL_TYPE.LADDER) { MapCellCtr target = m_mapCtr.GetMapCell(m_row + 1, m_col); if (null != target) { m_targetPos = target.Position; m_isMoving = true; m_dir = new Vector3(0, 1, 0); m_ani.SetBool("run", false); m_ani.SetBool("climb", true); State = PlayerState.CLIMB; m_isLookLeft = false; transform.localEulerAngles = new Vector3(0, 0, 0); m_body.transform.localEulerAngles = new Vector3(0, 0, 0); } else { Debug.LogWarning("warning: astarMap not match spriteMap:" + (m_row + 1) + "," + (m_col)); } } }
// Costruttore per celle con proprieta' collegata public Cell(int Position, CELL_TYPE Type, Property RelProperty) { this.Position = Position; this.Type = Type; this.RelProperty = RelProperty; this.tokensOnCell = 0; }
// Costruttore per celle con valore di vincita/perdita collegato public Cell(int Position, CELL_TYPE Type, int Value) { this.Position = Position; this.Type = Type; this.Value = Value; this.tokensOnCell = 0; }
public void copy(Cell cell) { ID = cell.ID; Cell_Type = cell.Cell_Type; H = cell.H; rec_ID = cell.rec_ID; recrystalized = cell.recrystalized; }
public Cell() { ID = 0; H = 0; rec_ID = 0; recrystalized = false; Cell_Type = CELL_TYPE.EMPTY; }
public void Init(MapDisplay owner, MapCellData data) { m_owner = owner; m_data = data; m_addition = (CELL_ADDITION)data.cellAdd; m_type = (CELL_TYPE)data.cellType; if (!string.IsNullOrEmpty(data.resName)) { Render.sprite = Resources.Load("Sprites/" + data.resName, typeof(Sprite)) as Sprite; } else { Render.sprite = null; } transform.position = owner.startPos + new Vector3(data.col * owner.cellSize.x, data.row * owner.cellSize.y, owner.startPos.z); //Render.sortingLayerID = SortingLayer.GetLayerValueFromID(data.sortLayer); Render.sortingOrder = data.sortOrder; Render.sortingLayerName = data.sortLayer; }
static void SetAStarMapCell_Second(MapData map, MapCellData cell, ref AStarMap astarMap) { // check second time CELL_TYPE curType = (CELL_TYPE)cell.cellType; if (curType == CELL_TYPE.STONE || curType == CELL_TYPE.WALL) { return; } if (cell.row - 1 >= 0) { MapCellData downCell = map.cells [(cell.row - 1) * map.column + cell.col]; CELL_TYPE downType = (CELL_TYPE)downCell.cellType; if (downType == CELL_TYPE.WALL || downType == CELL_TYPE.STONE || downType == CELL_TYPE.LADDER) { //right if (cell.col + 1 < map.column) { MapCellData rightCell = map.cells [(cell.row) * map.column + cell.col + 1]; CELL_TYPE rightType = (CELL_TYPE)rightCell.cellType; if (rightType != CELL_TYPE.WALL && rightType != CELL_TYPE.STONE) { //astarMapCell.IsToRight = true; astarMap.GetCell(rightCell.row, rightCell.col).IsToLeft = true; } } //left if (cell.col - 1 >= 0) { MapCellData leftCell = map.cells [(cell.row) * map.column + cell.col - 1]; CELL_TYPE leftType = (CELL_TYPE)leftCell.cellType; if (leftType != CELL_TYPE.WALL && leftType != CELL_TYPE.STONE) { //astarMapCell.IsToLeft = true; astarMap.GetCell(leftCell.row, leftCell.col).IsToRight = true; } } } } }
void CheckGround() { //not pole ladder && can move down m_ani.SetBool("jump", false); if ((CELL_TYPE)m_curCell.CellData.cellType != CELL_TYPE.POLE && (CELL_TYPE)m_curCell.CellData.cellType != CELL_TYPE.LADDER) { CELL_TYPE type = (CELL_TYPE)m_mapCtr.GetMapCell(m_row - 1, m_col).CellData.cellType; if (type != CELL_TYPE.LADDER) { MoveDown(); } } else if ((CELL_TYPE)m_curCell.CellData.cellType == CELL_TYPE.POLE) { transform.localEulerAngles = new Vector3(0, 0, 90); m_body.transform.localEulerAngles = new Vector3(0, 90, 0); m_ani.SetBool("run", false); m_ani.SetBool("climb", true); State = PlayerState.CLIMB; m_isLookLeft = true; } }
void MoveLeft() { CELL_TYPE type = (CELL_TYPE)m_mapCtr.GetMapCell(m_row, m_col - 1).CellData.cellType; if (type != CELL_TYPE.STONE && type != CELL_TYPE.WALL) { MapCellCtr target = m_mapCtr.GetMapCell(m_row, m_col - 1); if (null != target) { m_targetPos = target.Position; m_isMoving = true; m_dir = new Vector3(-1, 0, 0); if ((CELL_TYPE)target.CellData.cellType == CELL_TYPE.POLE) { transform.localEulerAngles = new Vector3(0, 0, 90); m_body.transform.localEulerAngles = new Vector3(0, 90, 0); m_ani.SetBool("run", false); m_ani.SetBool("climb", true); State = PlayerState.CLIMB; m_isLookLeft = true; } else { transform.localEulerAngles = new Vector3(0, 0, 0); m_body.transform.localEulerAngles = new Vector3(0, -90, 0); m_isLookLeft = true; m_ani.SetBool("run", true); m_ani.SetBool("climb", false); State = PlayerState.RUN; } } else { Debug.LogWarning("warning: astarMap not match spriteMap:" + m_row + "," + (m_col + 1)); } } }
void FixedUpdate() { if (!CanControl) { return; } //上格子 Vector2 upPos = new Vector2(transform.position.x, transform.position.y + (float)m_mapCtr.Map.cellHeight * 0.5f); MapCellCtr upCell = m_mapCtr.GetMapCell(upPos); CELL_TYPE upCellType = (CELL_TYPE)upCell.CellData.cellType; //下 MapCellCtr downCell = m_mapCtr.GetMapCell(new Vector2(transform.position.x, transform.position.y - (float)m_mapCtr.Map.cellHeight * 0.5f)); CELL_TYPE downCellType = (CELL_TYPE)downCell.CellData.cellType; //右 Vector2 rightPos = new Vector2(transform.position.x + (float)m_mapCtr.Map.cellWidth * 0.5f, transform.position.y); MapCellCtr rightCell = m_mapCtr.GetMapCell(rightPos); CELL_TYPE rightCellType = (CELL_TYPE)rightCell.CellData.cellType; //左 Vector2 leftPos = new Vector2(transform.position.x - (float)m_mapCtr.Map.cellWidth * 0.5f, transform.position.y); MapCellCtr leftCell = m_mapCtr.GetMapCell(leftPos); CELL_TYPE leftCellType = (CELL_TYPE)leftCell.CellData.cellType; //foot MapCellCtr footCell = m_mapCtr.GetMapCell(new Vector2(transform.position.x, transform.position.y - (float)m_mapCtr.Map.cellHeight * 0.5f + 0.1f)); CELL_TYPE footCellType = (CELL_TYPE)footCell.CellData.cellType; //cur m_curCell = m_mapCtr.GetMapCell(new Vector2(transform.position.x, transform.position.y)); CELL_TYPE curCellType = (CELL_TYPE)m_curCell.CellData.cellType; m_row = m_curCell.CellData.row; m_col = m_curCell.CellData.col; //检查是否劈砖 float angleY = m_body.transform.localRotation.eulerAngles.y; angleY = angleY > 180 ? (angleY - 360):angleY; if (angleY > 10) { m_look = 1; } else if (angleY < -10) { m_look = -1; } else { m_look = 0; } if (m_isHitInput) { m_isHitInput = false; if (downCellType == CELL_TYPE.WALL || downCellType == CELL_TYPE.STONE) { if (m_look != 0) { MapCellCtr target = m_mapCtr.GetMapCell(m_row, m_col + m_look); if ((CELL_TYPE)target.CellData.cellType == CELL_TYPE.NONE) { MapCellCtr targetDown = m_mapCtr.GetMapCell(m_row - 1, m_col + m_look); if ((CELL_TYPE)targetDown.CellData.cellType == CELL_TYPE.WALL) { m_isAttack = true; m_ani.SetBool("run", false); m_ani.SetBool("attack", m_isAttack); targetDown.ChangeToNone(true); AudioManager.Instance.PlayAudio("attack"); } } } } } if (m_isAttack) { return; } //计算重力 m_verticalAccelerate += m_g; if (m_verticalAccelerate > 0) { if (upCellType == CELL_TYPE.STONE || upCellType == CELL_TYPE.WALL) { m_verticalAccelerate = 0; } if (footCellType == CELL_TYPE.POLE) { m_verticalAccelerate = m_g; m_isGround = true; } } else if (m_verticalAccelerate < 0) { if (downCellType == CELL_TYPE.STONE || downCellType == CELL_TYPE.WALL || downCellType == CELL_TYPE.LADDER || curCellType == CELL_TYPE.POLE) { m_verticalAccelerate = 0; m_isGround = true; } else { m_isGround = false; m_body.transform.localEulerAngles = new Vector3(0, m_body.transform.localEulerAngles.y, 0); } // if (downCellType == CELL_TYPE.STONE || downCellType == CELL_TYPE.WALL) { transform.position = new Vector3(transform.position.x, downCell.Position.y + (float)m_mapCtr.Map.cellHeight - 0.01f, transform.position.z); } } else { m_isGround = true; } //计算左右位移和上下楼梯 if (m_dir.x > 0) { if (rightCellType == CELL_TYPE.STONE || rightCellType == CELL_TYPE.WALL) { m_dir = new Vector2(0, m_dir.y); } } else if (m_dir.x < 0) { if (leftCellType == CELL_TYPE.STONE || leftCellType == CELL_TYPE.WALL) { m_dir = new Vector2(0, m_dir.y); } } // if (m_dir.y > 0) { if (footCellType != CELL_TYPE.LADDER) { m_dir = new Vector2(m_dir.x, 0); } } else { if (downCellType == CELL_TYPE.STONE || downCellType == CELL_TYPE.WALL) { m_dir = new Vector2(m_dir.x, 0); } } //最后综合考虑重力和输入的上下左右 Vector2 velocity = m_verticalAccelerate * new Vector2(0, 1) * Time.fixedDeltaTime + m_dir * m_moveSpeed; Vector2 dist = velocity * Time.fixedDeltaTime; transform.position += new Vector3(dist.x, dist.y, 0); //animation //是否播放run动画 if (Mathf.Abs(m_dir.x) > 0 && m_isGround) { if ((footCellType != CELL_TYPE.LADDER && footCellType != CELL_TYPE.POLE) || (downCellType == CELL_TYPE.WALL || downCellType == CELL_TYPE.STONE)) { m_isRun = true; } else { m_isRun = false; } } else { m_isRun = false; } //是否播放climb动画 m_isPole = false; if (m_isGround && (footCellType == CELL_TYPE.LADDER || curCellType == CELL_TYPE.POLE)) { if (downCellType == CELL_TYPE.STONE || downCellType == CELL_TYPE.WALL) { m_isClimb = false; } else { m_isClimb = true; if (curCellType == CELL_TYPE.POLE) { m_isPole = true; } } } // else if(m_isGround && curCellType == CELL_TYPE.POLE && Mathf.Abs(m_dir.x) > 0){ // m_isClimb = true; // } else { m_isClimb = false; } if (m_isGround && dist == Vector2.zero && m_isClimb) { m_ani.speed = 0; } else { m_ani.speed = 1; } m_ani.SetBool("isGround", m_isGround); m_ani.SetBool("climb", m_isClimb); if (m_isClimb) { if (Mathf.Abs(m_dir.y) > 0) { AudioManager.Instance.PlayAudio("climb", true); } else { AudioManager.Instance.StopAudio("climb"); } if (m_isPole) { //朝左爬 if (velocity.x > 0.001f) { m_body.transform.localEulerAngles = new Vector3(-90, 90, 180); m_body.transform.localPosition = new Vector3(-0.5f, m_localPositionTemp.y * 0.5f, m_localPositionTemp.z); } else if (velocity.x < -0.001f) //朝右爬 { m_body.transform.localEulerAngles = new Vector3(-90, 90, 0); m_body.transform.localPosition = new Vector3(0.5f, m_localPositionTemp.y * 0.5f, m_localPositionTemp.z); } else { //未输入左右参数,且还未进行体位旋转 if (Mathf.Abs(m_body.transform.localPosition.x - 0.5f) > 0.01f) { m_body.transform.localEulerAngles = new Vector3(-90, 90, 180); m_body.transform.localPosition = new Vector3(-0.5f, m_localPositionTemp.y * 0.5f, m_localPositionTemp.z); } } } else { m_body.transform.localPosition = m_localPositionTemp; m_body.transform.localEulerAngles = new Vector3(0, 0, 0); } } else { AudioManager.Instance.StopAudio("climb"); m_body.transform.localPosition = m_localPositionTemp; //m_body.transform.localEulerAngles = new Vector3 (0, 90, 0); } m_ani.SetBool("run", m_isRun); if (m_isRun) { //AudioManager.Instance.PlayAudio("run", true); if (velocity.x > 0) { m_body.transform.localEulerAngles = new Vector3(0, 90, 0); } else { m_body.transform.localEulerAngles = new Vector3(0, -90, 0); } } else { //AudioManager.Instance.StopAudio("run"); } //是否播放jump动画 if (m_verticalAccelerate > 0 && !m_isGround && !m_ani.GetBool("jump")) { m_ani.SetBool("jump", true); AudioManager.Instance.PlayAudio("jump"); } if (m_isGround) { m_ani.SetBool("jump", false); } if (m_verticalAccelerate < 0 && !m_isGround) { if (m_dir.x > 0) { m_body.transform.localEulerAngles = new Vector3(0, 90, 0); } else if (m_dir.x < 0) { m_body.transform.localEulerAngles = new Vector3(0, -90, 0); } } //检查当前格子是否有bra/underpant/sock物品 object[] p = new object[2]; p[0] = (object)Row; p[1] = (object)Column; if (curCellType == CELL_TYPE.BRA) { MapCell.ChangeToNone(false); GameStateManager.Instance().FSM.CurrentState.Message("GetBra", p); AudioManager.Instance.PlayAudio("get"); } else if (curCellType == CELL_TYPE.UNDERPANT) { MapCell.ChangeToNone(false); GameStateManager.Instance().FSM.CurrentState.Message("GetUnderpant", p); AudioManager.Instance.PlayAudio("get"); } else if (curCellType == CELL_TYPE.SOCKS) { MapCell.ChangeToNone(false); GameStateManager.Instance().FSM.CurrentState.Message("GetSocks", p); AudioManager.Instance.PlayAudio("get"); } //是否是出口 if (m_mapCtr.CanExit && Row == m_mapCtr.ExitEndRow && Column == m_mapCtr.ExitEndCol) { GameStateManager.Instance().FSM.CurrentState.Message("Vectory", p); } //是否遇到狗狗 if (m_mapCtr.IsMeetWithDog(transform.position)) { GameStateManager.Instance().FSM.CurrentState.Message("PlayerDead", p); } }
// Costruttore per celle di tipo neutro o prigione o proprieta' non ancora assegnabile public Cell(int Position, CELL_TYPE Type) { this.Position = Position; this.Type = Type; }