public void DoppelMove(Vector3 direc) { MapPos nextPos = GetNextPos(nowPos, direc); nextObj = goMap[nextPos.floor, nextPos.x, nextPos.z]; transform.localRotation = Quaternion.LookRotation(direc); animator.SetBool(key_walk, true); if (nextObj == null) { StartCoroutine(Move(direc)); stayCnt = 0; } else { if (nextObj.tag.Contains("Movable")) { GameObject moveBlock = goMap[nextPos.floor, nextPos.x, nextPos.z]; BlockController b = moveBlock.GetComponent <BlockController>(); b.BlockMove(direc); if (goMap[nextPos.floor, nextPos.x, nextPos.z] == null) { //ブロック移動後移動先が空いているなら == ブロックが動けたなら プレイヤーを動かす StartCoroutine(Move(direc)); stayCnt = 0; } } } doppelPos[number] = nowPos; }
public void PlayerMove(Vector3 direc) { MapPos nextPos = GetNextPos(nowPos, direc); nextObj = goMap[nextPos.floor, nextPos.x, nextPos.z]; transform.localRotation = Quaternion.LookRotation(direc); animator.SetBool(key_walk, true); if (nextPos == doppelPos) { gameOver = true; return; } if (nextObj == null) { StartCoroutine(Move(direc)); stayCnt = 0; } else { if (nextObj.tag.Contains("Movable")) { GameObject moveBlock = goMap[nextPos.floor, nextPos.x, nextPos.z]; BlockController b = moveBlock.GetComponent <BlockController>(); MapPos nextnextPos = GetNextPos(nextPos, direc); if (!(nextnextPos.ExceedRange() || nextnextPos.ExceedRange() && nextnextPos == doppelPos)) { b.BlockMove(direc); if (goMap[nextPos.floor, nextPos.x, nextPos.z] == null) { //ブロック移動後移動先が空いているなら == ブロックが動けたなら プレイヤーを動かす StartCoroutine(Move(direc)); stayCnt = 0; } } } } playerPos = nowPos; }