//同じ高さかチェック bool IsWalkable(MapNodePlate target) { enAngle angle = GetAngle(target); enAngle tagAngle = RevAngle(angle); float myY = this.stY + GetAngleHeight((EnumShapeType)this.shapeType, angle); float tagY = target.stY + GetAngleHeight((EnumShapeType)target.shapeType, tagAngle); //Debug.Log("myY"+ myY + "tagY" + tagY); return(myY == tagY); }
//位置関係から角度 enAngle GetAngle(MapNodePlate target) { enAngle res = enAngle.Same; if (this.stX < target.stX) { if (this.stZ < target.stZ) { res = enAngle.BackRight; } else if (this.stZ > target.stZ) { res = enAngle.FrontRight; } else { res = enAngle.Right; } } else if (this.stX > target.stX) { if (this.stZ < target.stZ) { res = enAngle.BackLeft; } else if (this.stZ > target.stZ) { res = enAngle.FrontLeft; } else { res = enAngle.Left; } } else { if (this.stZ < target.stZ) { res = enAngle.Back; } else if (this.stZ > target.stZ) { res = enAngle.Front; } else { res = enAngle.Same; } } return(res); }
//逆方向 enAngle RevAngle(enAngle angle) { enAngle res = angle; switch (angle) { case enAngle.Back: res = enAngle.Front; break; case enAngle.BackRight: res = enAngle.FrontLeft; break; case enAngle.Right: res = enAngle.Left; break; case enAngle.FrontRight: res = enAngle.BackLeft; break; case enAngle.Front: res = enAngle.Back; break; case enAngle.FrontLeft: res = enAngle.BackRight; break; case enAngle.Left: res = enAngle.Right; break; case enAngle.BackLeft: res = enAngle.FrontRight; break; } return(res); }
//チップの向きごとの高さ static float GetAngleHeight(EnumShapeType tipType, enAngle angle) { float res = 0f; switch (tipType) { case EnumShapeType.Box: res = 1f; break; case EnumShapeType.LUpSlope: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.5f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 0f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 1f; break; } break; case EnumShapeType.RUpSlope: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.5f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 1f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 0f; break; } break; case EnumShapeType.LUpSlope2H: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.75f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 0.5f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 1f; break; } break; case EnumShapeType.LUpSlope2L: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.25f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 0f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 0.5f; break; } break; case EnumShapeType.RUpSlope2L: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.25f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 0.5f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 0f; break; } break; case EnumShapeType.RUpSlope2H: switch (angle) { case enAngle.Back: case enAngle.Front: res = 0.75f; break; case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 1f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.BackLeft: res = 0.5f; break; } break; case EnumShapeType.SlashWall: switch (angle) { case enAngle.Back: case enAngle.BackLeft: case enAngle.BackRight: case enAngle.FrontLeft: case enAngle.Left: res = 1f; break; case enAngle.Right: case enAngle.FrontRight: case enAngle.Front: res = 0f; break; } break; case EnumShapeType.BSlashWall: switch (angle) { case enAngle.Back: case enAngle.BackLeft: case enAngle.BackRight: case enAngle.Right: case enAngle.FrontRight: res = 1f; break; case enAngle.FrontLeft: case enAngle.Left: case enAngle.Front: res = 0f; break; } break; } return(res); }